OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/command_updater.h" | 10 #include "chrome/browser/command_updater.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 // NOTE: Don't remove the command observers here. This object gets destroyed | 213 // NOTE: Don't remove the command observers here. This object gets destroyed |
214 // after the Browser (which owns the CommandUpdater), so the CommandUpdater is | 214 // after the Browser (which owns the CommandUpdater), so the CommandUpdater is |
215 // already gone. | 215 // already gone. |
216 | 216 |
217 // TODO(kuan): Reset the search model observer in ~BrowserView before we lose | 217 // TODO(kuan): Reset the search model observer in ~BrowserView before we lose |
218 // browser. | 218 // browser. |
219 } | 219 } |
220 | 220 |
221 void ToolbarView::Init(views::View* location_bar_parent, | 221 void ToolbarView::Init(views::View* location_bar_parent, |
222 views::View* popup_parent_view) { | 222 views::View* popup_parent_view) { |
223 back_menu_model_.reset(new BackForwardMenuModel( | 223 back_ = new views::ButtonDropDown(this, new BackForwardMenuModel( |
224 browser_, BackForwardMenuModel::BACKWARD_MENU)); | 224 browser_, BackForwardMenuModel::BACKWARD_MENU)); |
225 forward_menu_model_.reset(new BackForwardMenuModel( | |
226 browser_, BackForwardMenuModel::FORWARD_MENU)); | |
227 | |
228 back_ = new views::ButtonDropDown(this, back_menu_model_.get()); | |
229 back_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | | 225 back_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | |
230 ui::EF_MIDDLE_MOUSE_BUTTON); | 226 ui::EF_MIDDLE_MOUSE_BUTTON); |
231 back_->set_tag(IDC_BACK); | 227 back_->set_tag(IDC_BACK); |
232 back_->SetImageAlignment(views::ImageButton::ALIGN_RIGHT, | 228 back_->SetImageAlignment(views::ImageButton::ALIGN_RIGHT, |
233 views::ImageButton::ALIGN_TOP); | 229 views::ImageButton::ALIGN_TOP); |
234 back_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_BACK)); | 230 back_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_BACK)); |
235 back_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_BACK)); | 231 back_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_BACK)); |
236 back_->set_id(VIEW_ID_BACK_BUTTON); | 232 back_->set_id(VIEW_ID_BACK_BUTTON); |
237 | 233 |
238 forward_ = new views::ButtonDropDown(this, forward_menu_model_.get()); | 234 forward_ = new views::ButtonDropDown(this, new BackForwardMenuModel( |
| 235 browser_, BackForwardMenuModel::FORWARD_MENU)); |
239 forward_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | | 236 forward_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | |
240 ui::EF_MIDDLE_MOUSE_BUTTON); | 237 ui::EF_MIDDLE_MOUSE_BUTTON); |
241 forward_->set_tag(IDC_FORWARD); | 238 forward_->set_tag(IDC_FORWARD); |
242 forward_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_FORWARD)); | 239 forward_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_FORWARD)); |
243 forward_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FORWARD)); | 240 forward_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FORWARD)); |
244 forward_->set_id(VIEW_ID_FORWARD_BUTTON); | 241 forward_->set_id(VIEW_ID_FORWARD_BUTTON); |
245 | 242 |
246 // Have to create this before |reload_| as |reload_|'s constructor needs it. | 243 // Have to create this before |reload_| as |reload_|'s constructor needs it. |
247 location_bar_container_ = new LocationBarContainer( | 244 location_bar_container_ = new LocationBarContainer( |
248 location_bar_parent, | 245 location_bar_parent, |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 // LocationBarContainer is not a child of the ToolbarView. | 1011 // LocationBarContainer is not a child of the ToolbarView. |
1015 gfx::Point origin(bounds.origin()); | 1012 gfx::Point origin(bounds.origin()); |
1016 views::View::ConvertPointToView(this, location_bar_container_->parent(), | 1013 views::View::ConvertPointToView(this, location_bar_container_->parent(), |
1017 &origin); | 1014 &origin); |
1018 gfx::Rect target_bounds(origin, bounds.size()); | 1015 gfx::Rect target_bounds(origin, bounds.size()); |
1019 if (location_bar_container_->GetTargetBounds() != target_bounds) { | 1016 if (location_bar_container_->GetTargetBounds() != target_bounds) { |
1020 location_bar_container_->SetInToolbar(true); | 1017 location_bar_container_->SetInToolbar(true); |
1021 location_bar_container_->SetBoundsRect(target_bounds); | 1018 location_bar_container_->SetBoundsRect(target_bounds); |
1022 } | 1019 } |
1023 } | 1020 } |
OLD | NEW |