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