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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
11 #include "base/i18n/number_formatting.h" | 11 #include "base/i18n/number_formatting.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
16 #include "chrome/browser/command_updater.h" | 16 #include "chrome/browser/command_updater.h" |
17 #include "chrome/browser/extensions/extension_commands_global_registry.h" | |
18 #include "chrome/browser/extensions/extension_util.h" | 17 #include "chrome/browser/extensions/extension_util.h" |
19 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/themes/theme_service.h" | 19 #include "chrome/browser/themes/theme_service.h" |
21 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
22 #include "chrome/browser/ui/browser_command_controller.h" | 21 #include "chrome/browser/ui/browser_command_controller.h" |
23 #include "chrome/browser/ui/browser_commands.h" | 22 #include "chrome/browser/ui/browser_commands.h" |
24 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" | 23 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" |
25 #include "chrome/browser/ui/browser_instant_controller.h" | 24 #include "chrome/browser/ui/browser_instant_controller.h" |
26 #include "chrome/browser/ui/browser_tabstrip.h" | 25 #include "chrome/browser/ui/browser_tabstrip.h" |
27 #include "chrome/browser/ui/browser_window.h" | 26 #include "chrome/browser/ui/browser_window.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 IsAccessibleBrowser()) { | 263 IsAccessibleBrowser()) { |
265 back_->SetTooltipText( | 264 back_->SetTooltipText( |
266 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_BACK)); | 265 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_BACK)); |
267 forward_->SetTooltipText( | 266 forward_->SetTooltipText( |
268 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_FORWARD)); | 267 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_FORWARD)); |
269 } | 268 } |
270 } | 269 } |
271 | 270 |
272 void ToolbarView::OnWidgetVisibilityChanged(views::Widget* widget, | 271 void ToolbarView::OnWidgetVisibilityChanged(views::Widget* widget, |
273 bool visible) { | 272 bool visible) { |
274 if (visible) { | 273 // Safe to call multiple times; the bubble will only appear once. |
275 // Safe to call multiple times; the bubble will only appear once. | 274 if (visible) |
276 extension_message_bubble_factory_->MaybeShow(app_menu_); | 275 extension_message_bubble_factory_->MaybeShow(app_menu_); |
277 } | |
278 } | |
279 | |
280 void ToolbarView::OnWidgetActivationChanged(views::Widget* widget, | |
281 bool active) { | |
282 extensions::ExtensionCommandsGlobalRegistry* registry = | |
283 extensions::ExtensionCommandsGlobalRegistry::Get(browser_->profile()); | |
284 if (registry) { | |
285 if (active) { | |
286 registry->set_registry_for_active_window( | |
287 browser_actions_->extension_keybinding_registry()); | |
288 } else if (registry->registry_for_active_window() == | |
289 browser_actions_->extension_keybinding_registry()) { | |
290 registry->set_registry_for_active_window(NULL); | |
291 } | |
292 } | |
293 } | 276 } |
294 | 277 |
295 void ToolbarView::Update(WebContents* tab) { | 278 void ToolbarView::Update(WebContents* tab) { |
296 if (location_bar_) | 279 if (location_bar_) |
297 location_bar_->Update(tab); | 280 location_bar_->Update(tab); |
298 if (browser_actions_) | 281 if (browser_actions_) |
299 browser_actions_->RefreshBrowserActionViews(); | 282 browser_actions_->RefreshBrowserActionViews(); |
300 if (reload_) | 283 if (reload_) |
301 reload_->set_menu_enabled(chrome::IsDebuggerAttachedToCurrentTab(browser_)); | 284 reload_->set_menu_enabled(chrome::IsDebuggerAttachedToCurrentTab(browser_)); |
302 } | 285 } |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 | 766 |
784 void ToolbarView::OnShowHomeButtonChanged() { | 767 void ToolbarView::OnShowHomeButtonChanged() { |
785 Layout(); | 768 Layout(); |
786 SchedulePaint(); | 769 SchedulePaint(); |
787 } | 770 } |
788 | 771 |
789 int ToolbarView::content_shadow_height() const { | 772 int ToolbarView::content_shadow_height() const { |
790 return browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH ? | 773 return browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH ? |
791 kContentShadowHeightAsh : kContentShadowHeight; | 774 kContentShadowHeightAsh : kContentShadowHeight; |
792 } | 775 } |
OLD | NEW |