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

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

Issue 9737001: Fix crash in AppNotifyChannelSetup when incognito profiles are used. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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
Index: chrome/browser/extensions/extension_tab_helper.cc
diff --git a/chrome/browser/extensions/extension_tab_helper.cc b/chrome/browser/extensions/extension_tab_helper.cc
index c43495bf24d91d8b01a50ad98a23c3bb7152ec8c..9d6bd4a4e20091a409f21ed0ac8577e599b279d8 100644
--- a/chrome/browser/extensions/extension_tab_helper.cc
+++ b/chrome/browser/extensions/extension_tab_helper.cc
@@ -27,6 +27,15 @@
using content::WebContents;
+namespace {
+
+const char kPermissionError[] = "permission_error";
+const char kIncognitoError[] =
jstritar 2012/03/22 20:21:10 Not sure where I should extract the two copies of
asargent_no_longer_on_chrome 2012/03/22 20:58:11 Sure, putting it in extension_constants.h seems fi
jstritar 2012/03/23 15:31:43 Done.
+ "This API is not accessible by 'split' mode "
+ "extensions in incognito windows.";
+
+} // namespace
+
ExtensionTabHelper::ExtensionTabHelper(TabContentsWrapper* wrapper)
: content::WebContentsObserver(wrapper->web_contents()),
delegate_(NULL),
@@ -179,14 +188,23 @@ void ExtensionTabHelper::OnGetAppNotifyChannel(
tab_contents_wrapper()->web_contents()->GetRenderProcessHost();
const Extension* extension =
extension_service->GetInstalledApp(requestor_url);
- bool allowed =
- extension &&
- extension->HasAPIPermission(
- ExtensionAPIPermission::kAppNotifications) &&
- process_map->Contains(extension->id(), process->GetID());
- if (!allowed) {
+
+ std::string error;
+ if (!extension ||
+ !extension->HasAPIPermission(
+ ExtensionAPIPermission::kAppNotifications) ||
+ !process_map->Contains(extension->id(), process->GetID()))
+ error = kPermissionError;
+
+ // Make sure the extension can cross to the main profile, if called from an
+ // an incognito window.
+ if (profile->IsOffTheRecord() &&
+ !extension_service->CanCrossIncognito(extension))
+ error = kIncognitoError;
+
+ if (!error.empty()) {
Send(new ExtensionMsg_GetAppNotifyChannelResponse(
- return_route_id, "", "permission_error", callback_id));
+ return_route_id, "", error, callback_id));
return;
}
« no previous file with comments | « chrome/browser/extensions/extension_local_filesystem_apitest.cc ('k') | chrome/browser/extensions/extension_tabs_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698