Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Side by Side Diff: chrome/browser/ui/views/toolbar_view.cc

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 chrome::ExecuteCommandWithDisposition(browser_, command, disposition); 601 chrome::ExecuteCommandWithDisposition(browser_, command, disposition);
602 } 602 }
603 603
604 //////////////////////////////////////////////////////////////////////////////// 604 ////////////////////////////////////////////////////////////////////////////////
605 // ToolbarView, content::NotificationObserver implementation: 605 // ToolbarView, content::NotificationObserver implementation:
606 606
607 void ToolbarView::Observe(int type, 607 void ToolbarView::Observe(int type,
608 const content::NotificationSource& source, 608 const content::NotificationSource& source,
609 const content::NotificationDetails& details) { 609 const content::NotificationDetails& details) {
610 switch (type) { 610 switch (type) {
611 case chrome::NOTIFICATION_PREF_CHANGED: {
612 std::string* pref_name = content::Details<std::string>(details).ptr();
613 if (*pref_name == prefs::kShowHomeButton) {
614 Layout();
615 SchedulePaint();
616 }
617 break;
618 }
619 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: 611 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED:
620 case chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE: 612 case chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE:
621 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED: 613 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED:
622 UpdateAppMenuState(); 614 UpdateAppMenuState();
623 break; 615 break;
624 #if defined(OS_WIN) 616 #if defined(OS_WIN)
625 case chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED: 617 case chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED:
626 ShowCriticalNotification(); 618 ShowCriticalNotification();
627 break; 619 break;
628 #endif 620 #endif
629 default: 621 default:
630 NOTREACHED(); 622 NOTREACHED();
631 } 623 }
632 } 624 }
633 625
626 void ToolbarView::OnPreferenceChanged(PrefServiceBase* service,
627 const std::string& pref_name) {
628 if (pref_name == prefs::kShowHomeButton) {
629 Layout();
630 SchedulePaint();
631 }
632 }
633
634 //////////////////////////////////////////////////////////////////////////////// 634 ////////////////////////////////////////////////////////////////////////////////
635 // ToolbarView, ui::AcceleratorProvider implementation: 635 // ToolbarView, ui::AcceleratorProvider implementation:
636 636
637 bool ToolbarView::GetAcceleratorForCommandId(int command_id, 637 bool ToolbarView::GetAcceleratorForCommandId(int command_id,
638 ui::Accelerator* accelerator) { 638 ui::Accelerator* accelerator) {
639 // The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators 639 // The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators
640 // anywhere so we need to check for them explicitly here. 640 // anywhere so we need to check for them explicitly here.
641 // TODO(cpu) Bug 1109102. Query WebKit land for the actual bindings. 641 // TODO(cpu) Bug 1109102. Query WebKit land for the actual bindings.
642 switch (command_id) { 642 switch (command_id) {
643 case IDC_CUT: 643 case IDC_CUT:
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 // LocationBarContainer is not a child of the ToolbarView. 1055 // LocationBarContainer is not a child of the ToolbarView.
1056 gfx::Point origin(bounds.origin()); 1056 gfx::Point origin(bounds.origin());
1057 views::View::ConvertPointToTarget(this, location_bar_container_->parent(), 1057 views::View::ConvertPointToTarget(this, location_bar_container_->parent(),
1058 &origin); 1058 &origin);
1059 gfx::Rect target_bounds(origin, bounds.size()); 1059 gfx::Rect target_bounds(origin, bounds.size());
1060 if (location_bar_container_->GetTargetBounds() != target_bounds) { 1060 if (location_bar_container_->GetTargetBounds() != target_bounds) {
1061 location_bar_container_->SetInToolbar(true); 1061 location_bar_container_->SetInToolbar(true);
1062 location_bar_container_->SetBoundsRect(target_bounds); 1062 location_bar_container_->SetBoundsRect(target_bounds);
1063 } 1063 }
1064 } 1064 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698