diff options
Diffstat (limited to 'chrome/browser/ui/views/toolbar/toolbar_view.cc')
-rw-r--r-- | chrome/browser/ui/views/toolbar/toolbar_view.cc | 64 |
1 files changed, 40 insertions, 24 deletions
diff --git a/chrome/browser/ui/views/toolbar/toolbar_view.cc b/chrome/browser/ui/views/toolbar/toolbar_view.cc index d057283c..a94a409 100644 --- a/chrome/browser/ui/views/toolbar/toolbar_view.cc +++ b/chrome/browser/ui/views/toolbar/toolbar_view.cc @@ -14,6 +14,7 @@ #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/command_updater.h" +#include "chrome/browser/extensions/extension_commands_global_registry.h" #include "chrome/browser/extensions/extension_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/themes/theme_properties.h" @@ -121,18 +122,15 @@ const char ToolbarView::kViewClassName[] = "ToolbarView"; // ToolbarView, public: ToolbarView::ToolbarView(Browser* browser) - : back_(nullptr), - forward_(nullptr), - reload_(nullptr), - home_(nullptr), - location_bar_(nullptr), - browser_actions_(nullptr), - app_menu_button_(nullptr), + : back_(NULL), + forward_(NULL), + reload_(NULL), + home_(NULL), + location_bar_(NULL), + browser_actions_(NULL), + app_menu_button_(NULL), browser_(browser), - badge_controller_(browser->profile(), this), - display_mode_(browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) - ? DISPLAYMODE_NORMAL - : DISPLAYMODE_LOCATION) { + badge_controller_(browser->profile(), this) { set_id(VIEW_ID_TOOLBAR); SetEventTargeter( @@ -144,6 +142,10 @@ ToolbarView::ToolbarView(Browser* browser) chrome::AddCommandObserver(browser_, IDC_HOME, this); chrome::AddCommandObserver(browser_, IDC_LOAD_NEW_TAB_PAGE, this); + display_mode_ = DISPLAYMODE_LOCATION; + if (browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)) + display_mode_ = DISPLAYMODE_NORMAL; + if (OutdatedUpgradeBubbleView::IsAvailable()) { registrar_.Add(this, chrome::NOTIFICATION_OUTDATED_INSTALL, content::NotificationService::AllSources()); @@ -163,16 +165,7 @@ ToolbarView::~ToolbarView() { } void ToolbarView::Init() { - location_bar_ = - new LocationBarView(browser_, browser_->profile(), - browser_->command_controller()->command_updater(), - this, !is_display_mode_normal()); - - if (!is_display_mode_normal()) { - AddChildView(location_bar_); - location_bar_->Init(); - return; - } + GetWidget()->AddObserver(this); back_ = new BackButton( browser_->profile(), this, @@ -196,6 +189,11 @@ void ToolbarView::Init() { forward_->set_id(VIEW_ID_FORWARD_BUTTON); forward_->Init(); + location_bar_ = new LocationBarView( + browser_, browser_->profile(), + browser_->command_controller()->command_updater(), this, + display_mode_ == DISPLAYMODE_LOCATION); + reload_ = new ReloadButton(browser_->profile(), browser_->command_controller()->command_updater()); reload_->set_triggerable_event_flags( @@ -276,6 +274,19 @@ void ToolbarView::Init() { } } +void ToolbarView::OnWidgetActivationChanged(views::Widget* widget, + bool active) { + extensions::ExtensionCommandsGlobalRegistry* registry = + extensions::ExtensionCommandsGlobalRegistry::Get(browser_->profile()); + if (active) { + registry->set_registry_for_active_window( + browser_actions_->extension_keybinding_registry()); + } else if (registry->registry_for_active_window() == + browser_actions_->extension_keybinding_registry()) { + registry->set_registry_for_active_window(nullptr); + } +} + void ToolbarView::Update(WebContents* tab) { if (location_bar_) location_bar_->Update(tab); @@ -329,6 +340,12 @@ void ToolbarView::OnBubbleCreatedForAnchor(views::View* anchor_view, } } +void ToolbarView::ExecuteExtensionCommand( + const extensions::Extension* extension, + const extensions::Command& command) { + browser_actions_->ExecuteExtensionCommand(extension, command); +} + int ToolbarView::GetMaxBrowserActionsWidth() const { // The browser actions container is allowed to grow, but only up until the // omnibox reaches its minimum size. So its maximum allowed width is its @@ -483,7 +500,7 @@ gfx::Size ToolbarView::GetMinimumSize() const { void ToolbarView::Layout() { // If we have not been initialized yet just do nothing. - if (!location_bar_) + if (back_ == NULL) return; if (!is_display_mode_normal()) { @@ -592,8 +609,7 @@ void ToolbarView::Layout() { } void ToolbarView::OnThemeChanged() { - if (is_display_mode_normal()) - LoadImages(); + LoadImages(); } const char* ToolbarView::GetClassName() const { |