| 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/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
| 14 #include "chrome/browser/ui/global_error_service.h" | 14 #include "chrome/browser/ui/global_error_service.h" |
| 15 #include "chrome/browser/ui/global_error_service_factory.h" | 15 #include "chrome/browser/ui/global_error_service_factory.h" |
| 16 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 16 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
| 17 #include "chrome/browser/ui/view_ids.h" | 17 #include "chrome/browser/ui/view_ids.h" |
| 18 #include "chrome/browser/ui/views/browser_actions_container.h" | 18 #include "chrome/browser/ui/views/browser_actions_container.h" |
| 19 #include "chrome/browser/ui/views/event_utils.h" | 19 #include "chrome/browser/ui/views/event_utils.h" |
| 20 #include "chrome/browser/ui/views/window.h" | 20 #include "chrome/browser/ui/views/window.h" |
| 21 #include "chrome/browser/ui/views/wrench_menu.h" | 21 #include "chrome/browser/ui/views/wrench_menu.h" |
| 22 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" |
| 22 #include "chrome/browser/upgrade_detector.h" | 23 #include "chrome/browser/upgrade_detector.h" |
| 23 #include "chrome/common/chrome_notification_types.h" | 24 #include "chrome/common/chrome_notification_types.h" |
| 24 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 25 #include "content/public/browser/browser_accessibility_state.h" | 26 #include "content/public/browser/browser_accessibility_state.h" |
| 26 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
| 27 #include "content/public/browser/user_metrics.h" | 28 #include "content/public/browser/user_metrics.h" |
| 28 #include "grit/chromium_strings.h" | 29 #include "grit/chromium_strings.h" |
| 29 #include "grit/generated_resources.h" | 30 #include "grit/generated_resources.h" |
| 30 #include "grit/theme_resources.h" | 31 #include "grit/theme_resources.h" |
| 31 #include "grit/theme_resources_standard.h" | 32 #include "grit/theme_resources_standard.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 150 |
| 150 forward_ = new views::ButtonDropDown(this, forward_menu_model_.get()); | 151 forward_ = new views::ButtonDropDown(this, forward_menu_model_.get()); |
| 151 forward_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | | 152 forward_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | |
| 152 ui::EF_MIDDLE_MOUSE_BUTTON); | 153 ui::EF_MIDDLE_MOUSE_BUTTON); |
| 153 forward_->set_tag(IDC_FORWARD); | 154 forward_->set_tag(IDC_FORWARD); |
| 154 forward_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_FORWARD)); | 155 forward_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_FORWARD)); |
| 155 forward_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FORWARD)); | 156 forward_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FORWARD)); |
| 156 forward_->set_id(VIEW_ID_FORWARD_BUTTON); | 157 forward_->set_id(VIEW_ID_FORWARD_BUTTON); |
| 157 | 158 |
| 158 // Have to create this before |reload_| as |reload_|'s constructor needs it. | 159 // Have to create this before |reload_| as |reload_|'s constructor needs it. |
| 159 location_bar_ = new LocationBarView(browser_, model_, this, | 160 location_bar_ = new LocationBarView( |
| 161 browser_->profile(), |
| 162 browser_->command_updater(), |
| 163 model_, |
| 164 this, |
| 160 (display_mode_ == DISPLAYMODE_LOCATION) ? | 165 (display_mode_ == DISPLAYMODE_LOCATION) ? |
| 161 LocationBarView::POPUP : LocationBarView::NORMAL); | 166 LocationBarView::POPUP : LocationBarView::NORMAL); |
| 162 | 167 |
| 163 reload_ = new ReloadButton(location_bar_, browser_); | 168 reload_ = new ReloadButton(location_bar_, browser_->command_updater()); |
| 164 reload_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | | 169 reload_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | |
| 165 ui::EF_MIDDLE_MOUSE_BUTTON); | 170 ui::EF_MIDDLE_MOUSE_BUTTON); |
| 166 reload_->set_tag(IDC_RELOAD); | 171 reload_->set_tag(IDC_RELOAD); |
| 167 reload_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_RELOAD)); | 172 reload_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_RELOAD)); |
| 168 reload_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_RELOAD)); | 173 reload_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_RELOAD)); |
| 169 reload_->set_id(VIEW_ID_RELOAD_BUTTON); | 174 reload_->set_id(VIEW_ID_RELOAD_BUTTON); |
| 170 | 175 |
| 171 home_ = new views::ImageButton(this); | 176 home_ = new views::ImageButton(this); |
| 172 home_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | | 177 home_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | |
| 173 ui::EF_MIDDLE_MOUSE_BUTTON); | 178 ui::EF_MIDDLE_MOUSE_BUTTON); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 // ToolbarView, LocationBarView::Delegate implementation: | 350 // ToolbarView, LocationBarView::Delegate implementation: |
| 346 | 351 |
| 347 TabContentsWrapper* ToolbarView::GetTabContentsWrapper() const { | 352 TabContentsWrapper* ToolbarView::GetTabContentsWrapper() const { |
| 348 return browser_->GetSelectedTabContentsWrapper(); | 353 return browser_->GetSelectedTabContentsWrapper(); |
| 349 } | 354 } |
| 350 | 355 |
| 351 InstantController* ToolbarView::GetInstant() { | 356 InstantController* ToolbarView::GetInstant() { |
| 352 return browser_->instant(); | 357 return browser_->instant(); |
| 353 } | 358 } |
| 354 | 359 |
| 360 BrowserShowContentRelated* ToolbarView::GetBrowserShowContentRelated() { |
| 361 return browser_; |
| 362 } |
| 363 |
| 364 BrowserShowPageInfo* ToolbarView::GetBrowserShowPageInfo() { |
| 365 return browser_; |
| 366 } |
| 367 |
| 368 views::Widget* ToolbarView::CreateViewsBubble( |
| 369 views::BubbleDelegateView* bubble_delegate) { |
| 370 return browser::CreateViewsBubble(bubble_delegate); |
| 371 } |
| 372 |
| 373 PageActionImageView* ToolbarView::CreatePageActionImageView( |
| 374 LocationBarView* owner, ExtensionAction* action) { |
| 375 return new PageActionImageView(owner, action, browser_); |
| 376 } |
| 377 |
| 355 void ToolbarView::OnInputInProgress(bool in_progress) { | 378 void ToolbarView::OnInputInProgress(bool in_progress) { |
| 356 // The edit should make sure we're only notified when something changes. | 379 // The edit should make sure we're only notified when something changes. |
| 357 DCHECK(model_->input_in_progress() != in_progress); | 380 DCHECK(model_->input_in_progress() != in_progress); |
| 358 | 381 |
| 359 model_->set_input_in_progress(in_progress); | 382 model_->set_input_in_progress(in_progress); |
| 360 location_bar_->Update(NULL); | 383 location_bar_->Update(NULL); |
| 361 } | 384 } |
| 362 | 385 |
| 363 //////////////////////////////////////////////////////////////////////////////// | 386 //////////////////////////////////////////////////////////////////////////////// |
| 364 // ToolbarView, CommandUpdater::CommandObserver implementation: | 387 // ToolbarView, CommandUpdater::CommandObserver implementation: |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 accname_app = l10n_util::GetStringFUTF16( | 756 accname_app = l10n_util::GetStringFUTF16( |
| 734 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); | 757 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); |
| 735 } | 758 } |
| 736 app_menu_->SetAccessibleName(accname_app); | 759 app_menu_->SetAccessibleName(accname_app); |
| 737 | 760 |
| 738 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); | 761 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); |
| 739 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); | 762 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); |
| 740 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); | 763 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); |
| 741 SchedulePaint(); | 764 SchedulePaint(); |
| 742 } | 765 } |
| OLD | NEW |