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

Side by Side Diff: chrome/browser/extensions/page_action_controller.cc

Issue 10535155: Hook the activeTab permission up to the omnibox, page action, and context menu APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 24 matching lines...) Expand all
44 ExtensionService* service = GetExtensionService(); 45 ExtensionService* service = GetExtensionService();
45 if (!service) 46 if (!service)
46 return ACTION_NONE; 47 return ACTION_NONE;
47 48
48 const Extension* extension = service->extensions()->GetByID(extension_id); 49 const Extension* extension = service->extensions()->GetByID(extension_id);
49 CHECK(extension); 50 CHECK(extension);
50 ExtensionAction* page_action = extension->page_action(); 51 ExtensionAction* page_action = extension->page_action();
51 CHECK(page_action); 52 CHECK(page_action);
52 int tab_id = ExtensionTabUtil::GetTabId(tab_contents_->web_contents()); 53 int tab_id = ExtensionTabUtil::GetTabId(tab_contents_->web_contents());
53 54
55 tab_contents_->extension_tab_helper()->active_tab_permission_manager()->
56 GrantIfRequested(extension);
57
54 switch (mouse_button) { 58 switch (mouse_button) {
55 case 1: // left 59 case 1: // left
56 case 2: // middle 60 case 2: // middle
57 if (page_action->HasPopup(tab_id)) 61 if (page_action->HasPopup(tab_id))
58 return ACTION_SHOW_POPUP; 62 return ACTION_SHOW_POPUP;
59 63
60 GetExtensionService()->browser_event_router()->PageActionExecuted( 64 GetExtensionService()->browser_event_router()->PageActionExecuted(
61 tab_contents_->profile(), 65 tab_contents_->profile(),
62 extension->id(), 66 extension->id(),
63 page_action->id(), 67 page_action->id(),
64 tab_id, 68 tab_id,
65 tab_contents_->web_contents()->GetURL().spec(), 69 tab_contents_->web_contents()->GetURL().spec(),
66 mouse_button); 70 mouse_button);
67 return ACTION_NONE; 71 return ACTION_NONE;
68 72
69 case 3: // right 73 case 3: // right
70 return extension->ShowConfigureContextMenus() ? 74 return extension->ShowConfigureContextMenus() ?
71 ACTION_SHOW_CONTEXT_MENU : ACTION_NONE; 75 ACTION_SHOW_CONTEXT_MENU : ACTION_NONE;
72 } 76 }
73 77
74 return ACTION_NONE; 78 return ACTION_NONE;
75 } 79 }
76 80
77 ExtensionService* PageActionController::GetExtensionService() { 81 ExtensionService* PageActionController::GetExtensionService() {
78 return ExtensionSystem::Get(tab_contents_->profile())->extension_service(); 82 return ExtensionSystem::Get(tab_contents_->profile())->extension_service();
79 } 83 }
80 84
81 } // namespace extensions 85 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698