| Index: chrome/browser/ui/views/toolbar/toolbar_view.cc
|
| diff --git a/chrome/browser/ui/views/toolbar/toolbar_view.cc b/chrome/browser/ui/views/toolbar/toolbar_view.cc
|
| index a94a409cdd249c94800faa69864940787929f163..d057283c81ffb2cfcc330004b05a0b88923ba366 100644
|
| --- a/chrome/browser/ui/views/toolbar/toolbar_view.cc
|
| +++ b/chrome/browser/ui/views/toolbar/toolbar_view.cc
|
| @@ -14,7 +14,6 @@
|
| #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"
|
| @@ -122,15 +121,18 @@ const char ToolbarView::kViewClassName[] = "ToolbarView";
|
| // ToolbarView, public:
|
|
|
| ToolbarView::ToolbarView(Browser* browser)
|
| - : back_(NULL),
|
| - forward_(NULL),
|
| - reload_(NULL),
|
| - home_(NULL),
|
| - location_bar_(NULL),
|
| - browser_actions_(NULL),
|
| - app_menu_button_(NULL),
|
| + : back_(nullptr),
|
| + forward_(nullptr),
|
| + reload_(nullptr),
|
| + home_(nullptr),
|
| + location_bar_(nullptr),
|
| + browser_actions_(nullptr),
|
| + app_menu_button_(nullptr),
|
| browser_(browser),
|
| - badge_controller_(browser->profile(), this) {
|
| + badge_controller_(browser->profile(), this),
|
| + display_mode_(browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)
|
| + ? DISPLAYMODE_NORMAL
|
| + : DISPLAYMODE_LOCATION) {
|
| set_id(VIEW_ID_TOOLBAR);
|
|
|
| SetEventTargeter(
|
| @@ -142,10 +144,6 @@ 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());
|
| @@ -165,7 +163,16 @@ ToolbarView::~ToolbarView() {
|
| }
|
|
|
| void ToolbarView::Init() {
|
| - GetWidget()->AddObserver(this);
|
| + 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;
|
| + }
|
|
|
| back_ = new BackButton(
|
| browser_->profile(), this,
|
| @@ -189,11 +196,6 @@ 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(
|
| @@ -274,19 +276,6 @@ 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);
|
| @@ -340,12 +329,6 @@ 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
|
| @@ -500,7 +483,7 @@ gfx::Size ToolbarView::GetMinimumSize() const {
|
|
|
| void ToolbarView::Layout() {
|
| // If we have not been initialized yet just do nothing.
|
| - if (back_ == NULL)
|
| + if (!location_bar_)
|
| return;
|
|
|
| if (!is_display_mode_normal()) {
|
| @@ -609,7 +592,8 @@ void ToolbarView::Layout() {
|
| }
|
|
|
| void ToolbarView::OnThemeChanged() {
|
| - LoadImages();
|
| + if (is_display_mode_normal())
|
| + LoadImages();
|
| }
|
|
|
| const char* ToolbarView::GetClassName() const {
|
|
|