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
-~----------~----~----~----~------~----~------~--~---

Reply via email to