Commit ffa3032c authored by Peter Boström's avatar Peter Boström Committed by Commit Bot

Show installation bubble from extensions menu

Makes sure that the installation bubble can show when the
extensions-menu experiment is enabled. This code will likely need to be
changed to pop out the installed extension. With this fix it will at
least show the extension-installed dialog.

Bug: chromium:987312
Change-Id: Ib46bffe3022407fb1cbc96596d055e46c7c4750c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1715469Reviewed-by: default avatarCaroline Rising <corising@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680592}
parent efd38a8e
...@@ -23,7 +23,10 @@ ...@@ -23,7 +23,10 @@
#include "chrome/browser/ui/extensions/extension_installed_bubble.h" #include "chrome/browser/ui/extensions/extension_installed_bubble.h"
#include "chrome/browser/ui/singleton_tabs.h" #include "chrome/browser/ui/singleton_tabs.h"
#include "chrome/browser/ui/sync/bubble_sync_promo_delegate.h" #include "chrome/browser/ui/sync/bubble_sync_promo_delegate.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h" #include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/extensions/extensions_toolbar_button.h"
#include "chrome/browser/ui/views/extensions/extensions_toolbar_container.h"
#include "chrome/browser/ui/views/frame/app_menu_button.h" #include "chrome/browser/ui/views/frame/app_menu_button.h"
#include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h" #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
...@@ -74,13 +77,23 @@ views::View* AnchorViewForBrowser(ExtensionInstalledBubble* controller, ...@@ -74,13 +77,23 @@ views::View* AnchorViewForBrowser(ExtensionInstalledBubble* controller,
switch (controller->anchor_position()) { switch (controller->anchor_position()) {
case ExtensionInstalledBubble::ANCHOR_ACTION: { case ExtensionInstalledBubble::ANCHOR_ACTION: {
BrowserActionsContainer* container = if (base::FeatureList::IsEnabled(features::kExtensionsToolbarMenu)) {
browser_view->toolbar()->browser_actions(); // TODO(pbos): Make sure this view pops out so that we can actually
// Hitting this DCHECK means |ShouldShow| failed. // anchor to a visible action. Right now this view is most likely not
DCHECK(container); // visible, and will fall back on the default case on showing the
DCHECK(!container->animating()); // installed dialog anchored to the general extensions toolbar button.
reference_view =
reference_view = container->GetViewForId(controller->extension()->id()); browser_view->toolbar()->extensions_container()->GetViewForId(
controller->extension()->id());
} else {
BrowserActionsContainer* container =
browser_view->toolbar()->browser_actions();
// Hitting this DCHECK means |ShouldShow| failed.
DCHECK(container);
DCHECK(!container->animating());
reference_view = container->GetViewForId(controller->extension()->id());
}
break; break;
} }
case ExtensionInstalledBubble::ANCHOR_OMNIBOX: { case ExtensionInstalledBubble::ANCHOR_OMNIBOX: {
...@@ -93,8 +106,14 @@ views::View* AnchorViewForBrowser(ExtensionInstalledBubble* controller, ...@@ -93,8 +106,14 @@ views::View* AnchorViewForBrowser(ExtensionInstalledBubble* controller,
} }
// Default case. // Default case.
if (!reference_view || !reference_view->GetVisible()) if (!reference_view || !reference_view->GetVisible()) {
if (base::FeatureList::IsEnabled(features::kExtensionsToolbarMenu)) {
return browser_view->toolbar()
->extensions_container()
->extensions_button();
}
return browser_view->toolbar_button_provider()->GetAppMenuButton(); return browser_view->toolbar_button_provider()->GetAppMenuButton();
}
return reference_view; return reference_view;
} }
...@@ -369,6 +388,8 @@ void ExtensionInstalledBubbleUi::OnWidgetClosing(views::Widget* widget) { ...@@ -369,6 +388,8 @@ void ExtensionInstalledBubbleUi::OnWidgetClosing(views::Widget* widget) {
// Views (BrowserView) specific implementation. // Views (BrowserView) specific implementation.
bool ExtensionInstalledBubble::ShouldShow() { bool ExtensionInstalledBubble::ShouldShow() {
if (base::FeatureList::IsEnabled(features::kExtensionsToolbarMenu))
return true;
if (anchor_position() == ANCHOR_ACTION) { if (anchor_position() == ANCHOR_ACTION) {
BrowserActionsContainer* container = BrowserActionsContainer* container =
BrowserView::GetBrowserViewForBrowser(browser()) BrowserView::GetBrowserViewForBrowser(browser())
......
...@@ -38,6 +38,14 @@ void ExtensionsToolbarContainer::UpdateAllIcons() { ...@@ -38,6 +38,14 @@ void ExtensionsToolbarContainer::UpdateAllIcons() {
action->UpdateState(); action->UpdateState();
} }
ToolbarActionView* ExtensionsToolbarContainer::GetViewForId(
const std::string& id) {
auto it = icons_.find(id);
if (it == icons_.end())
return nullptr;
return it->second.get();
}
ToolbarActionViewController* ExtensionsToolbarContainer::GetActionForId( ToolbarActionViewController* ExtensionsToolbarContainer::GetActionForId(
const std::string& action_id) { const std::string& action_id) {
for (const auto& action : actions_) { for (const auto& action : actions_) {
......
...@@ -48,6 +48,8 @@ class ExtensionsToolbarContainer : public ToolbarIconContainerView, ...@@ -48,6 +48,8 @@ class ExtensionsToolbarContainer : public ToolbarIconContainerView,
// ToolbarIconContainerView: // ToolbarIconContainerView:
void UpdateAllIcons() override; void UpdateAllIcons() override;
ToolbarActionView* GetViewForId(const std::string& id);
private: private:
// Creates toolbar actions and icons corresponding to the model. This is only // Creates toolbar actions and icons corresponding to the model. This is only
// called in the constructor or when the model initializes and should not be // called in the constructor or when the model initializes and should not be
......
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