| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/toolbar_view.h" | 5 #include "chrome/browser/ui/views/toolbar_view.h" |
| 6 | 6 |
| 7 #include "base/i18n/number_formatting.h" | 7 #include "base/i18n/number_formatting.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // NOTE: Don't remove the command observers here. This object gets destroyed | 126 // NOTE: Don't remove the command observers here. This object gets destroyed |
| 127 // after the Browser (which owns the CommandUpdater), so the CommandUpdater is | 127 // after the Browser (which owns the CommandUpdater), so the CommandUpdater is |
| 128 // already gone. | 128 // already gone. |
| 129 } | 129 } |
| 130 | 130 |
| 131 void ToolbarView::Init() { | 131 void ToolbarView::Init() { |
| 132 back_menu_model_.reset(new BackForwardMenuModel( | 132 back_menu_model_.reset(new BackForwardMenuModel( |
| 133 browser_, BackForwardMenuModel::BACKWARD_MENU)); | 133 browser_, BackForwardMenuModel::BACKWARD_MENU)); |
| 134 forward_menu_model_.reset(new BackForwardMenuModel( | 134 forward_menu_model_.reset(new BackForwardMenuModel( |
| 135 browser_, BackForwardMenuModel::FORWARD_MENU)); | 135 browser_, BackForwardMenuModel::FORWARD_MENU)); |
| 136 wrench_menu_model_.reset(new WrenchMenuModel(this, browser_)); | |
| 137 back_ = new views::ButtonDropDown(this, back_menu_model_.get()); | 136 back_ = new views::ButtonDropDown(this, back_menu_model_.get()); |
| 138 back_->set_triggerable_event_flags(ui::EF_LEFT_BUTTON_DOWN | | 137 back_->set_triggerable_event_flags(ui::EF_LEFT_BUTTON_DOWN | |
| 139 ui::EF_MIDDLE_BUTTON_DOWN); | 138 ui::EF_MIDDLE_BUTTON_DOWN); |
| 140 back_->set_tag(IDC_BACK); | 139 back_->set_tag(IDC_BACK); |
| 141 back_->SetImageAlignment(views::ImageButton::ALIGN_RIGHT, | 140 back_->SetImageAlignment(views::ImageButton::ALIGN_RIGHT, |
| 142 views::ImageButton::ALIGN_TOP); | 141 views::ImageButton::ALIGN_TOP); |
| 143 back_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_BACK)); | 142 back_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_BACK)); |
| 144 back_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_BACK)); | 143 back_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_BACK)); |
| 145 back_->set_id(VIEW_ID_BACK_BUTTON); | 144 back_->set_id(VIEW_ID_BACK_BUTTON); |
| 146 | 145 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 return GetWidget()->GetAccelerator(id, accel); | 329 return GetWidget()->GetAccelerator(id, accel); |
| 331 } | 330 } |
| 332 | 331 |
| 333 //////////////////////////////////////////////////////////////////////////////// | 332 //////////////////////////////////////////////////////////////////////////////// |
| 334 // ToolbarView, views::ViewMenuDelegate implementation: | 333 // ToolbarView, views::ViewMenuDelegate implementation: |
| 335 | 334 |
| 336 void ToolbarView::RunMenu(views::View* source, const gfx::Point& /* pt */) { | 335 void ToolbarView::RunMenu(views::View* source, const gfx::Point& /* pt */) { |
| 337 DCHECK_EQ(VIEW_ID_APP_MENU, source->id()); | 336 DCHECK_EQ(VIEW_ID_APP_MENU, source->id()); |
| 338 | 337 |
| 339 wrench_menu_.reset(new WrenchMenu(browser_)); | 338 wrench_menu_.reset(new WrenchMenu(browser_)); |
| 340 wrench_menu_->Init(wrench_menu_model_.get()); | 339 WrenchMenuModel model(this, browser_); |
| 340 wrench_menu_->Init(&model); |
| 341 | 341 |
| 342 FOR_EACH_OBSERVER(views::MenuListener, menu_listeners_, OnMenuOpened()); | 342 FOR_EACH_OBSERVER(views::MenuListener, menu_listeners_, OnMenuOpened()); |
| 343 | 343 |
| 344 wrench_menu_->RunMenu(app_menu_); | 344 wrench_menu_->RunMenu(app_menu_); |
| 345 } | 345 } |
| 346 | 346 |
| 347 //////////////////////////////////////////////////////////////////////////////// | 347 //////////////////////////////////////////////////////////////////////////////// |
| 348 // ToolbarView, LocationBarView::Delegate implementation: | 348 // ToolbarView, LocationBarView::Delegate implementation: |
| 349 | 349 |
| 350 TabContentsWrapper* ToolbarView::GetTabContentsWrapper() const { | 350 TabContentsWrapper* ToolbarView::GetTabContentsWrapper() const { |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); | 710 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); |
| 711 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); | 711 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); |
| 712 } | 712 } |
| 713 | 713 |
| 714 void ToolbarView::UpdateAppMenuBadge() { | 714 void ToolbarView::UpdateAppMenuBadge() { |
| 715 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); | 715 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); |
| 716 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); | 716 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); |
| 717 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); | 717 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); |
| 718 SchedulePaint(); | 718 SchedulePaint(); |
| 719 } | 719 } |
| OLD | NEW |