| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 if (!kPopupBackgroundEdge) { | 105 if (!kPopupBackgroundEdge) { |
| 106 kPopupBackgroundEdge = ResourceBundle::GetSharedInstance().GetBitmapNamed( | 106 kPopupBackgroundEdge = ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 107 IDR_LOCATIONBG_POPUPMODE_EDGE); | 107 IDR_LOCATIONBG_POPUPMODE_EDGE); |
| 108 } | 108 } |
| 109 | 109 |
| 110 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, | 110 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, |
| 111 NotificationService::AllSources()); | 111 NotificationService::AllSources()); |
| 112 registrar_.Add(this, | 112 registrar_.Add(this, |
| 113 chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE, | 113 chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE, |
| 114 NotificationService::AllSources()); | 114 NotificationService::AllSources()); |
| 115 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, |
| 116 Source<Profile>(browser_->profile())); |
| 115 } | 117 } |
| 116 | 118 |
| 117 ToolbarView::~ToolbarView() { | 119 ToolbarView::~ToolbarView() { |
| 118 // NOTE: Don't remove the command observers here. This object gets destroyed | 120 // NOTE: Don't remove the command observers here. This object gets destroyed |
| 119 // after the Browser (which owns the CommandUpdater), so the CommandUpdater is | 121 // after the Browser (which owns the CommandUpdater), so the CommandUpdater is |
| 120 // already gone. | 122 // already gone. |
| 121 } | 123 } |
| 122 | 124 |
| 123 void ToolbarView::Init() { | 125 void ToolbarView::Init() { |
| 124 back_menu_model_.reset(new BackForwardMenuModel( | 126 back_menu_model_.reset(new BackForwardMenuModel( |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 } | 405 } |
| 404 browser_->ExecuteCommandWithDisposition(command, disposition); | 406 browser_->ExecuteCommandWithDisposition(command, disposition); |
| 405 } | 407 } |
| 406 | 408 |
| 407 //////////////////////////////////////////////////////////////////////////////// | 409 //////////////////////////////////////////////////////////////////////////////// |
| 408 // ToolbarView, NotificationObserver implementation: | 410 // ToolbarView, NotificationObserver implementation: |
| 409 | 411 |
| 410 void ToolbarView::Observe(int type, | 412 void ToolbarView::Observe(int type, |
| 411 const NotificationSource& source, | 413 const NotificationSource& source, |
| 412 const NotificationDetails& details) { | 414 const NotificationDetails& details) { |
| 413 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 415 switch (type) { |
| 414 std::string* pref_name = Details<std::string>(details).ptr(); | 416 case chrome::NOTIFICATION_PREF_CHANGED: { |
| 415 if (*pref_name == prefs::kShowHomeButton) { | 417 std::string* pref_name = Details<std::string>(details).ptr(); |
| 416 Layout(); | 418 if (*pref_name == prefs::kShowHomeButton) { |
| 417 SchedulePaint(); | 419 Layout(); |
| 420 SchedulePaint(); |
| 421 } |
| 422 break; |
| 418 } | 423 } |
| 419 } else if ( | 424 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: |
| 420 type == chrome::NOTIFICATION_UPGRADE_RECOMMENDED || | 425 case chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE: |
| 421 type == chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE) { | 426 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED: |
| 422 UpdateAppMenuBadge(); | 427 UpdateAppMenuBadge(); |
| 428 break; |
| 423 } | 429 } |
| 424 } | 430 } |
| 425 | 431 |
| 426 //////////////////////////////////////////////////////////////////////////////// | 432 //////////////////////////////////////////////////////////////////////////////// |
| 427 // ToolbarView, ui::AcceleratorProvider implementation: | 433 // ToolbarView, ui::AcceleratorProvider implementation: |
| 428 | 434 |
| 429 bool ToolbarView::GetAcceleratorForCommandId(int command_id, | 435 bool ToolbarView::GetAcceleratorForCommandId(int command_id, |
| 430 ui::Accelerator* accelerator) { | 436 ui::Accelerator* accelerator) { |
| 431 // The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators | 437 // The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators |
| 432 // anywhere so we need to check for them explicitly here. | 438 // anywhere so we need to check for them explicitly here. |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); | 704 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); |
| 699 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); | 705 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); |
| 700 } | 706 } |
| 701 | 707 |
| 702 void ToolbarView::UpdateAppMenuBadge() { | 708 void ToolbarView::UpdateAppMenuBadge() { |
| 703 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); | 709 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); |
| 704 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); | 710 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); |
| 705 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); | 711 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); |
| 706 SchedulePaint(); | 712 SchedulePaint(); |
| 707 } | 713 } |
| OLD | NEW |