Commit 15324d56 authored by Devlin Cronin's avatar Devlin Cronin Committed by Commit Bot

[Extensions] ShowExtensionActionPopup -> ShowExtensionActionPopupForAPICall

Rename ShowToolbarActionPopup() and ShowExtensionActionPopup() to
ShowToolbarActionPopupForAPICall() and
ShowExtensionActionPopupForAPICall(). These methods were only used when
displaying a popup in response to an API call (outside of tests), and
this name makes it more obvious.

Additionally, this lets us get rid of the additional "grant_active_tab"
bool, which was always (outside of tests) set to false.

Bug: None
Change-Id: I02b4c489586f6cbec3ac99b02ce15413f2ceff40
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2145858Reviewed-by: default avatarCaroline Rising <corising@chromium.org>
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758549}
parent 4329568d
......@@ -112,10 +112,9 @@ void ExtensionActionAPI::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer);
}
bool ExtensionActionAPI::ShowExtensionActionPopup(
bool ExtensionActionAPI::ShowExtensionActionPopupForAPICall(
const Extension* extension,
Browser* browser,
bool grant_active_tab_permissions) {
Browser* browser) {
ExtensionAction* extension_action =
ExtensionActionManager::Get(browser_context_)->GetExtensionAction(
*extension);
......@@ -131,8 +130,8 @@ bool ExtensionActionAPI::ShowExtensionActionPopup(
// The ExtensionsContainer could be null if, e.g., this is a popup window with
// no toolbar.
return extensions_container &&
extensions_container->ShowToolbarActionPopup(
extension->id(), grant_active_tab_permissions);
extensions_container->ShowToolbarActionPopupForAPICall(
extension->id());
}
void ExtensionActionAPI::NotifyChange(ExtensionAction* extension_action,
......@@ -530,8 +529,8 @@ ExtensionFunction::ResponseAction BrowserActionOpenPopupFunction::Run() {
// fixed.
if (!browser || !browser->window()->IsActive() ||
!browser->window()->IsToolbarVisible() ||
!ExtensionActionAPI::Get(profile)->ShowExtensionActionPopup(
extension_.get(), browser, false)) {
!ExtensionActionAPI::Get(profile)->ShowExtensionActionPopupForAPICall(
extension_.get(), browser)) {
return RespondNow(Error(kOpenPopupError));
}
......
......@@ -68,12 +68,8 @@ class ExtensionActionAPI : public BrowserContextKeyedAPI {
void RemoveObserver(Observer* observer);
// Opens the popup for the given |extension| in the given |browser|'s window.
// If |grant_active_tab_permissions| is true, this grants the extension
// activeTab (so this should only be done if this is through a direct user
// action).
bool ShowExtensionActionPopup(const Extension* extension,
Browser* browser,
bool grant_active_tab_permissions);
bool ShowExtensionActionPopupForAPICall(const Extension* extension,
Browser* browser);
// Notifies that there has been a change in the given |extension_action|.
void NotifyChange(ExtensionAction* extension_action,
......
......@@ -181,8 +181,8 @@ IN_PROC_BROWSER_TEST_F(PageActionApiTest, DISABLED_ShowPageActionPopup) {
{
ResultCatcher catcher;
ExtensionActionAPI::Get(browser()->profile())->ShowExtensionActionPopup(
extension, browser(), true);
ExtensionActionAPI::Get(browser()->profile())
->ShowExtensionActionPopupForAPICall(extension, browser());
ASSERT_TRUE(catcher.GetNextResult());
}
}
......
......@@ -63,11 +63,10 @@ class ExtensionsContainer {
bool is_sticky,
const base::Closure& closure) = 0;
// Shows the popup for the action with |id|, returning true if a popup is
// shown. If |grant_active_tab| is true, then active tab permissions should
// be given to the action (only do this if this is through a user action).
virtual bool ShowToolbarActionPopup(const std::string& action_id,
bool grant_active_tab) = 0;
// Shows the popup for the action with |id| as the result of an API call,
// returning true if a popup is shown.
virtual bool ShowToolbarActionPopupForAPICall(
const std::string& action_id) = 0;
// Displays the given |bubble| once the toolbar is no longer animating.
virtual void ShowToolbarActionBubble(
......
......@@ -383,14 +383,17 @@ void ToolbarActionsBar::Update() {
ReorderActions(); // Also triggers a draw.
}
bool ToolbarActionsBar::ShowToolbarActionPopup(const std::string& action_id,
bool grant_active_tab) {
bool ToolbarActionsBar::ShowToolbarActionPopupForAPICall(
const std::string& action_id) {
// Don't override another popup, and only show in the active window.
if (popup_owner() || !browser_->window()->IsActive())
return false;
ToolbarActionViewController* action = GetActionForId(action_id);
return action && action->ExecuteAction(grant_active_tab);
// Since this was triggered by an API call, we never want to grant activeTab
// to the extension.
constexpr bool kGrantActiveTab = false;
return action && action->ExecuteAction(kGrantActiveTab);
}
void ToolbarActionsBar::SetOverflowRowWidth(int width) {
......
......@@ -243,8 +243,7 @@ class ToolbarActionsBar : public ExtensionsContainer,
void PopOutAction(ToolbarActionViewController* action,
bool is_sticky,
const base::Closure& closure) override;
bool ShowToolbarActionPopup(const std::string& id,
bool grant_active_tab) override;
bool ShowToolbarActionPopupForAPICall(const std::string& id) override;
void ShowToolbarActionBubble(
std::unique_ptr<ToolbarActionsBarBubbleDelegate> bubble) override;
void ShowToolbarActionBubbleAsync(
......
......@@ -325,15 +325,17 @@ void ExtensionsToolbarContainer::PopOutAction(
animating_layout_manager()->PostOrQueueAction(closure);
}
bool ExtensionsToolbarContainer::ShowToolbarActionPopup(
const std::string& action_id,
bool grant_active_tab) {
bool ExtensionsToolbarContainer::ShowToolbarActionPopupForAPICall(
const std::string& action_id) {
// Don't override another popup, and only show in the active window.
if (popped_out_action_ || !browser_->window()->IsActive())
return false;
ToolbarActionViewController* action = GetActionForId(action_id);
return action && action->ExecuteAction(grant_active_tab);
// Since this was triggered by an API call, we never want to grant activeTab
// to the extension.
constexpr bool kGrantActiveTab = false;
return action && action->ExecuteAction(kGrantActiveTab);
}
void ExtensionsToolbarContainer::ShowToolbarActionBubble(
......
......@@ -111,8 +111,7 @@ class ExtensionsToolbarContainer : public ToolbarIconContainerView,
void PopOutAction(ToolbarActionViewController* action,
bool is_sticky,
const base::Closure& closure) override;
bool ShowToolbarActionPopup(const std::string& action_id,
bool grant_active_tab) override;
bool ShowToolbarActionPopupForAPICall(const std::string& action_id) override;
void ShowToolbarActionBubble(
std::unique_ptr<ToolbarActionsBarBubbleDelegate> bubble) override;
void ShowToolbarActionBubbleAsync(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment