| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 AddChildView(back_); | 280 AddChildView(back_); |
| 281 AddChildView(forward_); | 281 AddChildView(forward_); |
| 282 AddChildView(reload_); | 282 AddChildView(reload_); |
| 283 AddChildView(home_); | 283 AddChildView(home_); |
| 284 AddChildView(location_bar_); | 284 AddChildView(location_bar_); |
| 285 AddChildView(browser_actions_); | 285 AddChildView(browser_actions_); |
| 286 AddChildView(app_menu_); | 286 AddChildView(app_menu_); |
| 287 | 287 |
| 288 location_bar_->Init(); | 288 location_bar_->Init(); |
| 289 show_home_button_.Init(prefs::kShowHomeButton, | 289 show_home_button_.Init(prefs::kShowHomeButton, |
| 290 browser_->profile()->GetPrefs(), this); | 290 browser_->profile()->GetPrefs(), |
| 291 base::Bind(&ToolbarView::OnShowHomeButtonChanged, |
| 292 base::Unretained(this))); |
| 291 | 293 |
| 292 browser_actions_->Init(); | 294 browser_actions_->Init(); |
| 293 | 295 |
| 294 // Accessibility specific tooltip text. | 296 // Accessibility specific tooltip text. |
| 295 if (content::BrowserAccessibilityState::GetInstance()-> | 297 if (content::BrowserAccessibilityState::GetInstance()-> |
| 296 IsAccessibleBrowser()) { | 298 IsAccessibleBrowser()) { |
| 297 back_->SetTooltipText( | 299 back_->SetTooltipText( |
| 298 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_BACK)); | 300 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_BACK)); |
| 299 forward_->SetTooltipText( | 301 forward_->SetTooltipText( |
| 300 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_FORWARD)); | 302 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_FORWARD)); |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 #if defined(OS_WIN) | 553 #if defined(OS_WIN) |
| 552 case chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED: | 554 case chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED: |
| 553 ShowCriticalNotification(); | 555 ShowCriticalNotification(); |
| 554 break; | 556 break; |
| 555 #endif | 557 #endif |
| 556 default: | 558 default: |
| 557 NOTREACHED(); | 559 NOTREACHED(); |
| 558 } | 560 } |
| 559 } | 561 } |
| 560 | 562 |
| 561 void ToolbarView::OnPreferenceChanged(PrefServiceBase* service, | |
| 562 const std::string& pref_name) { | |
| 563 if (pref_name == prefs::kShowHomeButton) { | |
| 564 Layout(); | |
| 565 SchedulePaint(); | |
| 566 } | |
| 567 } | |
| 568 | |
| 569 //////////////////////////////////////////////////////////////////////////////// | 563 //////////////////////////////////////////////////////////////////////////////// |
| 570 // ToolbarView, ui::AcceleratorProvider implementation: | 564 // ToolbarView, ui::AcceleratorProvider implementation: |
| 571 | 565 |
| 572 bool ToolbarView::GetAcceleratorForCommandId(int command_id, | 566 bool ToolbarView::GetAcceleratorForCommandId(int command_id, |
| 573 ui::Accelerator* accelerator) { | 567 ui::Accelerator* accelerator) { |
| 574 // The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators | 568 // The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators |
| 575 // anywhere so we need to check for them explicitly here. | 569 // anywhere so we need to check for them explicitly here. |
| 576 // TODO(cpu) Bug 1109102. Query WebKit land for the actual bindings. | 570 // TODO(cpu) Bug 1109102. Query WebKit land for the actual bindings. |
| 577 switch (command_id) { | 571 switch (command_id) { |
| 578 case IDC_CUT: | 572 case IDC_CUT: |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 accname_app = l10n_util::GetStringFUTF16( | 897 accname_app = l10n_util::GetStringFUTF16( |
| 904 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); | 898 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); |
| 905 } | 899 } |
| 906 app_menu_->SetAccessibleName(accname_app); | 900 app_menu_->SetAccessibleName(accname_app); |
| 907 | 901 |
| 908 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::STATE_NORMAL)); | 902 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::STATE_NORMAL)); |
| 909 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::STATE_HOVERED)); | 903 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::STATE_HOVERED)); |
| 910 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::STATE_PRESSED)); | 904 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::STATE_PRESSED)); |
| 911 SchedulePaint(); | 905 SchedulePaint(); |
| 912 } | 906 } |
| 907 |
| 908 void ToolbarView::OnShowHomeButtonChanged() { |
| 909 Layout(); |
| 910 SchedulePaint(); |
| 911 } |
| OLD | NEW |