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/command_updater.h" | 10 #include "chrome/browser/command_updater.h" |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 } | 521 } |
522 } | 522 } |
523 | 523 |
524 //////////////////////////////////////////////////////////////////////////////// | 524 //////////////////////////////////////////////////////////////////////////////// |
525 // ToolbarView, content::NotificationObserver implementation: | 525 // ToolbarView, content::NotificationObserver implementation: |
526 | 526 |
527 void ToolbarView::Observe(int type, | 527 void ToolbarView::Observe(int type, |
528 const content::NotificationSource& source, | 528 const content::NotificationSource& source, |
529 const content::NotificationDetails& details) { | 529 const content::NotificationDetails& details) { |
530 switch (type) { | 530 switch (type) { |
531 case chrome::NOTIFICATION_PREF_CHANGED: { | |
532 std::string* pref_name = content::Details<std::string>(details).ptr(); | |
533 if (*pref_name == prefs::kShowHomeButton) { | |
534 Layout(); | |
535 SchedulePaint(); | |
536 } | |
537 break; | |
538 } | |
539 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: | 531 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: |
540 case chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE: | 532 case chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE: |
541 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED: | 533 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED: |
542 UpdateAppMenuState(); | 534 UpdateAppMenuState(); |
543 break; | 535 break; |
544 #if defined(OS_WIN) | 536 #if defined(OS_WIN) |
545 case chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED: | 537 case chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED: |
546 ShowCriticalNotification(); | 538 ShowCriticalNotification(); |
547 break; | 539 break; |
548 #endif | 540 #endif |
549 default: | 541 default: |
550 NOTREACHED(); | 542 NOTREACHED(); |
551 } | 543 } |
552 } | 544 } |
553 | 545 |
| 546 void ToolbarView::OnPreferenceChanged(PrefServiceBase* service, |
| 547 const std::string& pref_name) { |
| 548 if (pref_name == prefs::kShowHomeButton) { |
| 549 Layout(); |
| 550 SchedulePaint(); |
| 551 } |
| 552 } |
| 553 |
554 //////////////////////////////////////////////////////////////////////////////// | 554 //////////////////////////////////////////////////////////////////////////////// |
555 // ToolbarView, ui::AcceleratorProvider implementation: | 555 // ToolbarView, ui::AcceleratorProvider implementation: |
556 | 556 |
557 bool ToolbarView::GetAcceleratorForCommandId(int command_id, | 557 bool ToolbarView::GetAcceleratorForCommandId(int command_id, |
558 ui::Accelerator* accelerator) { | 558 ui::Accelerator* accelerator) { |
559 // The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators | 559 // The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators |
560 // anywhere so we need to check for them explicitly here. | 560 // anywhere so we need to check for them explicitly here. |
561 // TODO(cpu) Bug 1109102. Query WebKit land for the actual bindings. | 561 // TODO(cpu) Bug 1109102. Query WebKit land for the actual bindings. |
562 switch (command_id) { | 562 switch (command_id) { |
563 case IDC_CUT: | 563 case IDC_CUT: |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 accname_app = l10n_util::GetStringFUTF16( | 888 accname_app = l10n_util::GetStringFUTF16( |
889 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); | 889 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); |
890 } | 890 } |
891 app_menu_->SetAccessibleName(accname_app); | 891 app_menu_->SetAccessibleName(accname_app); |
892 | 892 |
893 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); | 893 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); |
894 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); | 894 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); |
895 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); | 895 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); |
896 SchedulePaint(); | 896 SchedulePaint(); |
897 } | 897 } |
OLD | NEW |