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=chrome&ie=UTF-8&q=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 <[email protected]> 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, Kruncher<[email protected]> 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 <[email protected]> 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, Kruncher<[email protected]> 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: [email protected] View archives, change email options, or unsubscribe: http://groups.google.com/group/chromium-dev -~----------~----~----~----~------~----~------~--~---
