diff options
Diffstat (limited to 'chrome/browser/extensions/extension_protocols.cc')
-rw-r--r-- | chrome/browser/extensions/extension_protocols.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_protocols.cc b/chrome/browser/extensions/extension_protocols.cc index 21dcd12..b6e66f6 100644 --- a/chrome/browser/extensions/extension_protocols.cc +++ b/chrome/browser/extensions/extension_protocols.cc @@ -6,12 +6,16 @@ #include "base/string_util.h" #include "chrome/browser/net/chrome_url_request_context.h" +#include "chrome/browser/renderer_host/resource_dispatcher_host.h" +#include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_file_util.h" #include "chrome/common/extensions/extension_resource.h" #include "chrome/common/url_constants.h" #include "googleurl/src/url_util.h" +#include "net/base/net_errors.h" #include "net/url_request/url_request_file_job.h" +#include "net/url_request/url_request_error_job.h" // Factory registered with URLRequest to create URLRequestJobs for extension:// // URLs. @@ -20,6 +24,16 @@ static URLRequestJob* CreateExtensionURLRequestJob(URLRequest* request, ChromeURLRequestContext* context = static_cast<ChromeURLRequestContext*>(request->context()); + // Don't allow toplevel navigations to extension resources in incognito mode. + // This is because an extension must run in a single process, and an incognito + // tab prevents that. + // TODO(mpcomplete): better error code. + const ResourceDispatcherHostRequestInfo* info = + ResourceDispatcherHost::InfoForRequest(request); + if (context->is_off_the_record() && + info && info->resource_type() == ResourceType::MAIN_FRAME) + return new URLRequestErrorJob(request, net::ERR_ADDRESS_UNREACHABLE); + // chrome-extension://extension-id/resource/path.js FilePath directory_path = context->GetPathForExtension(request->url().host()); if (directory_path.value().empty()) { |