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" |
11 #include "ash/multi_profile_uma.h" | 11 #include "ash/multi_profile_uma.h" |
12 #include "ash/root_window_controller.h" | 12 #include "ash/root_window_controller.h" |
13 #include "ash/shelf/shelf.h" | 13 #include "ash/shelf/shelf.h" |
14 #include "ash/shelf/shelf_item_delegate_manager.h" | 14 #include "ash/shelf/shelf_item_delegate_manager.h" |
15 #include "ash/shelf/shelf_layout_manager.h" | 15 #include "ash/shelf/shelf_layout_manager.h" |
16 #include "ash/shelf/shelf_model.h" | 16 #include "ash/shelf/shelf_model.h" |
17 #include "ash/shelf/shelf_widget.h" | 17 #include "ash/shelf/shelf_widget.h" |
18 #include "ash/shell.h" | 18 #include "ash/shell.h" |
| 19 #include "ash/system/tray/system_tray_delegate.h" |
19 #include "ash/wm/window_util.h" | 20 #include "ash/wm/window_util.h" |
20 #include "base/command_line.h" | 21 #include "base/command_line.h" |
21 #include "base/prefs/scoped_user_pref_update.h" | 22 #include "base/prefs/scoped_user_pref_update.h" |
22 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
23 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
24 #include "base/values.h" | 25 #include "base/values.h" |
25 #include "chrome/browser/app_mode/app_mode_utils.h" | 26 #include "chrome/browser/app_mode/app_mode_utils.h" |
26 #include "chrome/browser/chrome_notification_types.h" | 27 #include "chrome/browser/chrome_notification_types.h" |
27 #include "chrome/browser/defaults.h" | 28 #include "chrome/browser/defaults.h" |
28 #include "chrome/browser/extensions/app_icon_loader_impl.h" | 29 #include "chrome/browser/extensions/app_icon_loader_impl.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 #include "grit/ui_resources.h" | 81 #include "grit/ui_resources.h" |
81 #include "net/base/url_util.h" | 82 #include "net/base/url_util.h" |
82 #include "ui/aura/root_window.h" | 83 #include "ui/aura/root_window.h" |
83 #include "ui/aura/window.h" | 84 #include "ui/aura/window.h" |
84 #include "ui/base/l10n/l10n_util.h" | 85 #include "ui/base/l10n/l10n_util.h" |
85 #include "ui/views/corewm/window_animations.h" | 86 #include "ui/views/corewm/window_animations.h" |
86 | 87 |
87 #if defined(OS_CHROMEOS) | 88 #if defined(OS_CHROMEOS) |
88 #include "chrome/browser/browser_process.h" | 89 #include "chrome/browser/browser_process.h" |
89 #include "chrome/browser/chromeos/login/user_manager.h" | 90 #include "chrome/browser/chromeos/login/user_manager.h" |
90 #include "chrome/browser/chromeos/login/wallpaper_manager.h" | |
91 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" | 91 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" |
92 #include "chrome/browser/ui/ash/launcher/multi_profile_browser_status_monitor.h" | 92 #include "chrome/browser/ui/ash/launcher/multi_profile_browser_status_monitor.h" |
93 #include "chrome/browser/ui/ash/launcher/multi_profile_shell_window_launcher_con
troller.h" | 93 #include "chrome/browser/ui/ash/launcher/multi_profile_shell_window_launcher_con
troller.h" |
94 #endif | 94 #endif |
95 | 95 |
96 using extensions::Extension; | 96 using extensions::Extension; |
97 using extensions::UnloadedExtensionInfo; | 97 using extensions::UnloadedExtensionInfo; |
98 using extension_misc::kGmailAppId; | 98 using extension_misc::kGmailAppId; |
99 using content::WebContents; | 99 using content::WebContents; |
100 | 100 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 // to postpone the notification until the ProfileManager lets us know that | 236 // to postpone the notification until the ProfileManager lets us know that |
237 // the profile for that newly added user was added to the ProfileManager. | 237 // the profile for that newly added user was added to the ProfileManager. |
238 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED, | 238 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED, |
239 content::NotificationService::AllSources()); | 239 content::NotificationService::AllSources()); |
240 } | 240 } |
241 virtual ~ChromeLauncherControllerUserSwitchObserverChromeOS() { | 241 virtual ~ChromeLauncherControllerUserSwitchObserverChromeOS() { |
242 chromeos::UserManager::Get()->RemoveSessionStateObserver(this); | 242 chromeos::UserManager::Get()->RemoveSessionStateObserver(this); |
243 } | 243 } |
244 | 244 |
245 // chromeos::UserManager::UserSessionStateObserver overrides: | 245 // chromeos::UserManager::UserSessionStateObserver overrides: |
246 virtual void ActiveUserChanged(const chromeos::User* active_user) OVERRIDE; | |
247 virtual void UserAddedToSession(const chromeos::User* added_user) OVERRIDE; | 246 virtual void UserAddedToSession(const chromeos::User* added_user) OVERRIDE; |
248 | 247 |
249 // content::NotificationObserver overrides: | 248 // content::NotificationObserver overrides: |
250 virtual void Observe(int type, | 249 virtual void Observe(int type, |
251 const content::NotificationSource& source, | 250 const content::NotificationSource& source, |
252 const content::NotificationDetails& details) OVERRIDE; | 251 const content::NotificationDetails& details) OVERRIDE; |
253 | 252 |
254 private: | 253 private: |
255 // Add a user to the session. | 254 // Add a user to the session. |
256 void AddUser(Profile* profile); | 255 void AddUser(Profile* profile); |
257 | 256 |
258 // The owning ChromeLauncherController. | 257 // The owning ChromeLauncherController. |
259 ChromeLauncherController* controller_; | 258 ChromeLauncherController* controller_; |
260 | 259 |
261 // The notification registrar to track the Profile creations after a user got | 260 // The notification registrar to track the Profile creations after a user got |
262 // added to the session (if required). | 261 // added to the session (if required). |
263 content::NotificationRegistrar registrar_; | 262 content::NotificationRegistrar registrar_; |
264 | 263 |
265 // Users which were just added to the system, but which profiles were not yet | 264 // Users which were just added to the system, but which profiles were not yet |
266 // (fully) loaded. | 265 // (fully) loaded. |
267 std::set<std::string> added_user_ids_waiting_for_profiles_; | 266 std::set<std::string> added_user_ids_waiting_for_profiles_; |
268 | 267 |
269 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerUserSwitchObserverChromeOS); | 268 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerUserSwitchObserverChromeOS); |
270 }; | 269 }; |
271 | 270 |
272 void ChromeLauncherControllerUserSwitchObserverChromeOS::ActiveUserChanged( | |
273 const chromeos::User* active_user) { | |
274 const std::string& user_email = active_user->email(); | |
275 // Forward the OS specific event to the ChromeLauncherController. | |
276 controller_->ActiveUserChanged(user_email); | |
277 // TODO(skuhne): At the moment the login screen does the wallpaper management | |
278 // and wallpapers are not synchronized across multiple desktops. | |
279 if (chromeos::WallpaperManager::Get()) | |
280 chromeos::WallpaperManager::Get()->SetUserWallpaperDelayed(user_email); | |
281 } | |
282 | |
283 void ChromeLauncherControllerUserSwitchObserverChromeOS::UserAddedToSession( | 271 void ChromeLauncherControllerUserSwitchObserverChromeOS::UserAddedToSession( |
284 const chromeos::User* active_user) { | 272 const chromeos::User* active_user) { |
285 Profile* profile = multi_user_util::GetProfileFromUserID( | 273 Profile* profile = multi_user_util::GetProfileFromUserID( |
286 active_user->email()); | 274 active_user->email()); |
287 // If we do not have a profile yet, we postpone forwarding the notification | 275 // If we do not have a profile yet, we postpone forwarding the notification |
288 // until it is loaded. | 276 // until it is loaded. |
289 if (!profile) | 277 if (!profile) |
290 added_user_ids_waiting_for_profiles_.insert(active_user->email()); | 278 added_user_ids_waiting_for_profiles_.insert(active_user->email()); |
291 else | 279 else |
292 AddUser(profile); | 280 AddUser(profile); |
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 // Switch the running applications to the new user. | 1150 // Switch the running applications to the new user. |
1163 shell_window_controller_->ActiveUserChanged(user_email); | 1151 shell_window_controller_->ActiveUserChanged(user_email); |
1164 // Update the user specific shell properties from the new user profile. | 1152 // Update the user specific shell properties from the new user profile. |
1165 UpdateAppLaunchersFromPref(); | 1153 UpdateAppLaunchersFromPref(); |
1166 SetShelfAlignmentFromPrefs(); | 1154 SetShelfAlignmentFromPrefs(); |
1167 SetShelfAutoHideBehaviorFromPrefs(); | 1155 SetShelfAutoHideBehaviorFromPrefs(); |
1168 SetShelfBehaviorsFromPrefs(); | 1156 SetShelfBehaviorsFromPrefs(); |
1169 // Restore the order of running, but unpinned applications for the activated | 1157 // Restore the order of running, but unpinned applications for the activated |
1170 // user. | 1158 // user. |
1171 RestoreUnpinnedRunningApplicationOrder(user_email); | 1159 RestoreUnpinnedRunningApplicationOrder(user_email); |
| 1160 // Inform the system tray of the change. |
| 1161 ash::Shell::GetInstance()->system_tray_delegate()->ActiveUserChanged(); |
1172 } | 1162 } |
1173 | 1163 |
1174 void ChromeLauncherController::AdditionalUserAddedToSession(Profile* profile) { | 1164 void ChromeLauncherController::AdditionalUserAddedToSession(Profile* profile) { |
1175 // Switch the running applications to the new user. | 1165 // Switch the running applications to the new user. |
1176 shell_window_controller_->AdditionalUserAddedToSession(profile); | 1166 shell_window_controller_->AdditionalUserAddedToSession(profile); |
1177 } | 1167 } |
1178 | 1168 |
1179 void ChromeLauncherController::Observe( | 1169 void ChromeLauncherController::Observe( |
1180 int type, | 1170 int type, |
1181 const content::NotificationSource& source, | 1171 const content::NotificationSource& source, |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1685 const char* value = NULL; | 1675 const char* value = NULL; |
1686 switch (behavior) { | 1676 switch (behavior) { |
1687 case ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: | 1677 case ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: |
1688 value = ash::kShelfAutoHideBehaviorAlways; | 1678 value = ash::kShelfAutoHideBehaviorAlways; |
1689 break; | 1679 break; |
1690 case ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER: | 1680 case ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER: |
1691 value = ash::kShelfAutoHideBehaviorNever; | 1681 value = ash::kShelfAutoHideBehaviorNever; |
1692 break; | 1682 break; |
1693 case ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN: | 1683 case ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN: |
1694 // This one should not be a valid preference option for now. We only want | 1684 // This one should not be a valid preference option for now. We only want |
1695 // to completely hide it when we run app mode. | 1685 // to completely hide it when we run in app mode - or while we temporarily |
1696 NOTREACHED(); | 1686 // hide the shelf as part of an animation (e.g. the multi user change). |
1697 return; | 1687 return; |
1698 } | 1688 } |
1699 | 1689 |
1700 UpdatePerDisplayPref( | 1690 UpdatePerDisplayPref( |
1701 profile_->GetPrefs(), root_window, prefs::kShelfAutoHideBehavior, value); | 1691 profile_->GetPrefs(), root_window, prefs::kShelfAutoHideBehavior, value); |
1702 | 1692 |
1703 if (root_window == ash::Shell::GetPrimaryRootWindow()) { | 1693 if (root_window == ash::Shell::GetPrimaryRootWindow()) { |
1704 // See comment in |kShelfAlignment| about why we have two prefs here. | 1694 // See comment in |kShelfAlignment| about why we have two prefs here. |
1705 profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehaviorLocal, value); | 1695 profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehaviorLocal, value); |
1706 profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehavior, value); | 1696 profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehavior, value); |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2065 } | 2055 } |
2066 | 2056 |
2067 void ChromeLauncherController::ReleaseProfile() { | 2057 void ChromeLauncherController::ReleaseProfile() { |
2068 if (app_sync_ui_state_) | 2058 if (app_sync_ui_state_) |
2069 app_sync_ui_state_->RemoveObserver(this); | 2059 app_sync_ui_state_->RemoveObserver(this); |
2070 | 2060 |
2071 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); | 2061 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); |
2072 | 2062 |
2073 pref_change_registrar_.RemoveAll(); | 2063 pref_change_registrar_.RemoveAll(); |
2074 } | 2064 } |
OLD | NEW |