| 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/extension_browser_event_router.h" | 7 #include "chrome/browser/extensions/extension_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/extension_tab_helper.h" |
| 10 #include "chrome/browser/extensions/extension_tab_util.h" | 11 #include "chrome/browser/extensions/extension_tab_util.h" |
| 11 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 12 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 12 #include "chrome/common/extensions/extension_set.h" | 13 #include "chrome/common/extensions/extension_set.h" |
| 13 #include "chrome/common/chrome_notification_types.h" | 14 #include "chrome/common/chrome_notification_types.h" |
| 14 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
| 15 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 16 | 17 |
| 17 namespace extensions { | 18 namespace extensions { |
| 18 | 19 |
| 19 PageActionController::PageActionController(TabContents* tab_contents) | 20 PageActionController::PageActionController(TabContents* tab_contents) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 42 ExtensionService* service = GetExtensionService(); | 43 ExtensionService* service = GetExtensionService(); |
| 43 if (!service) | 44 if (!service) |
| 44 return ACTION_NONE; | 45 return ACTION_NONE; |
| 45 | 46 |
| 46 const Extension* extension = service->extensions()->GetByID(extension_id); | 47 const Extension* extension = service->extensions()->GetByID(extension_id); |
| 47 CHECK(extension); | 48 CHECK(extension); |
| 48 ExtensionAction* page_action = extension->page_action(); | 49 ExtensionAction* page_action = extension->page_action(); |
| 49 CHECK(page_action); | 50 CHECK(page_action); |
| 50 int tab_id = ExtensionTabUtil::GetTabId(tab_contents_->web_contents()); | 51 int tab_id = ExtensionTabUtil::GetTabId(tab_contents_->web_contents()); |
| 51 | 52 |
| 53 tab_contents_->extension_tab_helper()->active_tab_permission_manager()-> |
| 54 GrantIfRequested(extension); |
| 55 |
| 52 switch (mouse_button) { | 56 switch (mouse_button) { |
| 53 case 1: // left | 57 case 1: // left |
| 54 case 2: // middle | 58 case 2: // middle |
| 55 if (page_action->HasPopup(tab_id)) | 59 if (page_action->HasPopup(tab_id)) |
| 56 return ACTION_SHOW_POPUP; | 60 return ACTION_SHOW_POPUP; |
| 57 | 61 |
| 58 GetExtensionService()->browser_event_router()->PageActionExecuted( | 62 GetExtensionService()->browser_event_router()->PageActionExecuted( |
| 59 tab_contents_->profile(), | 63 tab_contents_->profile(), |
| 60 extension->id(), | 64 extension->id(), |
| 61 page_action->id(), | 65 page_action->id(), |
| 62 tab_id, | 66 tab_id, |
| 63 tab_contents_->web_contents()->GetURL().spec(), | 67 tab_contents_->web_contents()->GetURL().spec(), |
| 64 mouse_button); | 68 mouse_button); |
| 65 return ACTION_NONE; | 69 return ACTION_NONE; |
| 66 | 70 |
| 67 case 3: // right | 71 case 3: // right |
| 68 return extension->ShowConfigureContextMenus() ? | 72 return extension->ShowConfigureContextMenus() ? |
| 69 ACTION_SHOW_CONTEXT_MENU : ACTION_NONE; | 73 ACTION_SHOW_CONTEXT_MENU : ACTION_NONE; |
| 70 } | 74 } |
| 71 | 75 |
| 72 return ACTION_NONE; | 76 return ACTION_NONE; |
| 73 } | 77 } |
| 74 | 78 |
| 75 ExtensionService* PageActionController::GetExtensionService() { | 79 ExtensionService* PageActionController::GetExtensionService() { |
| 76 return ExtensionSystem::Get(tab_contents_->profile())->extension_service(); | 80 return ExtensionSystem::Get(tab_contents_->profile())->extension_service(); |
| 77 } | 81 } |
| 78 | 82 |
| 79 } // namespace extensions | 83 } // namespace extensions |
| OLD | NEW |