| 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/page_action_controller.h" | 5 #include "chrome/browser/extensions/page_action_controller.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/browser_event_router.h" | 7 #include "chrome/browser/extensions/browser_event_router.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
| 10 #include "chrome/browser/extensions/tab_helper.h" | 10 #include "chrome/browser/extensions/tab_helper.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 ExtensionService* service = GetExtensionService(); | 47 ExtensionService* service = GetExtensionService(); |
| 48 if (!service) | 48 if (!service) |
| 49 return ACTION_NONE; | 49 return ACTION_NONE; |
| 50 | 50 |
| 51 const Extension* extension = service->extensions()->GetByID(extension_id); | 51 const Extension* extension = service->extensions()->GetByID(extension_id); |
| 52 CHECK(extension); | 52 CHECK(extension); |
| 53 ExtensionAction* page_action = extension->page_action(); | 53 ExtensionAction* page_action = extension->page_action(); |
| 54 CHECK(page_action); | 54 CHECK(page_action); |
| 55 int tab_id = ExtensionTabUtil::GetTabId(web_contents()); | 55 int tab_id = ExtensionTabUtil::GetTabId(web_contents()); |
| 56 | 56 |
| 57 TabContents* tab_contents = TabContents::FromWebContents(web_contents()); | 57 extensions::TabHelper::FromWebContents(web_contents())-> |
| 58 tab_contents->extension_tab_helper()->active_tab_permission_manager()-> | 58 active_tab_permission_manager()->GrantIfRequested(extension); |
| 59 GrantIfRequested(extension); | |
| 60 | 59 |
| 61 switch (mouse_button) { | 60 switch (mouse_button) { |
| 62 case 1: // left | 61 case 1: // left |
| 63 case 2: // middle | 62 case 2: // middle |
| 64 if (page_action->HasPopup(tab_id)) | 63 if (page_action->HasPopup(tab_id)) |
| 65 return ACTION_SHOW_POPUP; | 64 return ACTION_SHOW_POPUP; |
| 66 | 65 |
| 67 GetExtensionService()->browser_event_router()->PageActionExecuted( | 66 GetExtensionService()->browser_event_router()->PageActionExecuted( |
| 68 tab_contents->profile(), | 67 Profile::FromBrowserContext(web_contents()->GetBrowserContext()), |
| 69 *page_action, | 68 *page_action, |
| 70 tab_id, | 69 tab_id, |
| 71 web_contents()->GetURL().spec(), | 70 web_contents()->GetURL().spec(), |
| 72 mouse_button); | 71 mouse_button); |
| 73 return ACTION_NONE; | 72 return ACTION_NONE; |
| 74 | 73 |
| 75 case 3: // right | 74 case 3: // right |
| 76 return extension->ShowConfigureContextMenus() ? | 75 return extension->ShowConfigureContextMenus() ? |
| 77 ACTION_SHOW_CONTEXT_MENU : ACTION_NONE; | 76 ACTION_SHOW_CONTEXT_MENU : ACTION_NONE; |
| 78 } | 77 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 105 | 104 |
| 106 NotifyChange(); | 105 NotifyChange(); |
| 107 } | 106 } |
| 108 | 107 |
| 109 ExtensionService* PageActionController::GetExtensionService() const { | 108 ExtensionService* PageActionController::GetExtensionService() const { |
| 110 TabContents* tab_contents = TabContents::FromWebContents(web_contents()); | 109 TabContents* tab_contents = TabContents::FromWebContents(web_contents()); |
| 111 return ExtensionSystem::Get(tab_contents->profile())->extension_service(); | 110 return ExtensionSystem::Get(tab_contents->profile())->extension_service(); |
| 112 } | 111 } |
| 113 | 112 |
| 114 } // namespace extensions | 113 } // namespace extensions |
| OLD | NEW |