summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_protocols.cc
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-25 22:10:50 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-25 22:10:50 +0000
commitdb7331aecb1f0c01aecf4cd4627d08a8d5b08bc2 (patch)
tree5a33fc21cb1628462f9e365add27aeaf058d60fc /chrome/browser/extensions/extension_protocols.cc
parentf56abff188b90b7f2d67a094930d7d9407df507d (diff)
downloadchromium_src-db7331aecb1f0c01aecf4cd4627d08a8d5b08bc2.zip
chromium_src-db7331aecb1f0c01aecf4cd4627d08a8d5b08bc2.tar.gz
chromium_src-db7331aecb1f0c01aecf4cd4627d08a8d5b08bc2.tar.bz2
Allow users to enable extensions in incognito. Requires
--enable-experimental-extension-apis . The UI needs work. Tab and window events are hooked up so that they work with incognito tabs/windows when enabled. BUG=32365 BUG=36292 Review URL: http://codereview.chromium.org/657041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40057 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_protocols.cc')
-rw-r--r--chrome/browser/extensions/extension_protocols.cc14
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()) {