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/ash/launcher/chrome_launcher_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 app_tab_helper_.reset(new LauncherAppTabHelper(profile_)); | 168 app_tab_helper_.reset(new LauncherAppTabHelper(profile_)); |
169 app_icon_loader_.reset(new LauncherAppIconLoader(profile_, this)); | 169 app_icon_loader_.reset(new LauncherAppIconLoader(profile_, this)); |
170 | 170 |
171 notification_registrar_.Add(this, | 171 notification_registrar_.Add(this, |
172 chrome::NOTIFICATION_EXTENSION_LOADED, | 172 chrome::NOTIFICATION_EXTENSION_LOADED, |
173 content::Source<Profile>(profile_)); | 173 content::Source<Profile>(profile_)); |
174 notification_registrar_.Add(this, | 174 notification_registrar_.Add(this, |
175 chrome::NOTIFICATION_EXTENSION_UNLOADED, | 175 chrome::NOTIFICATION_EXTENSION_UNLOADED, |
176 content::Source<Profile>(profile_)); | 176 content::Source<Profile>(profile_)); |
177 pref_change_registrar_.Init(profile_->GetPrefs()); | 177 pref_change_registrar_.Init(profile_->GetPrefs()); |
178 pref_change_registrar_.Add(prefs::kPinnedLauncherApps, this); | 178 pref_change_registrar_.Add( |
179 prefs::kPinnedLauncherApps, | |
180 base::Bind(&ChromeLauncherController::UpdateAppLaunchersFromPref, | |
181 base::Unretained(this))); | |
179 } | 182 } |
180 | 183 |
181 ChromeLauncherController::~ChromeLauncherController() { | 184 ChromeLauncherController::~ChromeLauncherController() { |
182 // Reset the shell window controller here since it has a weak pointer to this. | 185 // Reset the shell window controller here since it has a weak pointer to this. |
183 shell_window_controller_.reset(); | 186 shell_window_controller_.reset(); |
184 | 187 |
185 model_->RemoveObserver(this); | 188 model_->RemoveObserver(this); |
186 for (IDToItemControllerMap::iterator i = id_to_item_controller_map_.begin(); | 189 for (IDToItemControllerMap::iterator i = id_to_item_controller_map_.begin(); |
187 i != id_to_item_controller_map_.end(); ++i) { | 190 i != id_to_item_controller_map_.end(); ++i) { |
188 i->second->OnRemoved(); | 191 i->second->OnRemoved(); |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
770 if (IsAppPinned(extension->id())) | 773 if (IsAppPinned(extension->id())) |
771 DoUnpinAppsWithID(extension->id()); | 774 DoUnpinAppsWithID(extension->id()); |
772 app_icon_loader_->ClearImage(extension->id()); | 775 app_icon_loader_->ClearImage(extension->id()); |
773 break; | 776 break; |
774 } | 777 } |
775 default: | 778 default: |
776 NOTREACHED() << "Unexpected notification type=" << type; | 779 NOTREACHED() << "Unexpected notification type=" << type; |
777 } | 780 } |
778 } | 781 } |
779 | 782 |
780 void ChromeLauncherController::OnPreferenceChanged( | |
781 PrefServiceBase* service, | |
782 const std::string& pref_name) { | |
783 if (pref_name == prefs::kPinnedLauncherApps) { | |
784 UpdateAppLaunchersFromPref(); | |
785 } else if (pref_name == prefs::kShelfAlignmentLocal) { | |
786 SetShelfAlignmentFromPrefs(); | |
Mattias Nissler (ping if slow)
2012/11/21 11:31:04
Hm, maybe the code is missing pref change notifica
Jói
2012/11/21 12:59:33
davemoore: Do you know? The code prior to this cha
sky
2012/11/29 01:49:02
See line 236 old.
| |
787 } else if (pref_name == prefs::kShelfAutoHideBehaviorLocal) { | |
788 SetShelfAutoHideBehaviorFromPrefs(); | |
789 } else { | |
790 NOTREACHED() << "Unexpected pref change for " << pref_name; | |
791 } | |
792 } | |
793 | |
794 void ChromeLauncherController::OnShelfAlignmentChanged() { | 783 void ChromeLauncherController::OnShelfAlignmentChanged() { |
795 const char* pref_value = NULL; | 784 const char* pref_value = NULL; |
796 // TODO(oshima): Support multiple displays. | 785 // TODO(oshima): Support multiple displays. |
797 switch (ash::Shell::GetInstance()->GetShelfAlignment( | 786 switch (ash::Shell::GetInstance()->GetShelfAlignment( |
798 ash::Shell::GetPrimaryRootWindow())) { | 787 ash::Shell::GetPrimaryRootWindow())) { |
799 case ash::SHELF_ALIGNMENT_BOTTOM: | 788 case ash::SHELF_ALIGNMENT_BOTTOM: |
800 pref_value = ash::kShelfAlignmentBottom; | 789 pref_value = ash::kShelfAlignmentBottom; |
801 break; | 790 break; |
802 case ash::SHELF_ALIGNMENT_LEFT: | 791 case ash::SHELF_ALIGNMENT_LEFT: |
803 pref_value = ash::kShelfAlignmentLeft; | 792 pref_value = ash::kShelfAlignmentLeft; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
852 ash::LauncherID id = model_->items()[i].id; | 841 ash::LauncherID id = model_->items()[i].id; |
853 if (HasItemController(id) && IsPinned(id)) { | 842 if (HasItemController(id) && IsPinned(id)) { |
854 base::DictionaryValue* app_value = ash::CreateAppDict( | 843 base::DictionaryValue* app_value = ash::CreateAppDict( |
855 id_to_item_controller_map_[id]->app_id()); | 844 id_to_item_controller_map_[id]->app_id()); |
856 if (app_value) | 845 if (app_value) |
857 updater->Append(app_value); | 846 updater->Append(app_value); |
858 } | 847 } |
859 } | 848 } |
860 } | 849 } |
861 } | 850 } |
862 pref_change_registrar_.Add(prefs::kPinnedLauncherApps, this); | 851 pref_change_registrar_.Add(prefs::kPinnedLauncherApps, this); |
Mattias Nissler (ping if slow)
2012/11/21 11:31:04
I think you missed this instance.
Jói
2012/11/21 12:59:33
Thanks for the catch. The trybots also failed on
| |
863 } | 852 } |
864 | 853 |
865 void ChromeLauncherController::SetAppTabHelperForTest(AppTabHelper* helper) { | 854 void ChromeLauncherController::SetAppTabHelperForTest(AppTabHelper* helper) { |
866 app_tab_helper_.reset(helper); | 855 app_tab_helper_.reset(helper); |
867 } | 856 } |
868 | 857 |
869 void ChromeLauncherController::SetAppIconLoaderForTest(AppIconLoader* loader) { | 858 void ChromeLauncherController::SetAppIconLoaderForTest(AppIconLoader* loader) { |
870 app_icon_loader_.reset(loader); | 859 app_icon_loader_.reset(loader); |
871 } | 860 } |
872 | 861 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1073 new AppShortcutLauncherItemController(app_id, this); | 1062 new AppShortcutLauncherItemController(app_id, this); |
1074 ash::LauncherID launcher_id = InsertAppLauncherItem( | 1063 ash::LauncherID launcher_id = InsertAppLauncherItem( |
1075 controller, app_id, ash::STATUS_CLOSED, index); | 1064 controller, app_id, ash::STATUS_CLOSED, index); |
1076 return launcher_id; | 1065 return launcher_id; |
1077 } | 1066 } |
1078 | 1067 |
1079 bool ChromeLauncherController::HasItemController(ash::LauncherID id) const { | 1068 bool ChromeLauncherController::HasItemController(ash::LauncherID id) const { |
1080 return id_to_item_controller_map_.find(id) != | 1069 return id_to_item_controller_map_.find(id) != |
1081 id_to_item_controller_map_.end(); | 1070 id_to_item_controller_map_.end(); |
1082 } | 1071 } |
OLD | NEW |