Chromium Code Reviews| Index: chrome/browser/extensions/api/extension_action/extension_action_api.cc |
| diff --git a/chrome/browser/extensions/api/extension_action/extension_action_api.cc b/chrome/browser/extensions/api/extension_action/extension_action_api.cc |
| index d24ca2272a9cff31f69c5edc4995bb91dd02d459..4c57cf7ad110049e3b2f5f30c502320191f755b6 100644 |
| --- a/chrome/browser/extensions/api/extension_action/extension_action_api.cc |
| +++ b/chrome/browser/extensions/api/extension_action/extension_action_api.cc |
| @@ -170,51 +170,6 @@ void ExtensionActionAPI::SetBrowserActionVisibility( |
| extension_id, visible)); |
| } |
| -ExtensionAction::ShowAction ExtensionActionAPI::ExecuteExtensionAction( |
|
Devlin
2016/03/16 13:21:16
Pretty much just moved to ExtensionActionRunner::R
|
| - const Extension* extension, |
| - Browser* browser, |
| - bool grant_active_tab_permissions) { |
| - content::WebContents* web_contents = |
| - browser->tab_strip_model()->GetActiveWebContents(); |
| - if (!web_contents) |
| - return ExtensionAction::ACTION_NONE; |
| - |
| - int tab_id = SessionTabHelper::IdForTab(web_contents); |
| - |
| - ExtensionActionRunner* action_runner = |
| - ExtensionActionRunner::GetForWebContents(web_contents); |
| - bool has_pending_scripts = false; |
| - if (action_runner && action_runner->WantsToRun(extension)) |
| - has_pending_scripts = true; |
| - |
| - // Grant active tab if appropriate. |
| - if (grant_active_tab_permissions) { |
| - TabHelper::FromWebContents(web_contents)->active_tab_permission_granter()-> |
| - GrantIfRequested(extension); |
| - } |
| - |
| - // If this was a request to run a script, it will have been run once active |
| - // tab was granted. Return without executing the action, since we should only |
| - // run pending scripts OR the extension action, not both. |
| - if (has_pending_scripts) |
| - return ExtensionAction::ACTION_NONE; |
| - |
| - ExtensionAction* extension_action = |
| - ExtensionActionManager::Get(browser_context_)->GetExtensionAction( |
| - *extension); |
| - |
| - // Anything that gets here should have a page or browser action. |
| - DCHECK(extension_action); |
| - if (!extension_action->GetIsVisible(tab_id)) |
| - return ExtensionAction::ACTION_NONE; |
| - |
| - if (extension_action->HasPopup(tab_id)) |
| - return ExtensionAction::ACTION_SHOW_POPUP; |
| - |
| - ExtensionActionExecuted(*extension_action, web_contents); |
| - return ExtensionAction::ACTION_NONE; |
| -} |
| - |
| bool ExtensionActionAPI::ShowExtensionActionPopup( |
| const Extension* extension, |
| Browser* browser, |
| @@ -246,22 +201,6 @@ bool ExtensionActionAPI::ShowExtensionActionPopup( |
| extension->id(), grant_active_tab_permissions); |
| } |
| -bool ExtensionActionAPI::PageActionWantsToRun( |
| - const Extension* extension, |
| - content::WebContents* web_contents) { |
| - ExtensionAction* page_action = |
| - ExtensionActionManager::Get(browser_context_)->GetPageAction(*extension); |
| - return page_action && |
| - page_action->GetIsVisible(SessionTabHelper::IdForTab(web_contents)); |
| -} |
| - |
| -bool ExtensionActionAPI::HasBeenBlocked(const Extension* extension, |
| - content::WebContents* web_contents) { |
| - ExtensionActionRunner* action_runner = |
| - ExtensionActionRunner::GetForWebContents(web_contents); |
| - return action_runner && action_runner->WantsToRun(extension); |
| -} |
| - |
| void ExtensionActionAPI::NotifyChange(ExtensionAction* extension_action, |
| content::WebContents* web_contents, |
| content::BrowserContext* context) { |
| @@ -274,6 +213,37 @@ void ExtensionActionAPI::NotifyChange(ExtensionAction* extension_action, |
| NotifyPageActionsChanged(web_contents); |
| } |
| +void ExtensionActionAPI::DispatchExtensionActionClicked( |
|
Devlin
2016/03/16 13:21:16
Copy-paste from ExtensionActionExecuted() below
|
| + const ExtensionAction& extension_action, |
| + WebContents* web_contents) { |
| + events::HistogramValue histogram_value = events::UNKNOWN; |
| + const char* event_name = NULL; |
| + switch (extension_action.action_type()) { |
| + case ActionInfo::TYPE_BROWSER: |
| + histogram_value = events::BROWSER_ACTION_ON_CLICKED; |
| + event_name = "browserAction.onClicked"; |
| + break; |
| + case ActionInfo::TYPE_PAGE: |
| + histogram_value = events::PAGE_ACTION_ON_CLICKED; |
| + event_name = "pageAction.onClicked"; |
| + break; |
| + case ActionInfo::TYPE_SYSTEM_INDICATOR: |
| + // The System Indicator handles its own clicks. |
| + NOTREACHED(); |
| + break; |
| + } |
| + |
| + if (event_name) { |
| + scoped_ptr<base::ListValue> args(new base::ListValue()); |
| + args->Append( |
| + ExtensionTabUtil::CreateTabObject(web_contents)->ToValue().release()); |
| + |
| + DispatchEventToExtension(web_contents->GetBrowserContext(), |
| + extension_action.extension_id(), histogram_value, |
| + event_name, std::move(args)); |
| + } |
| +} |
| + |
| void ExtensionActionAPI::ClearAllValuesForTab( |
| content::WebContents* web_contents) { |
| DCHECK(web_contents); |
| @@ -321,37 +291,6 @@ void ExtensionActionAPI::DispatchEventToExtension( |
| ->DispatchEventToExtension(extension_id, std::move(event)); |
| } |
| -void ExtensionActionAPI::ExtensionActionExecuted( |
| - const ExtensionAction& extension_action, |
| - WebContents* web_contents) { |
| - events::HistogramValue histogram_value = events::UNKNOWN; |
| - const char* event_name = NULL; |
| - switch (extension_action.action_type()) { |
| - case ActionInfo::TYPE_BROWSER: |
| - histogram_value = events::BROWSER_ACTION_ON_CLICKED; |
| - event_name = "browserAction.onClicked"; |
| - break; |
| - case ActionInfo::TYPE_PAGE: |
| - histogram_value = events::PAGE_ACTION_ON_CLICKED; |
| - event_name = "pageAction.onClicked"; |
| - break; |
| - case ActionInfo::TYPE_SYSTEM_INDICATOR: |
| - // The System Indicator handles its own clicks. |
| - NOTREACHED(); |
| - break; |
| - } |
| - |
| - if (event_name) { |
| - scoped_ptr<base::ListValue> args(new base::ListValue()); |
| - args->Append( |
| - ExtensionTabUtil::CreateTabObject(web_contents)->ToValue().release()); |
| - |
| - DispatchEventToExtension(web_contents->GetBrowserContext(), |
| - extension_action.extension_id(), histogram_value, |
| - event_name, std::move(args)); |
| - } |
| -} |
| - |
| void ExtensionActionAPI::NotifyPageActionsChanged( |
| content::WebContents* web_contents) { |
| Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |