| 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 <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 Loading... |
| 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 |
| OLD | NEW |