[chromium-dev] Re: Adding a Custom Scheme

2009-07-30 Thread Peter Kasting
On Wed, Jul 29, 2009 at 9:18 PM, Tim Steele t...@chromium.org wrote:

 I've done something like this in the past, and it used to be that if I
 selected the second suggestion (which was *not* a Search Google for: ...
 type suggestion, it would actually go to my registered URL and from that
 point on this became the default whenever I typed a URL with my scheme.


Sorry, but that has never been the behavior.

Navigation (rather than search) could become the default action for _that
URL_, but not for the entire scheme-- the autocomplete system doesn't learn
that way.


   I'm trying to remember which piece of code I traced this to.. I'll take a
 look and reply if I can find it.


Probably things like AutocompleteInput::Parse() and the various results the
AutocompleteProviders returned.  That's all higher-level than the desired
effect here, which needs to happen down in the scheme handling code.

PK

--~--~-~--~~~---~--~~
Chromium Developers mailing list: chromium-dev@googlegroups.com 
View archives, change email options, or unsubscribe: 
http://groups.google.com/group/chromium-dev
-~--~~~~--~~--~--~---



[chromium-dev] Re: Adding a Custom Scheme

2009-07-30 Thread Tim Steele
On Wed, Jul 29, 2009 at 11:39 PM, Peter Kasting pkast...@chromium.orgwrote:

 On Wed, Jul 29, 2009 at 9:18 PM, Tim Steele t...@chromium.org wrote:

 I've done something like this in the past, and it used to be that if I
 selected the second suggestion (which was *not* a Search Google for:
 ... type suggestion, it would actually go to my registered URL and from
 that point on this became the default whenever I typed a URL with my scheme.


 Sorry, but that has never been the behavior.

 Navigation (rather than search) could become the default action for _that
 URL_, but not for the entire scheme-- the autocomplete system doesn't learn
 that way.


Im describing what the behavior I saw was; not claiming to know how the
internals work.  Sorry for the confusion.  We only had one URL for the
scheme in question, so whether it was for the entire scheme didn't matter.
 At first we didn't even notice the option below Search Google for: .. 
and assumed our scheme wasn't getting registered, so I suggested it in case
something similar was going on here.

Thanks for clarifying though!



   I'm trying to remember which piece of code I traced this to.. I'll take
 a look and reply if I can find it.


 Probably things like AutocompleteInput::Parse() and the various results the
 AutocompleteProviders returned.  That's all higher-level than the desired
 effect here, which needs to happen down in the scheme handling code.

 PK


--~--~-~--~~~---~--~~
Chromium Developers mailing list: chromium-dev@googlegroups.com 
View archives, change email options, or unsubscribe: 
http://groups.google.com/group/chromium-dev
-~--~~~~--~~--~--~---



[chromium-dev] Re: Adding a Custom Scheme

2009-07-30 Thread Peter Kasting
On Thu, Jul 30, 2009 at 12:38 AM, Tim Steele t...@chromium.org wrote:

 We only had one URL for the scheme in question, so whether it was for the
 entire scheme didn't matter.


Ah.  Yeah, that'd do it.

PK

--~--~-~--~~~---~--~~
Chromium Developers mailing list: chromium-dev@googlegroups.com 
View archives, change email options, or unsubscribe: 
http://groups.google.com/group/chromium-dev
-~--~~~~--~~--~--~---



[chromium-dev] Re: Adding a Custom Scheme

2009-07-30 Thread Kruncher

I tried selecting an alternative from the autocomplete suggestions,
but all of them resort to a Google search.

From what I saw last night, it seems as though any factory methods
that are registered prior to the BrowserMain method are being
cleared, and then the Chromium methods are being registered. I haven't
been able to spend very much time exploring/breaking throughout the
Chromium source yet. I am going to give it another try when I get home
from work tonight.

Thanks,

On 30 July, 08:44, Peter Kasting pkast...@chromium.org wrote:
 On Thu, Jul 30, 2009 at 12:38 AM, Tim Steele t...@chromium.org wrote:

  We only had one URL for the scheme in question, so whether it was for the
  entire scheme didn't matter.

 Ah.  Yeah, that'd do it.

 PK
--~--~-~--~~~---~--~~
Chromium Developers mailing list: chromium-dev@googlegroups.com 
View archives, change email options, or unsubscribe: 
http://groups.google.com/group/chromium-dev
-~--~~~~--~~--~--~---



[chromium-dev] Re: Adding a Custom Scheme

2009-07-30 Thread Kruncher

I have just tried adding the scheme directly beneath where the
standard Chromium ones are being registered. The scheme is now being
recognized within the web browser.

When my-scheme://test is entered, the location bar now automatically
switches to http://192.168.1.4:8080/;.

Is it possible to make the Chromium location bar show my-scheme://
test but still have the page come from http://192.168.1.4:8080/;?

On 30 July, 09:39, Kruncher leaha...@gmail.com wrote:
 I tried selecting an alternative from the autocomplete suggestions,
 but all of them resort to a Google search.

 From what I saw last night, it seems as though any factory methods
 that are registered prior to the BrowserMain method are being
 cleared, and then the Chromium methods are being registered. I haven't
 been able to spend very much time exploring/breaking throughout the
 Chromium source yet. I am going to give it another try when I get home
 from work tonight.

 Thanks,

 On 30 July, 08:44, Peter Kasting pkast...@chromium.org wrote:



  On Thu, Jul 30, 2009 at 12:38 AM, Tim Steele t...@chromium.org wrote:

   We only had one URL for the scheme in question, so whether it was for the
   entire scheme didn't matter.

  Ah.  Yeah, that'd do it.

  PK
--~--~-~--~~~---~--~~
Chromium Developers mailing list: chromium-dev@googlegroups.com 
View archives, change email options, or unsubscribe: 
http://groups.google.com/group/chromium-dev
-~--~~~~--~~--~--~---



[chromium-dev] Re: Adding a Custom Scheme

2009-07-29 Thread Eric Roman

You are pretty close.

What you want to do is override URLRequestJob::IsRedirectResponse(),
rather than trying to do the redirect in the factory.

Something like this should work:


class URLRequestCustomJob : public URLRequestJob {
 public:
  explicit URLRequestCustomJob(URLRequest* request) : URLRequestJob(request) {}

  // URLRequestJob methods:
  virtual void Start() {
NotifyHeadersComplete();
  }

  virtual bool IsRedirectResponse(GURL* location, int* http_status_code) {
*http_status_code = 301;
*location = GURL(http://i-redirected-you/cuz-im-the-awesome;);
return true;
  }

  static URLRequestJob* Factory(URLRequest* request, const
std::string scheme) {
return new URLRequestCustomJob(request);
  }
};


On Mon, Jul 27, 2009 at 5:44 PM, Kruncherleaha...@gmail.com wrote:

 Hi,

 I am trying to add a custom scheme to the Chromium browser. I am
 trying to write a scheme that will transparently redirect requests to
 another URL.

 For some reason, however, my custom scheme does not appear to get
 recognized. Could somebody tell me what I am doing wrong?

 For the time being I have added the following code to the
 chrome_exe_main.cc source.

 //
 // Added above the main Windows function.
 //

 #include net/url_request/url_request.h
 #include net/url_request/url_request_http_job.h

 static const char kCustomURLScheme[] = my-scheme;


 class URLRequestCustomJob : public URLRequestJob {
  public:
  static URLRequestJob* Factory(URLRequest* request, const
 std::string scheme) {
          DCHECK(scheme == my-scheme);

          // Redirect response to a local network resource.
          std::string requestPath = request-url().PathForRequest().replace
 (0, 10, http://192.168.1.4:8080;);

          // I tried using the following line, but it turns out that the
 Redirect function is protected.
          //request-Redirect(GURL(requestPath), request-status().status());
          // So instead I am attempting to create a new request.
          request = new URLRequest(GURL(requestPath), request-delegate());

          // Proceed with regular HTTP scheme factory.
          return URLRequestHttpJob::Factory(request, http);
        }
 };


 //
 // Added above #if defined(GOOGLE_CHROME_BUILD) inside Windows main
 function.
 //

 // Register custom scheme:
 url_util::AddStandardScheme(kCustomURLScheme);
 URLRequest::RegisterProtocolFactory(kCustomURLScheme,
 URLRequestCustomJob::Factory);

 Many thanks,
 Lea Hayes
 


--~--~-~--~~~---~--~~
Chromium Developers mailing list: chromium-dev@googlegroups.com 
View archives, change email options, or unsubscribe: 
http://groups.google.com/group/chromium-dev
-~--~~~~--~~--~--~---



[chromium-dev] Re: Adding a Custom Scheme

2009-07-29 Thread Eric Roman

The entry point would be to enter a URL that uses the custom scheme.

i.e. you would need to type in my-scheme://some-url to reach the
custom scheme handler.

Not sure what you are trying to build.

On Wed, Jul 29, 2009 at 3:39 PM, Kruncherleaha...@gmail.com wrote:

 Hi Eric,

 I have just tried the code that you have suggested, however, if I
 enter a URL in the Chromium location bar and hit enter, Chromium is
 still defaulting to a Google search.

 I have tried placing a breakpoint within the constructor and each of
 the virtual methods, and the factory method. When running in debug
 mode, none of these breakpoints are being hit. I tried adding a
 breakpoint directly after the factory is being registered, and the
 program is breaking at this point.

 Thanks for your help!

 On 29 July, 22:32, Eric Roman ero...@chromium.org wrote:
 You are pretty close.

 What you want to do is override URLRequestJob::IsRedirectResponse(),
 rather than trying to do the redirect in the factory.

 Something like this should work:

 class URLRequestCustomJob : public URLRequestJob {
  public:
   explicit URLRequestCustomJob(URLRequest* request) : URLRequestJob(request) 
 {}

   // URLRequestJob methods:
   virtual void Start() {
     NotifyHeadersComplete();
   }

   virtual bool IsRedirectResponse(GURL* location, int* http_status_code) {
     *http_status_code = 301;
     *location = GURL(http://i-redirected-you/cuz-im-the-awesome;);
     return true;
   }

   static URLRequestJob* Factory(URLRequest* request, const
 std::string scheme) {
     return new URLRequestCustomJob(request);
   }



 };
 On Mon, Jul 27, 2009 at 5:44 PM, Kruncherleaha...@gmail.com wrote:

  Hi,

  I am trying to add a custom scheme to the Chromium browser. I am
  trying to write a scheme that will transparently redirect requests to
  another URL.

  For some reason, however, my custom scheme does not appear to get
  recognized. Could somebody tell me what I am doing wrong?

  For the time being I have added the following code to the
  chrome_exe_main.cc source.

  //
  // Added above the main Windows function.
  //

  #include net/url_request/url_request.h
  #include net/url_request/url_request_http_job.h

  static const char kCustomURLScheme[] = my-scheme;

  class URLRequestCustomJob : public URLRequestJob {
   public:
   static URLRequestJob* Factory(URLRequest* request, const
  std::string scheme) {
           DCHECK(scheme == my-scheme);

           // Redirect response to a local network resource.
           std::string requestPath = request-url().PathForRequest().replace
  (0, 10, http://192.168.1.4:8080;);

           // I tried using the following line, but it turns out that the
  Redirect function is protected.
           //request-Redirect(GURL(requestPath), 
  request-status().status());
           // So instead I am attempting to create a new request.
           request = new URLRequest(GURL(requestPath), request-delegate());

           // Proceed with regular HTTP scheme factory.
           return URLRequestHttpJob::Factory(request, http);
         }
  };

  //
  // Added above #if defined(GOOGLE_CHROME_BUILD) inside Windows main
  function.
  //

  // Register custom scheme:
  url_util::AddStandardScheme(kCustomURLScheme);
  URLRequest::RegisterProtocolFactory(kCustomURLScheme,
  URLRequestCustomJob::Factory);

  Many thanks,
  Lea Hayes
 


--~--~-~--~~~---~--~~
Chromium Developers mailing list: chromium-dev@googlegroups.com 
View archives, change email options, or unsubscribe: 
http://groups.google.com/group/chromium-dev
-~--~~~~--~~--~--~---



[chromium-dev] Re: Adding a Custom Scheme

2009-07-29 Thread Kruncher

Those are the kinds of URL's that I have been trying, but when I hit
enter it reverts to:

http://www.google.co.uk/search?sourceid=chromeie=UTF-8q=my-scheme://some-url

It seems almost as though the scheme factory is not getting
registered.

I am working on a help viewer. When the viewer is opened a local web
server is initialized on port 8080 (for the time being). I basically
want to rewrite all URLs that begin with my-scheme:// with http://
192.168.1.4:8080/ the local machines IP address and port.


On 30 July, 00:10, Eric Roman ero...@chromium.org wrote:
 The entry point would be to enter a URL that uses the custom scheme.

 i.e. you would need to type in my-scheme://some-url to reach the
 custom scheme handler.

 Not sure what you are trying to build.



 On Wed, Jul 29, 2009 at 3:39 PM, Kruncherleaha...@gmail.com wrote:

  Hi Eric,

  I have just tried the code that you have suggested, however, if I
  enter a URL in the Chromium location bar and hit enter, Chromium is
  still defaulting to a Google search.

  I have tried placing a breakpoint within the constructor and each of
  the virtual methods, and the factory method. When running in debug
  mode, none of these breakpoints are being hit. I tried adding a
  breakpoint directly after the factory is being registered, and the
  program is breaking at this point.

  Thanks for your help!

  On 29 July, 22:32, Eric Roman ero...@chromium.org wrote:
  You are pretty close.

  What you want to do is override URLRequestJob::IsRedirectResponse(),
  rather than trying to do the redirect in the factory.

  Something like this should work:

  class URLRequestCustomJob : public URLRequestJob {
   public:
    explicit URLRequestCustomJob(URLRequest* request) : 
  URLRequestJob(request) {}

    // URLRequestJob methods:
    virtual void Start() {
      NotifyHeadersComplete();
    }

    virtual bool IsRedirectResponse(GURL* location, int* http_status_code) {
      *http_status_code = 301;
      *location = GURL(http://i-redirected-you/cuz-im-the-awesome;);
      return true;
    }

    static URLRequestJob* Factory(URLRequest* request, const
  std::string scheme) {
      return new URLRequestCustomJob(request);
    }

  };
  On Mon, Jul 27, 2009 at 5:44 PM, Kruncherleaha...@gmail.com wrote:

   Hi,

   I am trying to add a custom scheme to the Chromium browser. I am
   trying to write a scheme that will transparently redirect requests to
   another URL.

   For some reason, however, my custom scheme does not appear to get
   recognized. Could somebody tell me what I am doing wrong?

   For the time being I have added the following code to the
   chrome_exe_main.cc source.

   //
   // Added above the main Windows function.
   //

   #include net/url_request/url_request.h
   #include net/url_request/url_request_http_job.h

   static const char kCustomURLScheme[] = my-scheme;

   class URLRequestCustomJob : public URLRequestJob {
    public:
    static URLRequestJob* Factory(URLRequest* request, const
   std::string scheme) {
            DCHECK(scheme == my-scheme);

            // Redirect response to a local network resource.
            std::string requestPath = 
   request-url().PathForRequest().replace
   (0, 10, http://192.168.1.4:8080;);

            // I tried using the following line, but it turns out that the
   Redirect function is protected.
            //request-Redirect(GURL(requestPath), 
   request-status().status());
            // So instead I am attempting to create a new request.
            request = new URLRequest(GURL(requestPath), 
   request-delegate());

            // Proceed with regular HTTP scheme factory.
            return URLRequestHttpJob::Factory(request, http);
          }
   };

   //
   // Added above #if defined(GOOGLE_CHROME_BUILD) inside Windows main
   function.
   //

   // Register custom scheme:
   url_util::AddStandardScheme(kCustomURLScheme);
   URLRequest::RegisterProtocolFactory(kCustomURLScheme,
   URLRequestCustomJob::Factory);

   Many thanks,
   Lea Hayes
--~--~-~--~~~---~--~~
Chromium Developers mailing list: chromium-dev@googlegroups.com 
View archives, change email options, or unsubscribe: 
http://groups.google.com/group/chromium-dev
-~--~~~~--~~--~--~---



[chromium-dev] Re: Adding a Custom Scheme

2009-07-29 Thread Peter Kasting
On Wed, Jul 29, 2009 at 4:23 PM, Kruncher leaha...@gmail.com wrote:

 Those are the kinds of URL's that I have been trying, but when I hit
 enter it reverts to:


 http://www.google.co.uk/search?sourceid=chromeie=UTF-8q=my-scheme://some-url


Put my-scheme://some-url in the address bar and set a breakpoint in
URLRequestJobManager::SupportsScheme().  Now type a letter at the end.  You
should hit your breakpoint.  Check and see if |factories_| contains your
scheme.  If not, you need to make that happen.  If it does, and this
function therefore returns true, there's some problem at the time you
actually open the URL.

PK

--~--~-~--~~~---~--~~
Chromium Developers mailing list: chromium-dev@googlegroups.com 
View archives, change email options, or unsubscribe: 
http://groups.google.com/group/chromium-dev
-~--~~~~--~~--~--~---



[chromium-dev] Re: Adding a Custom Scheme

2009-07-29 Thread Kruncher

When the debugger breaks inside the SupportsScheme function, the
factories list does not include my-scheme.

Perhaps I am trying to register the scheme too early? Do I need to add
this directly below where the various chrome schemes are registered,
or is it possible to keep it in the domain of a custom application?

On 30 July, 00:40, Peter Kasting pkast...@google.com wrote:
 On Wed, Jul 29, 2009 at 4:23 PM, Kruncher leaha...@gmail.com wrote:
  Those are the kinds of URL's that I have been trying, but when I hit
  enter it reverts to:

 http://www.google.co.uk/search?sourceid=chromeie=UTF-8q=my-scheme:/...

 Put my-scheme://some-url in the address bar and set a breakpoint in
 URLRequestJobManager::SupportsScheme().  Now type a letter at the end.  You
 should hit your breakpoint.  Check and see if |factories_| contains your
 scheme.  If not, you need to make that happen.  If it does, and this
 function therefore returns true, there's some problem at the time you
 actually open the URL.

 PK
--~--~-~--~~~---~--~~
Chromium Developers mailing list: chromium-dev@googlegroups.com 
View archives, change email options, or unsubscribe: 
http://groups.google.com/group/chromium-dev
-~--~~~~--~~--~--~---



[chromium-dev] Re: Adding a Custom Scheme

2009-07-29 Thread Evan Martin

At this point you know more about the problem than the majority of the
Chrome team, so I suggest putting breakpoints in other code you're
trying to emulate and figuring it out from there.  :)

On Wed, Jul 29, 2009 at 5:02 PM, Kruncherleaha...@gmail.com wrote:

 When the debugger breaks inside the SupportsScheme function, the
 factories list does not include my-scheme.

 Perhaps I am trying to register the scheme too early? Do I need to add
 this directly below where the various chrome schemes are registered,
 or is it possible to keep it in the domain of a custom application?

 On 30 July, 00:40, Peter Kasting pkast...@google.com wrote:
 On Wed, Jul 29, 2009 at 4:23 PM, Kruncher leaha...@gmail.com wrote:
  Those are the kinds of URL's that I have been trying, but when I hit
  enter it reverts to:

 http://www.google.co.uk/search?sourceid=chromeie=UTF-8q=my-scheme:/...

 Put my-scheme://some-url in the address bar and set a breakpoint in
 URLRequestJobManager::SupportsScheme().  Now type a letter at the end.  You
 should hit your breakpoint.  Check and see if |factories_| contains your
 scheme.  If not, you need to make that happen.  If it does, and this
 function therefore returns true, there's some problem at the time you
 actually open the URL.

 PK
 


--~--~-~--~~~---~--~~
Chromium Developers mailing list: chromium-dev@googlegroups.com 
View archives, change email options, or unsubscribe: 
http://groups.google.com/group/chromium-dev
-~--~~~~--~~--~--~---



[chromium-dev] Re: Adding a Custom Scheme

2009-07-29 Thread Tim Steele
What happens if you type the URL in, but instead of hitting enter, press the
down arrow (to select a different autocomplete suggestion)?  I've done
something like this in the past, and it used to be that if I selected the
second suggestion (which was *not* a Search Google for: ... type
suggestion, it would actually go to my registered URL and from that point on
this became the default whenever I typed a URL with my scheme.   I'm trying
to remember which piece of code I traced this to.. I'll take a look and
reply if I can find it.

On Wed, Jul 29, 2009 at 5:02 PM, Kruncher leaha...@gmail.com wrote:


 When the debugger breaks inside the SupportsScheme function, the
 factories list does not include my-scheme.

 Perhaps I am trying to register the scheme too early? Do I need to add
 this directly below where the various chrome schemes are registered,
 or is it possible to keep it in the domain of a custom application?

 On 30 July, 00:40, Peter Kasting pkast...@google.com wrote:
  On Wed, Jul 29, 2009 at 4:23 PM, Kruncher leaha...@gmail.com wrote:
   Those are the kinds of URL's that I have been trying, but when I hit
   enter it reverts to:
 
  http://www.google.co.uk/search?sourceid=chromeie=UTF-8q=my-scheme:/.
 ..
 
  Put my-scheme://some-url in the address bar and set a breakpoint in
  URLRequestJobManager::SupportsScheme().  Now type a letter at the end.
  You
  should hit your breakpoint.  Check and see if |factories_| contains your
  scheme.  If not, you need to make that happen.  If it does, and this
  function therefore returns true, there's some problem at the time you
  actually open the URL.
 
  PK
 


--~--~-~--~~~---~--~~
Chromium Developers mailing list: chromium-dev@googlegroups.com 
View archives, change email options, or unsubscribe: 
http://groups.google.com/group/chromium-dev
-~--~~~~--~~--~--~---