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

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

Issue 130983007: Creating multi profile animations for switching users and teleporting of windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Created 6 years, 10 months 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 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
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
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 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 // Switch the running applications to the new user. 1148 // Switch the running applications to the new user.
1161 shell_window_controller_->ActiveUserChanged(user_email); 1149 shell_window_controller_->ActiveUserChanged(user_email);
1162 // Update the user specific shell properties from the new user profile. 1150 // Update the user specific shell properties from the new user profile.
1163 UpdateAppLaunchersFromPref(); 1151 UpdateAppLaunchersFromPref();
1164 SetShelfAlignmentFromPrefs(); 1152 SetShelfAlignmentFromPrefs();
1165 SetShelfAutoHideBehaviorFromPrefs(); 1153 SetShelfAutoHideBehaviorFromPrefs();
1166 SetShelfBehaviorsFromPrefs(); 1154 SetShelfBehaviorsFromPrefs();
1167 // Restore the order of running, but unpinned applications for the activated 1155 // Restore the order of running, but unpinned applications for the activated
1168 // user. 1156 // user.
1169 RestoreUnpinnedRunningApplicationOrder(user_email); 1157 RestoreUnpinnedRunningApplicationOrder(user_email);
1158 // Inform the system tray of the change.
1159 ash::Shell::GetInstance()->system_tray_delegate()->ActiveUserWasChanged();
1170 } 1160 }
1171 1161
1172 void ChromeLauncherController::AdditionalUserAddedToSession(Profile* profile) { 1162 void ChromeLauncherController::AdditionalUserAddedToSession(Profile* profile) {
1173 // Switch the running applications to the new user. 1163 // Switch the running applications to the new user.
1174 shell_window_controller_->AdditionalUserAddedToSession(profile); 1164 shell_window_controller_->AdditionalUserAddedToSession(profile);
1175 } 1165 }
1176 1166
1177 void ChromeLauncherController::Observe( 1167 void ChromeLauncherController::Observe(
1178 int type, 1168 int type,
1179 const content::NotificationSource& source, 1169 const content::NotificationSource& source,
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 const char* value = NULL; 1673 const char* value = NULL;
1684 switch (behavior) { 1674 switch (behavior) {
1685 case ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: 1675 case ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS:
1686 value = ash::kShelfAutoHideBehaviorAlways; 1676 value = ash::kShelfAutoHideBehaviorAlways;
1687 break; 1677 break;
1688 case ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER: 1678 case ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER:
1689 value = ash::kShelfAutoHideBehaviorNever; 1679 value = ash::kShelfAutoHideBehaviorNever;
1690 break; 1680 break;
1691 case ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN: 1681 case ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN:
1692 // This one should not be a valid preference option for now. We only want 1682 // This one should not be a valid preference option for now. We only want
1693 // to completely hide it when we run app mode. 1683 // to completely hide it when we run in app mode - or while we temporarily
1694 NOTREACHED(); 1684 // hide the shelf as part of an animation (e.g. the multi user change).
1695 return; 1685 return;
1696 } 1686 }
1697 1687
1698 UpdatePerDisplayPref( 1688 UpdatePerDisplayPref(
1699 profile_->GetPrefs(), root_window, prefs::kShelfAutoHideBehavior, value); 1689 profile_->GetPrefs(), root_window, prefs::kShelfAutoHideBehavior, value);
1700 1690
1701 if (root_window == ash::Shell::GetPrimaryRootWindow()) { 1691 if (root_window == ash::Shell::GetPrimaryRootWindow()) {
1702 // See comment in |kShelfAlignment| about why we have two prefs here. 1692 // See comment in |kShelfAlignment| about why we have two prefs here.
1703 profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehaviorLocal, value); 1693 profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehaviorLocal, value);
1704 profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehavior, value); 1694 profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehavior, value);
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
2063 } 2053 }
2064 2054
2065 void ChromeLauncherController::ReleaseProfile() { 2055 void ChromeLauncherController::ReleaseProfile() {
2066 if (app_sync_ui_state_) 2056 if (app_sync_ui_state_)
2067 app_sync_ui_state_->RemoveObserver(this); 2057 app_sync_ui_state_->RemoveObserver(this);
2068 2058
2069 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); 2059 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this);
2070 2060
2071 pref_change_registrar_.RemoveAll(); 2061 pref_change_registrar_.RemoveAll();
2072 } 2062 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698