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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 #include "chrome/browser/ui/extensions/extension_enable_flow.h" | 60 #include "chrome/browser/ui/extensions/extension_enable_flow.h" |
61 #include "chrome/browser/ui/host_desktop.h" | 61 #include "chrome/browser/ui/host_desktop.h" |
62 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 62 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
63 #include "chrome/browser/web_applications/web_app.h" | 63 #include "chrome/browser/web_applications/web_app.h" |
64 #include "chrome/common/chrome_switches.h" | 64 #include "chrome/common/chrome_switches.h" |
65 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 65 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
66 #include "chrome/common/pref_names.h" | 66 #include "chrome/common/pref_names.h" |
67 #include "chrome/common/url_constants.h" | 67 #include "chrome/common/url_constants.h" |
68 #include "chrome/grit/generated_resources.h" | 68 #include "chrome/grit/generated_resources.h" |
69 #include "components/favicon/content/content_favicon_driver.h" | 69 #include "components/favicon/content/content_favicon_driver.h" |
| 70 #include "components/user_manager/user_id.h" |
70 #include "content/public/browser/navigation_entry.h" | 71 #include "content/public/browser/navigation_entry.h" |
71 #include "content/public/browser/notification_registrar.h" | 72 #include "content/public/browser/notification_registrar.h" |
72 #include "content/public/browser/notification_service.h" | 73 #include "content/public/browser/notification_service.h" |
73 #include "content/public/browser/web_contents.h" | 74 #include "content/public/browser/web_contents.h" |
74 #include "extensions/browser/extension_prefs.h" | 75 #include "extensions/browser/extension_prefs.h" |
75 #include "extensions/browser/extension_registry.h" | 76 #include "extensions/browser/extension_registry.h" |
76 #include "extensions/browser/extension_system.h" | 77 #include "extensions/browser/extension_system.h" |
77 #include "extensions/browser/extension_util.h" | 78 #include "extensions/browser/extension_util.h" |
78 #include "extensions/common/constants.h" | 79 #include "extensions/common/constants.h" |
79 #include "extensions/common/extension.h" | 80 #include "extensions/common/extension.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 | 309 |
309 // The owning ChromeLauncherController. | 310 // The owning ChromeLauncherController. |
310 ChromeLauncherController* controller_; | 311 ChromeLauncherController* controller_; |
311 | 312 |
312 // The notification registrar to track the Profile creations after a user got | 313 // The notification registrar to track the Profile creations after a user got |
313 // added to the session (if required). | 314 // added to the session (if required). |
314 content::NotificationRegistrar registrar_; | 315 content::NotificationRegistrar registrar_; |
315 | 316 |
316 // Users which were just added to the system, but which profiles were not yet | 317 // Users which were just added to the system, but which profiles were not yet |
317 // (fully) loaded. | 318 // (fully) loaded. |
318 std::set<std::string> added_user_ids_waiting_for_profiles_; | 319 std::set<user_manager::UserID> added_user_ids_waiting_for_profiles_; |
319 | 320 |
320 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerUserSwitchObserverChromeOS); | 321 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerUserSwitchObserverChromeOS); |
321 }; | 322 }; |
322 | 323 |
323 void ChromeLauncherControllerUserSwitchObserverChromeOS::UserAddedToSession( | 324 void ChromeLauncherControllerUserSwitchObserverChromeOS::UserAddedToSession( |
324 const user_manager::User* active_user) { | 325 const user_manager::User* active_user) { |
325 Profile* profile = multi_user_util::GetProfileFromUserID( | 326 Profile* profile = multi_user_util::GetProfileFromUserID( |
326 active_user->email()); | 327 active_user->GetUserID()); |
327 // If we do not have a profile yet, we postpone forwarding the notification | 328 // If we do not have a profile yet, we postpone forwarding the notification |
328 // until it is loaded. | 329 // until it is loaded. |
329 if (!profile) | 330 if (!profile) |
330 added_user_ids_waiting_for_profiles_.insert(active_user->email()); | 331 added_user_ids_waiting_for_profiles_.insert(active_user->GetUserID()); |
331 else | 332 else |
332 AddUser(profile); | 333 AddUser(profile); |
333 } | 334 } |
334 | 335 |
335 void ChromeLauncherControllerUserSwitchObserverChromeOS::Observe( | 336 void ChromeLauncherControllerUserSwitchObserverChromeOS::Observe( |
336 int type, | 337 int type, |
337 const content::NotificationSource& source, | 338 const content::NotificationSource& source, |
338 const content::NotificationDetails& details) { | 339 const content::NotificationDetails& details) { |
339 if (type == chrome::NOTIFICATION_PROFILE_ADDED && | 340 if (type == chrome::NOTIFICATION_PROFILE_ADDED && |
340 !added_user_ids_waiting_for_profiles_.empty()) { | 341 !added_user_ids_waiting_for_profiles_.empty()) { |
341 // Check if the profile is from a user which was on the waiting list. | 342 // Check if the profile is from a user which was on the waiting list. |
342 Profile* profile = content::Source<Profile>(source).ptr(); | 343 Profile* profile = content::Source<Profile>(source).ptr(); |
343 std::string user_id = multi_user_util::GetUserIDFromProfile(profile); | 344 user_manager::UserID user_id = multi_user_util::GetUserIDFromProfile(profile
); |
344 std::set<std::string>::iterator it = std::find( | 345 std::set<user_manager::UserID>::iterator it = std::find( |
345 added_user_ids_waiting_for_profiles_.begin(), | 346 added_user_ids_waiting_for_profiles_.begin(), |
346 added_user_ids_waiting_for_profiles_.end(), | 347 added_user_ids_waiting_for_profiles_.end(), |
347 user_id); | 348 user_id); |
348 if (it != added_user_ids_waiting_for_profiles_.end()) { | 349 if (it != added_user_ids_waiting_for_profiles_.end()) { |
349 added_user_ids_waiting_for_profiles_.erase(it); | 350 added_user_ids_waiting_for_profiles_.erase(it); |
350 AddUser(profile->GetOriginalProfile()); | 351 AddUser(profile->GetOriginalProfile()); |
351 } | 352 } |
352 } | 353 } |
353 } | 354 } |
354 | 355 |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 | 1094 |
1094 ash::ShelfItemDelegate::PerformedAction | 1095 ash::ShelfItemDelegate::PerformedAction |
1095 ChromeLauncherController::ActivateWindowOrMinimizeIfActive( | 1096 ChromeLauncherController::ActivateWindowOrMinimizeIfActive( |
1096 ui::BaseWindow* window, | 1097 ui::BaseWindow* window, |
1097 bool allow_minimize) { | 1098 bool allow_minimize) { |
1098 // In separated desktop mode we might have to teleport a window back to the | 1099 // In separated desktop mode we might have to teleport a window back to the |
1099 // current user. | 1100 // current user. |
1100 if (chrome::MultiUserWindowManager::GetMultiProfileMode() == | 1101 if (chrome::MultiUserWindowManager::GetMultiProfileMode() == |
1101 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) { | 1102 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) { |
1102 aura::Window* native_window = window->GetNativeWindow(); | 1103 aura::Window* native_window = window->GetNativeWindow(); |
1103 const std::string& current_user = | 1104 const user_manager::UserID& current_user = |
1104 multi_user_util::GetUserIDFromProfile(profile()); | 1105 multi_user_util::GetUserIDFromProfile(profile()); |
1105 chrome::MultiUserWindowManager* manager = | 1106 chrome::MultiUserWindowManager* manager = |
1106 chrome::MultiUserWindowManager::GetInstance(); | 1107 chrome::MultiUserWindowManager::GetInstance(); |
1107 if (!manager->IsWindowOnDesktopOfUser(native_window, current_user)) { | 1108 if (!manager->IsWindowOnDesktopOfUser(native_window, current_user)) { |
1108 ash::MultiProfileUMA::RecordTeleportAction( | 1109 ash::MultiProfileUMA::RecordTeleportAction( |
1109 ash::MultiProfileUMA::TELEPORT_WINDOW_RETURN_BY_LAUNCHER); | 1110 ash::MultiProfileUMA::TELEPORT_WINDOW_RETURN_BY_LAUNCHER); |
1110 manager->ShowWindowForUser(native_window, current_user); | 1111 manager->ShowWindowForUser(native_window, current_user); |
1111 window->Activate(); | 1112 window->Activate(); |
1112 return ash::ShelfItemDelegate::kExistingWindowActivated; | 1113 return ash::ShelfItemDelegate::kExistingWindowActivated; |
1113 } | 1114 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1173 | 1174 |
1174 void ChromeLauncherController::ShelfItemChanged( | 1175 void ChromeLauncherController::ShelfItemChanged( |
1175 int index, | 1176 int index, |
1176 const ash::ShelfItem& old_item) { | 1177 const ash::ShelfItem& old_item) { |
1177 } | 1178 } |
1178 | 1179 |
1179 void ChromeLauncherController::ShelfStatusChanged() { | 1180 void ChromeLauncherController::ShelfStatusChanged() { |
1180 } | 1181 } |
1181 | 1182 |
1182 void ChromeLauncherController::ActiveUserChanged( | 1183 void ChromeLauncherController::ActiveUserChanged( |
1183 const std::string& user_email) { | 1184 const user_manager::UserID& user_id) { |
1184 // Store the order of running applications for the user which gets inactive. | 1185 // Store the order of running applications for the user which gets inactive. |
1185 RememberUnpinnedRunningApplicationOrder(); | 1186 RememberUnpinnedRunningApplicationOrder(); |
1186 // Coming here the default profile is already switched. All profile specific | 1187 // Coming here the default profile is already switched. All profile specific |
1187 // resources get released and the new profile gets attached instead. | 1188 // resources get released and the new profile gets attached instead. |
1188 ReleaseProfile(); | 1189 ReleaseProfile(); |
1189 // When coming here, the active user has already be changed so that we can | 1190 // When coming here, the active user has already be changed so that we can |
1190 // set it as active. | 1191 // set it as active. |
1191 AttachProfile(ProfileManager::GetActiveUserProfile()); | 1192 AttachProfile(ProfileManager::GetActiveUserProfile()); |
1192 // Update the V1 applications. | 1193 // Update the V1 applications. |
1193 browser_status_monitor_->ActiveUserChanged(user_email); | 1194 browser_status_monitor_->ActiveUserChanged(user_id); |
1194 // Switch the running applications to the new user. | 1195 // Switch the running applications to the new user. |
1195 app_window_controller_->ActiveUserChanged(user_email); | 1196 app_window_controller_->ActiveUserChanged(user_id); |
1196 // Update the user specific shell properties from the new user profile. | 1197 // Update the user specific shell properties from the new user profile. |
1197 UpdateAppLaunchersFromPref(); | 1198 UpdateAppLaunchersFromPref(); |
1198 SetShelfAlignmentFromPrefs(); | 1199 SetShelfAlignmentFromPrefs(); |
1199 SetShelfAutoHideBehaviorFromPrefs(); | 1200 SetShelfAutoHideBehaviorFromPrefs(); |
1200 SetShelfBehaviorsFromPrefs(); | 1201 SetShelfBehaviorsFromPrefs(); |
1201 #if defined(OS_CHROMEOS) | 1202 #if defined(OS_CHROMEOS) |
1202 SetVirtualKeyboardBehaviorFromPrefs(); | 1203 SetVirtualKeyboardBehaviorFromPrefs(); |
1203 #endif // defined(OS_CHROMEOS) | 1204 #endif // defined(OS_CHROMEOS) |
1204 // Restore the order of running, but unpinned applications for the activated | 1205 // Restore the order of running, but unpinned applications for the activated |
1205 // user. | 1206 // user. |
1206 RestoreUnpinnedRunningApplicationOrder(user_email); | 1207 RestoreUnpinnedRunningApplicationOrder(user_id); |
1207 // Inform the system tray of the change. | 1208 // Inform the system tray of the change. |
1208 ash::Shell::GetInstance()->system_tray_delegate()->ActiveUserWasChanged(); | 1209 ash::Shell::GetInstance()->system_tray_delegate()->ActiveUserWasChanged(); |
1209 // Force on-screen keyboard to reset. | 1210 // Force on-screen keyboard to reset. |
1210 if (keyboard::IsKeyboardEnabled()) | 1211 if (keyboard::IsKeyboardEnabled()) |
1211 ash::Shell::GetInstance()->CreateKeyboard(); | 1212 ash::Shell::GetInstance()->CreateKeyboard(); |
1212 } | 1213 } |
1213 | 1214 |
1214 void ChromeLauncherController::AdditionalUserAddedToSession(Profile* profile) { | 1215 void ChromeLauncherController::AdditionalUserAddedToSession(Profile* profile) { |
1215 // Switch the running applications to the new user. | 1216 // Switch the running applications to the new user. |
1216 app_window_controller_->AdditionalUserAddedToSession(profile); | 1217 app_window_controller_->AdditionalUserAddedToSession(profile); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1446 for (int i = 0; i < model_->item_count(); i++) { | 1447 for (int i = 0; i < model_->item_count(); i++) { |
1447 ash::ShelfItemType type = model_->items()[i].type; | 1448 ash::ShelfItemType type = model_->items()[i].type; |
1448 if (type == ash::TYPE_WINDOWED_APP || type == ash::TYPE_PLATFORM_APP) | 1449 if (type == ash::TYPE_WINDOWED_APP || type == ash::TYPE_PLATFORM_APP) |
1449 list.push_back(GetAppIDForShelfID(model_->items()[i].id)); | 1450 list.push_back(GetAppIDForShelfID(model_->items()[i].id)); |
1450 } | 1451 } |
1451 last_used_running_application_order_[ | 1452 last_used_running_application_order_[ |
1452 multi_user_util::GetUserIDFromProfile(profile_)] = list; | 1453 multi_user_util::GetUserIDFromProfile(profile_)] = list; |
1453 } | 1454 } |
1454 | 1455 |
1455 void ChromeLauncherController::RestoreUnpinnedRunningApplicationOrder( | 1456 void ChromeLauncherController::RestoreUnpinnedRunningApplicationOrder( |
1456 const std::string& user_id) { | 1457 const user_manager::UserID& user_id) { |
1457 const RunningAppListIdMap::iterator app_id_list = | 1458 const RunningAppListIdMap::iterator app_id_list = |
1458 last_used_running_application_order_.find(user_id); | 1459 last_used_running_application_order_.find(user_id); |
1459 if (app_id_list == last_used_running_application_order_.end()) | 1460 if (app_id_list == last_used_running_application_order_.end()) |
1460 return; | 1461 return; |
1461 | 1462 |
1462 // Find the first insertion point for running applications. | 1463 // Find the first insertion point for running applications. |
1463 int running_index = model_->FirstRunningAppIndex(); | 1464 int running_index = model_->FirstRunningAppIndex(); |
1464 for (RunningAppListIds::iterator app_id = app_id_list->second.begin(); | 1465 for (RunningAppListIds::iterator app_id = app_id_list->second.begin(); |
1465 app_id != app_id_list->second.end(); ++app_id) { | 1466 app_id != app_id_list->second.end(); ++app_id) { |
1466 ash::ShelfID shelf_id = GetShelfIDForAppID(*app_id); | 1467 ash::ShelfID shelf_id = GetShelfIDForAppID(*app_id); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1499 // If running multi user mode with separate desktops, we have to check if the | 1500 // If running multi user mode with separate desktops, we have to check if the |
1500 // browser is from the active user. | 1501 // browser is from the active user. |
1501 if (chrome::MultiUserWindowManager::GetMultiProfileMode() != | 1502 if (chrome::MultiUserWindowManager::GetMultiProfileMode() != |
1502 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) | 1503 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) |
1503 return true; | 1504 return true; |
1504 return multi_user_util::IsProfileFromActiveUser(browser->profile()); | 1505 return multi_user_util::IsProfileFromActiveUser(browser->profile()); |
1505 } | 1506 } |
1506 | 1507 |
1507 bool ChromeLauncherController::ShelfBoundsChangesProbablyWithUser( | 1508 bool ChromeLauncherController::ShelfBoundsChangesProbablyWithUser( |
1508 aura::Window* root_window, | 1509 aura::Window* root_window, |
1509 const std::string& user_id) const { | 1510 const user_manager::UserID& user_id) const { |
1510 Profile* other_profile = multi_user_util::GetProfileFromUserID(user_id); | 1511 Profile* other_profile = multi_user_util::GetProfileFromUserID(user_id); |
1511 DCHECK_NE(other_profile, profile_); | 1512 DCHECK_NE(other_profile, profile_); |
1512 | 1513 |
1513 // Note: The Auto hide state from preferences is not the same as the actual | 1514 // Note: The Auto hide state from preferences is not the same as the actual |
1514 // visibility of the shelf. Depending on all the various states (full screen, | 1515 // visibility of the shelf. Depending on all the various states (full screen, |
1515 // no window on desktop, multi user, ..) the shelf could be shown - or not. | 1516 // no window on desktop, multi user, ..) the shelf could be shown - or not. |
1516 bool currently_shown = ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER == | 1517 bool currently_shown = ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER == |
1517 GetShelfAutoHideBehaviorFromPrefs(profile_, root_window); | 1518 GetShelfAutoHideBehaviorFromPrefs(profile_, root_window); |
1518 bool other_shown = ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER == | 1519 bool other_shown = ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER == |
1519 GetShelfAutoHideBehaviorFromPrefs(other_profile, root_window); | 1520 GetShelfAutoHideBehaviorFromPrefs(other_profile, root_window); |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2139 void ChromeLauncherController::ReleaseProfile() { | 2140 void ChromeLauncherController::ReleaseProfile() { |
2140 if (app_sync_ui_state_) | 2141 if (app_sync_ui_state_) |
2141 app_sync_ui_state_->RemoveObserver(this); | 2142 app_sync_ui_state_->RemoveObserver(this); |
2142 | 2143 |
2143 extensions::ExtensionRegistry::Get(profile_)->RemoveObserver(this); | 2144 extensions::ExtensionRegistry::Get(profile_)->RemoveObserver(this); |
2144 | 2145 |
2145 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); | 2146 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); |
2146 | 2147 |
2147 pref_change_registrar_.RemoveAll(); | 2148 pref_change_registrar_.RemoveAll(); |
2148 } | 2149 } |
OLD | NEW |