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

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

Issue 496863003: Consolidate ExtensionAction execution code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 <set> 7 #include <set>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 22 matching lines...) Expand all
33 } 33 }
34 34
35 PageActionController::~PageActionController() { 35 PageActionController::~PageActionController() {
36 } 36 }
37 37
38 ExtensionAction* PageActionController::GetActionForExtension( 38 ExtensionAction* PageActionController::GetActionForExtension(
39 const Extension* extension) { 39 const Extension* extension) {
40 return ExtensionActionManager::Get(GetProfile())->GetPageAction(*extension); 40 return ExtensionActionManager::Get(GetProfile())->GetPageAction(*extension);
41 } 41 }
42 42
43 ExtensionAction::ShowAction PageActionController::OnClicked(
44 const Extension* extension) {
45 ExtensionAction* page_action =
46 ExtensionActionManager::Get(GetProfile())->GetPageAction(*extension);
47 CHECK(page_action);
48
49 int tab_id = SessionTabHelper::IdForTab(web_contents_);
50 TabHelper::FromWebContents(web_contents_)->
51 active_tab_permission_granter()->GrantIfRequested(extension);
52
53 if (page_action->HasPopup(tab_id))
54 return ExtensionAction::ACTION_SHOW_POPUP;
55
56 ExtensionActionAPI::PageActionExecuted(
57 web_contents_->GetBrowserContext(),
58 *page_action,
59 tab_id,
60 web_contents_->GetLastCommittedURL().spec(),
61 1 /* Button indication. We only ever pass left-click. */);
62
63 return ExtensionAction::ACTION_NONE;
64 }
65
66 void PageActionController::OnNavigated() { 43 void PageActionController::OnNavigated() {
67 // Clearing extension action values is handled in TabHelper, so nothing to 44 // Clearing extension action values is handled in TabHelper, so nothing to
68 // do here. 45 // do here.
69 } 46 }
70 47
71 void PageActionController::OnExtensionActionUpdated( 48 void PageActionController::OnExtensionActionUpdated(
72 ExtensionAction* extension_action, 49 ExtensionAction* extension_action,
73 content::WebContents* web_contents, 50 content::WebContents* web_contents,
74 content::BrowserContext* browser_context) { 51 content::BrowserContext* browser_context) {
75 if (web_contents == web_contents_ && 52 if (web_contents == web_contents_ &&
76 extension_action->action_type() == ActionInfo::TYPE_PAGE) 53 extension_action->action_type() == ActionInfo::TYPE_PAGE)
77 LocationBarController::NotifyChange(web_contents_); 54 LocationBarController::NotifyChange(web_contents_);
78 } 55 }
79 56
80 Profile* PageActionController::GetProfile() { 57 Profile* PageActionController::GetProfile() {
81 return Profile::FromBrowserContext(web_contents_->GetBrowserContext()); 58 return Profile::FromBrowserContext(web_contents_->GetBrowserContext());
82 } 59 }
83 60
84 } // namespace extensions 61 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/page_action_controller.h ('k') | chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698