| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/toolbar_view.h" | 5 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/i18n/number_formatting.h" | 10 #include "base/i18n/number_formatting.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" | 24 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" |
| 25 #include "chrome/browser/ui/browser_instant_controller.h" | 25 #include "chrome/browser/ui/browser_instant_controller.h" |
| 26 #include "chrome/browser/ui/browser_tabstrip.h" | 26 #include "chrome/browser/ui/browser_tabstrip.h" |
| 27 #include "chrome/browser/ui/browser_window.h" | 27 #include "chrome/browser/ui/browser_window.h" |
| 28 #include "chrome/browser/ui/global_error/global_error_service.h" | 28 #include "chrome/browser/ui/global_error/global_error_service.h" |
| 29 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 29 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 30 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 30 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 32 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 32 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
| 33 #include "chrome/browser/ui/view_ids.h" | 33 #include "chrome/browser/ui/view_ids.h" |
| 34 #include "chrome/browser/ui/views/extensions/extension_message_bubble_view.h" |
| 34 #include "chrome/browser/ui/views/extensions/extension_popup.h" | 35 #include "chrome/browser/ui/views/extensions/extension_popup.h" |
| 35 #include "chrome/browser/ui/views/frame/browser_view.h" | 36 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 36 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" | 37 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" |
| 37 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" | 38 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" |
| 38 #include "chrome/browser/ui/views/location_bar/star_view.h" | 39 #include "chrome/browser/ui/views/location_bar/star_view.h" |
| 39 #include "chrome/browser/ui/views/location_bar/translate_icon_view.h" | 40 #include "chrome/browser/ui/views/location_bar/translate_icon_view.h" |
| 40 #include "chrome/browser/ui/views/outdated_upgrade_bubble_view.h" | 41 #include "chrome/browser/ui/views/outdated_upgrade_bubble_view.h" |
| 41 #include "chrome/browser/ui/views/toolbar/back_button.h" | 42 #include "chrome/browser/ui/views/toolbar/back_button.h" |
| 42 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" | 43 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" |
| 43 #include "chrome/browser/ui/views/toolbar/home_button.h" | 44 #include "chrome/browser/ui/views/toolbar/home_button.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 123 |
| 123 ToolbarView::ToolbarView(Browser* browser) | 124 ToolbarView::ToolbarView(Browser* browser) |
| 124 : back_(NULL), | 125 : back_(NULL), |
| 125 forward_(NULL), | 126 forward_(NULL), |
| 126 reload_(NULL), | 127 reload_(NULL), |
| 127 home_(NULL), | 128 home_(NULL), |
| 128 location_bar_(NULL), | 129 location_bar_(NULL), |
| 129 browser_actions_(NULL), | 130 browser_actions_(NULL), |
| 130 app_menu_(NULL), | 131 app_menu_(NULL), |
| 131 browser_(browser), | 132 browser_(browser), |
| 132 badge_controller_(browser->profile(), this) { | 133 badge_controller_(browser->profile(), this), |
| 134 extension_message_bubble_factory_( |
| 135 new extensions::ExtensionMessageBubbleFactory(browser->profile(), |
| 136 this)) { |
| 133 set_id(VIEW_ID_TOOLBAR); | 137 set_id(VIEW_ID_TOOLBAR); |
| 134 | 138 |
| 135 SetEventTargeter( | 139 SetEventTargeter( |
| 136 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); | 140 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); |
| 137 | 141 |
| 138 chrome::AddCommandObserver(browser_, IDC_BACK, this); | 142 chrome::AddCommandObserver(browser_, IDC_BACK, this); |
| 139 chrome::AddCommandObserver(browser_, IDC_FORWARD, this); | 143 chrome::AddCommandObserver(browser_, IDC_FORWARD, this); |
| 140 chrome::AddCommandObserver(browser_, IDC_RELOAD, this); | 144 chrome::AddCommandObserver(browser_, IDC_RELOAD, this); |
| 141 chrome::AddCommandObserver(browser_, IDC_HOME, this); | 145 chrome::AddCommandObserver(browser_, IDC_HOME, this); |
| 142 chrome::AddCommandObserver(browser_, IDC_LOAD_NEW_TAB_PAGE, this); | 146 chrome::AddCommandObserver(browser_, IDC_LOAD_NEW_TAB_PAGE, this); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 // Accessibility specific tooltip text. | 264 // Accessibility specific tooltip text. |
| 261 if (content::BrowserAccessibilityState::GetInstance()-> | 265 if (content::BrowserAccessibilityState::GetInstance()-> |
| 262 IsAccessibleBrowser()) { | 266 IsAccessibleBrowser()) { |
| 263 back_->SetTooltipText( | 267 back_->SetTooltipText( |
| 264 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_BACK)); | 268 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_BACK)); |
| 265 forward_->SetTooltipText( | 269 forward_->SetTooltipText( |
| 266 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_FORWARD)); | 270 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_FORWARD)); |
| 267 } | 271 } |
| 268 } | 272 } |
| 269 | 273 |
| 274 void ToolbarView::OnWidgetVisibilityChanged(views::Widget* widget, |
| 275 bool visible) { |
| 276 if (visible) { |
| 277 // Safe to call multiple times; the bubble will only appear once. |
| 278 extension_message_bubble_factory_->MaybeShow(app_menu_); |
| 279 } |
| 280 } |
| 281 |
| 270 void ToolbarView::OnWidgetActivationChanged(views::Widget* widget, | 282 void ToolbarView::OnWidgetActivationChanged(views::Widget* widget, |
| 271 bool active) { | 283 bool active) { |
| 272 extensions::ExtensionCommandsGlobalRegistry* registry = | 284 extensions::ExtensionCommandsGlobalRegistry* registry = |
| 273 extensions::ExtensionCommandsGlobalRegistry::Get(browser_->profile()); | 285 extensions::ExtensionCommandsGlobalRegistry::Get(browser_->profile()); |
| 274 if (active) { | 286 if (active) { |
| 275 registry->set_registry_for_active_window( | 287 registry->set_registry_for_active_window( |
| 276 browser_actions_->extension_keybinding_registry()); | 288 browser_actions_->extension_keybinding_registry()); |
| 277 } else if (registry->registry_for_active_window() == | 289 } else if (registry->registry_for_active_window() == |
| 278 browser_actions_->extension_keybinding_registry()) { | 290 browser_actions_->extension_keybinding_registry()) { |
| 279 registry->set_registry_for_active_window(nullptr); | 291 registry->set_registry_for_active_window(nullptr); |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 | 792 |
| 781 void ToolbarView::OnShowHomeButtonChanged() { | 793 void ToolbarView::OnShowHomeButtonChanged() { |
| 782 Layout(); | 794 Layout(); |
| 783 SchedulePaint(); | 795 SchedulePaint(); |
| 784 } | 796 } |
| 785 | 797 |
| 786 int ToolbarView::content_shadow_height() const { | 798 int ToolbarView::content_shadow_height() const { |
| 787 return browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH ? | 799 return browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH ? |
| 788 kContentShadowHeightAsh : kContentShadowHeight; | 800 kContentShadowHeightAsh : kContentShadowHeight; |
| 789 } | 801 } |
| OLD | NEW |