OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/desktop_background/desktop_background_controller.h" | 10 #include "ash/desktop_background/desktop_background_controller.h" |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 #endif | 375 #endif |
376 | 376 |
377 // Right now ash::Shell isn't created for tests. | 377 // Right now ash::Shell isn't created for tests. |
378 // TODO(mukai): Allows it to observe display change and write tests. | 378 // TODO(mukai): Allows it to observe display change and write tests. |
379 if (ash::Shell::HasInstance()) { | 379 if (ash::Shell::HasInstance()) { |
380 ash::Shell::GetInstance()->display_controller()->AddObserver(this); | 380 ash::Shell::GetInstance()->display_controller()->AddObserver(this); |
381 item_delegate_manager_ = | 381 item_delegate_manager_ = |
382 ash::Shell::GetInstance()->shelf_item_delegate_manager(); | 382 ash::Shell::GetInstance()->shelf_item_delegate_manager(); |
383 } | 383 } |
384 | 384 |
385 notification_registrar_.Add(this, | |
386 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, | |
387 content::Source<Profile>(profile_)); | |
388 notification_registrar_.Add( | 385 notification_registrar_.Add( |
389 this, | 386 this, |
390 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 387 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 388 content::Source<Profile>(profile_)); |
| 389 notification_registrar_.Add( |
| 390 this, |
| 391 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
391 content::Source<Profile>(profile_)); | 392 content::Source<Profile>(profile_)); |
392 } | 393 } |
393 | 394 |
394 ChromeLauncherController::~ChromeLauncherController() { | 395 ChromeLauncherController::~ChromeLauncherController() { |
395 // Reset the BrowserStatusMonitor as it has a weak pointer to this. | 396 // Reset the BrowserStatusMonitor as it has a weak pointer to this. |
396 browser_status_monitor_.reset(); | 397 browser_status_monitor_.reset(); |
397 | 398 |
398 // Reset the app window controller here since it has a weak pointer to this. | 399 // Reset the app window controller here since it has a weak pointer to this. |
399 app_window_controller_.reset(); | 400 app_window_controller_.reset(); |
400 | 401 |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 void ChromeLauncherController::AdditionalUserAddedToSession(Profile* profile) { | 1149 void ChromeLauncherController::AdditionalUserAddedToSession(Profile* profile) { |
1149 // Switch the running applications to the new user. | 1150 // Switch the running applications to the new user. |
1150 app_window_controller_->AdditionalUserAddedToSession(profile); | 1151 app_window_controller_->AdditionalUserAddedToSession(profile); |
1151 } | 1152 } |
1152 | 1153 |
1153 void ChromeLauncherController::Observe( | 1154 void ChromeLauncherController::Observe( |
1154 int type, | 1155 int type, |
1155 const content::NotificationSource& source, | 1156 const content::NotificationSource& source, |
1156 const content::NotificationDetails& details) { | 1157 const content::NotificationDetails& details) { |
1157 switch (type) { | 1158 switch (type) { |
1158 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: { | 1159 case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: { |
1159 const Extension* extension = | 1160 const Extension* extension = |
1160 content::Details<const Extension>(details).ptr(); | 1161 content::Details<const Extension>(details).ptr(); |
1161 if (IsAppPinned(extension->id())) { | 1162 if (IsAppPinned(extension->id())) { |
1162 // Clear and re-fetch to ensure icon is up-to-date. | 1163 // Clear and re-fetch to ensure icon is up-to-date. |
1163 app_icon_loader_->ClearImage(extension->id()); | 1164 app_icon_loader_->ClearImage(extension->id()); |
1164 app_icon_loader_->FetchImage(extension->id()); | 1165 app_icon_loader_->FetchImage(extension->id()); |
1165 } | 1166 } |
1166 | 1167 |
1167 UpdateAppLaunchersFromPref(); | 1168 UpdateAppLaunchersFromPref(); |
1168 break; | 1169 break; |
1169 } | 1170 } |
1170 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { | 1171 case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { |
1171 const content::Details<UnloadedExtensionInfo>& unload_info(details); | 1172 const content::Details<UnloadedExtensionInfo>& unload_info(details); |
1172 const Extension* extension = unload_info->extension; | 1173 const Extension* extension = unload_info->extension; |
1173 const std::string& id = extension->id(); | 1174 const std::string& id = extension->id(); |
1174 // Since we might have windowed apps of this type which might have | 1175 // Since we might have windowed apps of this type which might have |
1175 // outstanding locks which needs to be removed. | 1176 // outstanding locks which needs to be removed. |
1176 if (GetShelfIDForAppID(id) && | 1177 if (GetShelfIDForAppID(id) && |
1177 unload_info->reason == UnloadedExtensionInfo::REASON_UNINSTALL) { | 1178 unload_info->reason == UnloadedExtensionInfo::REASON_UNINSTALL) { |
1178 CloseWindowedAppsFromRemovedExtension(id); | 1179 CloseWindowedAppsFromRemovedExtension(id); |
1179 } | 1180 } |
1180 | 1181 |
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2061 } | 2062 } |
2062 | 2063 |
2063 void ChromeLauncherController::ReleaseProfile() { | 2064 void ChromeLauncherController::ReleaseProfile() { |
2064 if (app_sync_ui_state_) | 2065 if (app_sync_ui_state_) |
2065 app_sync_ui_state_->RemoveObserver(this); | 2066 app_sync_ui_state_->RemoveObserver(this); |
2066 | 2067 |
2067 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); | 2068 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); |
2068 | 2069 |
2069 pref_change_registrar_.RemoveAll(); | 2070 pref_change_registrar_.RemoveAll(); |
2070 } | 2071 } |
OLD | NEW |