OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/extension_tab_helper.h" | 5 #include "chrome/browser/extensions/extension_tab_helper.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
8 #include "chrome/browser/extensions/page_action_controller.h" | 8 #include "chrome/browser/extensions/page_action_controller.h" |
9 #include "chrome/browser/extensions/script_badge_controller.h" | 9 #include "chrome/browser/extensions/script_badge_controller.h" |
10 #include "chrome/browser/extensions/script_executor_impl.h" | 10 #include "chrome/browser/extensions/script_executor_impl.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "content/public/browser/navigation_details.h" | 25 #include "content/public/browser/navigation_details.h" |
26 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
27 #include "content/public/browser/render_process_host.h" | 27 #include "content/public/browser/render_process_host.h" |
28 #include "content/public/browser/render_view_host.h" | 28 #include "content/public/browser/render_view_host.h" |
29 #include "content/public/browser/render_widget_host_view.h" | 29 #include "content/public/browser/render_widget_host_view.h" |
30 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
31 #include "ui/gfx/image/image.h" | 31 #include "ui/gfx/image/image.h" |
32 | 32 |
33 using content::RenderViewHost; | 33 using content::RenderViewHost; |
34 using content::WebContents; | 34 using content::WebContents; |
| 35 using extensions::APIPermission; |
35 using extensions::Extension; | 36 using extensions::Extension; |
36 using extensions::PageActionController; | 37 using extensions::PageActionController; |
37 using extensions::ScriptBadgeController; | 38 using extensions::ScriptBadgeController; |
38 using extensions::ScriptExecutorImpl; | 39 using extensions::ScriptExecutorImpl; |
39 | 40 |
40 namespace { | 41 namespace { |
41 | 42 |
42 const char kPermissionError[] = "permission_error"; | 43 const char kPermissionError[] = "permission_error"; |
43 | 44 |
44 } // namespace | 45 } // namespace |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 ExtensionService* extension_service = profile->GetExtensionService(); | 229 ExtensionService* extension_service = profile->GetExtensionService(); |
229 extensions::ProcessMap* process_map = extension_service->process_map(); | 230 extensions::ProcessMap* process_map = extension_service->process_map(); |
230 content::RenderProcessHost* process = | 231 content::RenderProcessHost* process = |
231 tab_contents()->web_contents()->GetRenderProcessHost(); | 232 tab_contents()->web_contents()->GetRenderProcessHost(); |
232 const Extension* extension = | 233 const Extension* extension = |
233 extension_service->GetInstalledApp(requestor_url); | 234 extension_service->GetInstalledApp(requestor_url); |
234 | 235 |
235 std::string error; | 236 std::string error; |
236 if (!extension || | 237 if (!extension || |
237 !extension->HasAPIPermission( | 238 !extension->HasAPIPermission( |
238 ExtensionAPIPermission::kAppNotifications) || | 239 APIPermission::kAppNotifications) || |
239 !process_map->Contains(extension->id(), process->GetID())) | 240 !process_map->Contains(extension->id(), process->GetID())) |
240 error = kPermissionError; | 241 error = kPermissionError; |
241 | 242 |
242 // Make sure the extension can cross to the main profile, if called from an | 243 // Make sure the extension can cross to the main profile, if called from an |
243 // an incognito window. | 244 // an incognito window. |
244 if (profile->IsOffTheRecord() && | 245 if (profile->IsOffTheRecord() && |
245 !extension_service->CanCrossIncognito(extension)) | 246 !extension_service->CanCrossIncognito(extension)) |
246 error = extension_misc::kAppNotificationsIncognitoError; | 247 error = extension_misc::kAppNotificationsIncognitoError; |
247 | 248 |
248 if (!error.empty()) { | 249 if (!error.empty()) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 void ExtensionTabHelper::OnInlineInstallFailure(int install_id, | 385 void ExtensionTabHelper::OnInlineInstallFailure(int install_id, |
385 int return_route_id, | 386 int return_route_id, |
386 const std::string& error) { | 387 const std::string& error) { |
387 Send(new ExtensionMsg_InlineWebstoreInstallResponse( | 388 Send(new ExtensionMsg_InlineWebstoreInstallResponse( |
388 return_route_id, install_id, false, error)); | 389 return_route_id, install_id, false, error)); |
389 } | 390 } |
390 | 391 |
391 WebContents* ExtensionTabHelper::GetAssociatedWebContents() const { | 392 WebContents* ExtensionTabHelper::GetAssociatedWebContents() const { |
392 return web_contents(); | 393 return web_contents(); |
393 } | 394 } |
OLD | NEW |