Chromium Code Reviews| 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; |
| } |