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

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_browser.cc

Issue 11280115: Remove PrefObserver usages, batch 12. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix removal of PrefServiceObserver usage. Created 8 years 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/ash/launcher/chrome_launcher_controller_per_browser. h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_browser. h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/launcher/launcher_model.h" 9 #include "ash/launcher/launcher_model.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 app_tab_helper_.reset(new LauncherAppTabHelper(profile_)); 167 app_tab_helper_.reset(new LauncherAppTabHelper(profile_));
168 app_icon_loader_.reset(new LauncherAppIconLoader(profile_, this)); 168 app_icon_loader_.reset(new LauncherAppIconLoader(profile_, this));
169 169
170 notification_registrar_.Add(this, 170 notification_registrar_.Add(this,
171 chrome::NOTIFICATION_EXTENSION_LOADED, 171 chrome::NOTIFICATION_EXTENSION_LOADED,
172 content::Source<Profile>(profile_)); 172 content::Source<Profile>(profile_));
173 notification_registrar_.Add(this, 173 notification_registrar_.Add(this,
174 chrome::NOTIFICATION_EXTENSION_UNLOADED, 174 chrome::NOTIFICATION_EXTENSION_UNLOADED,
175 content::Source<Profile>(profile_)); 175 content::Source<Profile>(profile_));
176 pref_change_registrar_.Init(profile_->GetPrefs()); 176 pref_change_registrar_.Init(profile_->GetPrefs());
177 pref_change_registrar_.Add(prefs::kPinnedLauncherApps, this); 177 pref_change_registrar_.Add(
178 prefs::kPinnedLauncherApps,
179 base::Bind(&ChromeLauncherControllerPerBrowser::
180 UpdateAppLaunchersFromPref,
181 base::Unretained(this)));
178 } 182 }
179 183
180 ChromeLauncherControllerPerBrowser::~ChromeLauncherControllerPerBrowser() { 184 ChromeLauncherControllerPerBrowser::~ChromeLauncherControllerPerBrowser() {
181 // Reset the shell window controller here since it has a weak pointer to 185 // Reset the shell window controller here since it has a weak pointer to
182 // this. 186 // this.
183 shell_window_controller_.reset(); 187 shell_window_controller_.reset();
184 188
185 model_->RemoveObserver(this); 189 model_->RemoveObserver(this);
186 for (IDToItemControllerMap::iterator i = id_to_item_controller_map_.begin(); 190 for (IDToItemControllerMap::iterator i = id_to_item_controller_map_.begin();
187 i != id_to_item_controller_map_.end(); ++i) { 191 i != id_to_item_controller_map_.end(); ++i) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 228
225 UpdateAppLaunchersFromPref(); 229 UpdateAppLaunchersFromPref();
226 230
227 // TODO(sky): update unit test so that this test isn't necessary. 231 // TODO(sky): update unit test so that this test isn't necessary.
228 if (ash::Shell::HasInstance()) { 232 if (ash::Shell::HasInstance()) {
229 SetShelfAutoHideBehaviorFromPrefs(); 233 SetShelfAutoHideBehaviorFromPrefs();
230 SetShelfAlignmentFromPrefs(); 234 SetShelfAlignmentFromPrefs();
231 PrefService* prefs = profile_->GetPrefs(); 235 PrefService* prefs = profile_->GetPrefs();
232 if (prefs->GetString(prefs::kShelfAlignmentLocal).empty() || 236 if (prefs->GetString(prefs::kShelfAlignmentLocal).empty() ||
233 prefs->GetString(prefs::kShelfAutoHideBehaviorLocal).empty()) { 237 prefs->GetString(prefs::kShelfAutoHideBehaviorLocal).empty()) {
238 // This causes OnIsSyncingChanged to be called when the value of
239 // PrefService::IsSyncing() changes.
234 prefs->AddObserver(this); 240 prefs->AddObserver(this);
235 } 241 }
236 ash::Shell::GetInstance()->AddShellObserver(this); 242 ash::Shell::GetInstance()->AddShellObserver(this);
237 } 243 }
238 } 244 }
239 245
240 ash::LauncherID ChromeLauncherControllerPerBrowser::CreateTabbedLauncherItem( 246 ash::LauncherID ChromeLauncherControllerPerBrowser::CreateTabbedLauncherItem(
241 LauncherItemController* controller, 247 LauncherItemController* controller,
242 IncognitoState is_incognito, 248 IncognitoState is_incognito,
243 ash::LauncherItemStatus status) { 249 ash::LauncherItemStatus status) {
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 if (IsAppPinned(extension->id())) 787 if (IsAppPinned(extension->id()))
782 DoUnpinAppsWithID(extension->id()); 788 DoUnpinAppsWithID(extension->id());
783 app_icon_loader_->ClearImage(extension->id()); 789 app_icon_loader_->ClearImage(extension->id());
784 break; 790 break;
785 } 791 }
786 default: 792 default:
787 NOTREACHED() << "Unexpected notification type=" << type; 793 NOTREACHED() << "Unexpected notification type=" << type;
788 } 794 }
789 } 795 }
790 796
791 void ChromeLauncherControllerPerBrowser::OnPreferenceChanged(
792 PrefServiceBase* service,
793 const std::string& pref_name) {
794 if (pref_name == prefs::kPinnedLauncherApps) {
795 UpdateAppLaunchersFromPref();
796 } else if (pref_name == prefs::kShelfAlignmentLocal) {
797 SetShelfAlignmentFromPrefs();
798 } else if (pref_name == prefs::kShelfAutoHideBehaviorLocal) {
799 SetShelfAutoHideBehaviorFromPrefs();
800 } else {
801 NOTREACHED() << "Unexpected pref change for " << pref_name;
802 }
803 }
804
805 void ChromeLauncherControllerPerBrowser::OnShelfAlignmentChanged() { 797 void ChromeLauncherControllerPerBrowser::OnShelfAlignmentChanged() {
806 const char* pref_value = NULL; 798 const char* pref_value = NULL;
807 // TODO(oshima): Support multiple displays. 799 // TODO(oshima): Support multiple displays.
808 switch (ash::Shell::GetInstance()->GetShelfAlignment( 800 switch (ash::Shell::GetInstance()->GetShelfAlignment(
809 ash::Shell::GetPrimaryRootWindow())) { 801 ash::Shell::GetPrimaryRootWindow())) {
810 case ash::SHELF_ALIGNMENT_BOTTOM: 802 case ash::SHELF_ALIGNMENT_BOTTOM:
811 pref_value = ash::kShelfAlignmentBottom; 803 pref_value = ash::kShelfAlignmentBottom;
812 break; 804 break;
813 case ash::SHELF_ALIGNMENT_LEFT: 805 case ash::SHELF_ALIGNMENT_LEFT:
814 pref_value = ash::kShelfAlignmentLeft; 806 pref_value = ash::kShelfAlignmentLeft;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 ash::LauncherID id = model_->items()[i].id; 855 ash::LauncherID id = model_->items()[i].id;
864 if (HasItemController(id) && IsPinned(id)) { 856 if (HasItemController(id) && IsPinned(id)) {
865 base::DictionaryValue* app_value = ash::CreateAppDict( 857 base::DictionaryValue* app_value = ash::CreateAppDict(
866 id_to_item_controller_map_[id]->app_id()); 858 id_to_item_controller_map_[id]->app_id());
867 if (app_value) 859 if (app_value)
868 updater->Append(app_value); 860 updater->Append(app_value);
869 } 861 }
870 } 862 }
871 } 863 }
872 } 864 }
873 pref_change_registrar_.Add(prefs::kPinnedLauncherApps, this); 865 pref_change_registrar_.Add(
866 prefs::kPinnedLauncherApps,
867 base::Bind(&ChromeLauncherControllerPerBrowser::
868 UpdateAppLaunchersFromPref,
869 base::Unretained(this)));
874 } 870 }
875 871
876 ash::LauncherModel* ChromeLauncherControllerPerBrowser::model() { 872 ash::LauncherModel* ChromeLauncherControllerPerBrowser::model() {
877 return model_; 873 return model_;
878 } 874 }
879 875
880 Profile* ChromeLauncherControllerPerBrowser::profile() { 876 Profile* ChromeLauncherControllerPerBrowser::profile() {
881 return profile_; 877 return profile_;
882 } 878 }
883 879
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 AppIconLoader* loader) { 1102 AppIconLoader* loader) {
1107 app_icon_loader_.reset(loader); 1103 app_icon_loader_.reset(loader);
1108 } 1104 }
1109 1105
1110 const std::string& 1106 const std::string&
1111 ChromeLauncherControllerPerBrowser::GetAppIdFromLauncherIdForTest( 1107 ChromeLauncherControllerPerBrowser::GetAppIdFromLauncherIdForTest(
1112 ash::LauncherID id) { 1108 ash::LauncherID id) {
1113 return id_to_item_controller_map_[id]->app_id(); 1109 return id_to_item_controller_map_[id]->app_id();
1114 } 1110 }
1115 1111
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698