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

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: feedback + test failures 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
« no previous file with comments | « chrome/browser/extensions/extension_apitest.cc ('k') | chrome/browser/extensions/extension_tabs_apitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5df7f6a3a6837085933af07d70f8f2bda5d0bd14 100644
--- a/chrome/browser/extensions/extension_tab_helper.cc
+++ b/chrome/browser/extensions/extension_tab_helper.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/extension_action.h"
+#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_icon_set.h"
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/extensions/extension_resource.h"
@@ -27,6 +28,12 @@
using content::WebContents;
+namespace {
+
+const char kPermissionError[] = "permission_error";
+
+} // namespace
+
ExtensionTabHelper::ExtensionTabHelper(TabContentsWrapper* wrapper)
: content::WebContentsObserver(wrapper->web_contents()),
delegate_(NULL),
@@ -179,14 +186,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 = extension_misc::kAppNotificationsIncognitoError;
+
+ 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_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