Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Unified Diff: chrome/browser/extensions/extension_function_dispatcher.cc

Issue 3210007: Add support for a "split" incognito behavior for extensions. (Closed)
Patch Set: latest Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_function.h ('k') | chrome/browser/extensions/extension_history_api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_function_dispatcher.cc
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index 51cc8feb1eb8fa5a30fb835bd99f49be462ba2eb..6224fe1d91f9b35f005af931ae967984e46632b3 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -383,7 +383,7 @@ ExtensionFunctionDispatcher::ExtensionFunctionDispatcher(
render_view_host->Send(new ViewMsg_Extension_SetHostPermissions(
extension->url(), extension->host_permissions()));
render_view_host->Send(new ViewMsg_Extension_ExtensionSetIncognitoEnabled(
- extension->id(), incognito_enabled));
+ extension->id(), incognito_enabled, extension->incognito_split_mode()));
NotificationService::current()->Notify(
NotificationType::EXTENSION_FUNCTION_DISPATCHER_CREATED,
@@ -404,20 +404,16 @@ Browser* ExtensionFunctionDispatcher::GetCurrentBrowser(
bool include_incognito) {
Browser* browser = delegate_->GetBrowser();
- // If the delegate has an associated browser and that browser is in the right
- // incognito state, we can return it.
- if (browser) {
- if (include_incognito || !browser->profile()->IsOffTheRecord())
- return browser;
- }
+ // If the delegate has an associated browser, that is always the right answer.
+ if (browser)
+ return browser;
- // Otherwise, try to default to a reasonable browser.
+ // Otherwise, try to default to a reasonable browser. If |include_incognito|
+ // is true, we will also search browsers in the incognito version of this
+ // profile. Note that the profile may already be incognito, in which case
+ // we will search the incognito version only, regardless of the value of
+ // |include_incognito|.
Profile* profile = render_view_host()->process()->profile();
-
- // Make sure we don't return an incognito browser without proper access.
- if (!include_incognito)
- profile = profile->GetOriginalProfile();
-
browser = BrowserList::FindBrowserWithType(profile, Browser::TYPE_NORMAL,
include_incognito);
@@ -446,7 +442,8 @@ void ExtensionFunctionDispatcher::HandleRequest(
DCHECK(service);
Extension* extension = service->GetExtensionById(extension_id(), false);
DCHECK(extension);
- function->set_include_incognito(service->IsIncognitoEnabled(extension));
+ function->set_include_incognito(service->IsIncognitoEnabled(extension) &&
+ !extension->incognito_split_mode());
ExtensionsQuotaService* quota = service->quota_service();
if (quota->Assess(extension_id(), function, &params.arguments,
« no previous file with comments | « chrome/browser/extensions/extension_function.h ('k') | chrome/browser/extensions/extension_history_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698