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

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

Issue 1428213004: This CL replaces std::string user_id in ash/* with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update after review. Created 5 years, 1 month 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
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"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #include "chrome/browser/ui/extensions/extension_enable_flow.h" 61 #include "chrome/browser/ui/extensions/extension_enable_flow.h"
62 #include "chrome/browser/ui/host_desktop.h" 62 #include "chrome/browser/ui/host_desktop.h"
63 #include "chrome/browser/ui/tabs/tab_strip_model.h" 63 #include "chrome/browser/ui/tabs/tab_strip_model.h"
64 #include "chrome/browser/web_applications/web_app.h" 64 #include "chrome/browser/web_applications/web_app.h"
65 #include "chrome/common/chrome_switches.h" 65 #include "chrome/common/chrome_switches.h"
66 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 66 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
67 #include "chrome/common/pref_names.h" 67 #include "chrome/common/pref_names.h"
68 #include "chrome/common/url_constants.h" 68 #include "chrome/common/url_constants.h"
69 #include "chrome/grit/generated_resources.h" 69 #include "chrome/grit/generated_resources.h"
70 #include "components/favicon/content/content_favicon_driver.h" 70 #include "components/favicon/content/content_favicon_driver.h"
71 #include "components/signin/core/account_id/account_id.h"
71 #include "components/syncable_prefs/pref_service_syncable.h" 72 #include "components/syncable_prefs/pref_service_syncable.h"
72 #include "content/public/browser/navigation_entry.h" 73 #include "content/public/browser/navigation_entry.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"
80 #include "extensions/common/extension_resource.h" 81 #include "extensions/common/extension_resource.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 304
304 // Users which were just added to the system, but which profiles were not yet 305 // Users which were just added to the system, but which profiles were not yet
305 // (fully) loaded. 306 // (fully) loaded.
306 std::set<std::string> added_user_ids_waiting_for_profiles_; 307 std::set<std::string> added_user_ids_waiting_for_profiles_;
307 308
308 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerUserSwitchObserver); 309 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerUserSwitchObserver);
309 }; 310 };
310 311
311 void ChromeLauncherControllerUserSwitchObserver::UserAddedToSession( 312 void ChromeLauncherControllerUserSwitchObserver::UserAddedToSession(
312 const user_manager::User* active_user) { 313 const user_manager::User* active_user) {
313 Profile* profile = multi_user_util::GetProfileFromUserID( 314 Profile* profile =
314 active_user->email()); 315 multi_user_util::GetProfileFromAccountId(active_user->GetAccountId());
315 // If we do not have a profile yet, we postpone forwarding the notification 316 // If we do not have a profile yet, we postpone forwarding the notification
316 // until it is loaded. 317 // until it is loaded.
317 if (!profile) 318 if (!profile)
318 added_user_ids_waiting_for_profiles_.insert(active_user->email()); 319 added_user_ids_waiting_for_profiles_.insert(active_user->email());
319 else 320 else
320 AddUser(profile); 321 AddUser(profile);
321 } 322 }
322 323
323 void ChromeLauncherControllerUserSwitchObserver::OnUserProfileReadyToSwitch( 324 void ChromeLauncherControllerUserSwitchObserver::OnUserProfileReadyToSwitch(
324 Profile* profile) { 325 Profile* profile) {
325 if (!added_user_ids_waiting_for_profiles_.empty()) { 326 if (!added_user_ids_waiting_for_profiles_.empty()) {
326 // Check if the profile is from a user which was on the waiting list. 327 // Check if the profile is from a user which was on the waiting list.
327 std::string user_id = multi_user_util::GetUserIDFromProfile(profile); 328 std::string user_id =
329 multi_user_util::GetAccountIdFromProfile(profile).GetUserEmail();
328 std::set<std::string>::iterator it = std::find( 330 std::set<std::string>::iterator it = std::find(
329 added_user_ids_waiting_for_profiles_.begin(), 331 added_user_ids_waiting_for_profiles_.begin(),
330 added_user_ids_waiting_for_profiles_.end(), 332 added_user_ids_waiting_for_profiles_.end(),
331 user_id); 333 user_id);
332 if (it != added_user_ids_waiting_for_profiles_.end()) { 334 if (it != added_user_ids_waiting_for_profiles_.end()) {
333 added_user_ids_waiting_for_profiles_.erase(it); 335 added_user_ids_waiting_for_profiles_.erase(it);
334 AddUser(profile->GetOriginalProfile()); 336 AddUser(profile->GetOriginalProfile());
335 } 337 }
336 } 338 }
337 } 339 }
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 1051
1050 ash::ShelfItemDelegate::PerformedAction 1052 ash::ShelfItemDelegate::PerformedAction
1051 ChromeLauncherController::ActivateWindowOrMinimizeIfActive( 1053 ChromeLauncherController::ActivateWindowOrMinimizeIfActive(
1052 ui::BaseWindow* window, 1054 ui::BaseWindow* window,
1053 bool allow_minimize) { 1055 bool allow_minimize) {
1054 // In separated desktop mode we might have to teleport a window back to the 1056 // In separated desktop mode we might have to teleport a window back to the
1055 // current user. 1057 // current user.
1056 if (chrome::MultiUserWindowManager::GetMultiProfileMode() == 1058 if (chrome::MultiUserWindowManager::GetMultiProfileMode() ==
1057 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) { 1059 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) {
1058 aura::Window* native_window = window->GetNativeWindow(); 1060 aura::Window* native_window = window->GetNativeWindow();
1059 const std::string& current_user = 1061 const AccountId& current_account_id =
1060 multi_user_util::GetUserIDFromProfile(profile()); 1062 multi_user_util::GetAccountIdFromProfile(profile());
1061 chrome::MultiUserWindowManager* manager = 1063 chrome::MultiUserWindowManager* manager =
1062 chrome::MultiUserWindowManager::GetInstance(); 1064 chrome::MultiUserWindowManager::GetInstance();
1063 if (!manager->IsWindowOnDesktopOfUser(native_window, current_user)) { 1065 if (!manager->IsWindowOnDesktopOfUser(native_window, current_account_id)) {
1064 ash::MultiProfileUMA::RecordTeleportAction( 1066 ash::MultiProfileUMA::RecordTeleportAction(
1065 ash::MultiProfileUMA::TELEPORT_WINDOW_RETURN_BY_LAUNCHER); 1067 ash::MultiProfileUMA::TELEPORT_WINDOW_RETURN_BY_LAUNCHER);
1066 manager->ShowWindowForUser(native_window, current_user); 1068 manager->ShowWindowForUser(native_window, current_account_id);
1067 window->Activate(); 1069 window->Activate();
1068 return ash::ShelfItemDelegate::kExistingWindowActivated; 1070 return ash::ShelfItemDelegate::kExistingWindowActivated;
1069 } 1071 }
1070 } 1072 }
1071 1073
1072 if (window->IsActive() && allow_minimize) { 1074 if (window->IsActive() && allow_minimize) {
1073 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1075 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1074 switches::kDisableMinimizeOnSecondLauncherItemClick)) { 1076 switches::kDisableMinimizeOnSecondLauncherItemClick)) {
1075 AnimateWindow(window->GetNativeWindow(), 1077 AnimateWindow(window->GetNativeWindow(),
1076 wm::WINDOW_ANIMATION_TYPE_BOUNCE); 1078 wm::WINDOW_ANIMATION_TYPE_BOUNCE);
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 item_delegate_manager_->AddObserver(this); 1401 item_delegate_manager_->AddObserver(this);
1400 } 1402 }
1401 1403
1402 void ChromeLauncherController::RememberUnpinnedRunningApplicationOrder() { 1404 void ChromeLauncherController::RememberUnpinnedRunningApplicationOrder() {
1403 RunningAppListIds list; 1405 RunningAppListIds list;
1404 for (int i = 0; i < model_->item_count(); i++) { 1406 for (int i = 0; i < model_->item_count(); i++) {
1405 ash::ShelfItemType type = model_->items()[i].type; 1407 ash::ShelfItemType type = model_->items()[i].type;
1406 if (type == ash::TYPE_WINDOWED_APP || type == ash::TYPE_PLATFORM_APP) 1408 if (type == ash::TYPE_WINDOWED_APP || type == ash::TYPE_PLATFORM_APP)
1407 list.push_back(GetAppIDForShelfID(model_->items()[i].id)); 1409 list.push_back(GetAppIDForShelfID(model_->items()[i].id));
1408 } 1410 }
1409 last_used_running_application_order_[ 1411 const std::string user_email =
1410 multi_user_util::GetUserIDFromProfile(profile_)] = list; 1412 multi_user_util::GetAccountIdFromProfile(profile_).GetUserEmail();
1413 last_used_running_application_order_[user_email] = list;
1411 } 1414 }
1412 1415
1413 void ChromeLauncherController::RestoreUnpinnedRunningApplicationOrder( 1416 void ChromeLauncherController::RestoreUnpinnedRunningApplicationOrder(
1414 const std::string& user_id) { 1417 const std::string& user_id) {
1415 const RunningAppListIdMap::iterator app_id_list = 1418 const RunningAppListIdMap::iterator app_id_list =
1416 last_used_running_application_order_.find(user_id); 1419 last_used_running_application_order_.find(user_id);
1417 if (app_id_list == last_used_running_application_order_.end()) 1420 if (app_id_list == last_used_running_application_order_.end())
1418 return; 1421 return;
1419 1422
1420 // Find the first insertion point for running applications. 1423 // Find the first insertion point for running applications.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 // browser is from the active user. 1461 // browser is from the active user.
1459 if (chrome::MultiUserWindowManager::GetMultiProfileMode() != 1462 if (chrome::MultiUserWindowManager::GetMultiProfileMode() !=
1460 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) 1463 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED)
1461 return true; 1464 return true;
1462 return multi_user_util::IsProfileFromActiveUser(browser->profile()); 1465 return multi_user_util::IsProfileFromActiveUser(browser->profile());
1463 } 1466 }
1464 1467
1465 bool ChromeLauncherController::ShelfBoundsChangesProbablyWithUser( 1468 bool ChromeLauncherController::ShelfBoundsChangesProbablyWithUser(
1466 aura::Window* root_window, 1469 aura::Window* root_window,
1467 const std::string& user_id) const { 1470 const std::string& user_id) const {
1468 Profile* other_profile = multi_user_util::GetProfileFromUserID(user_id); 1471 Profile* other_profile = multi_user_util::GetProfileFromAccountId(
1472 AccountId::FromUserEmail(user_id));
1469 DCHECK_NE(other_profile, profile_); 1473 DCHECK_NE(other_profile, profile_);
1470 1474
1471 // Note: The Auto hide state from preferences is not the same as the actual 1475 // Note: The Auto hide state from preferences is not the same as the actual
1472 // visibility of the shelf. Depending on all the various states (full screen, 1476 // visibility of the shelf. Depending on all the various states (full screen,
1473 // no window on desktop, multi user, ..) the shelf could be shown - or not. 1477 // no window on desktop, multi user, ..) the shelf could be shown - or not.
1474 bool currently_shown = ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER == 1478 bool currently_shown = ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER ==
1475 GetShelfAutoHideBehaviorFromPrefs(profile_, root_window); 1479 GetShelfAutoHideBehaviorFromPrefs(profile_, root_window);
1476 bool other_shown = ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER == 1480 bool other_shown = ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER ==
1477 GetShelfAutoHideBehaviorFromPrefs(other_profile, root_window); 1481 GetShelfAutoHideBehaviorFromPrefs(other_profile, root_window);
1478 1482
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
2105 void ChromeLauncherController::ReleaseProfile() { 2109 void ChromeLauncherController::ReleaseProfile() {
2106 if (app_sync_ui_state_) 2110 if (app_sync_ui_state_)
2107 app_sync_ui_state_->RemoveObserver(this); 2111 app_sync_ui_state_->RemoveObserver(this);
2108 2112
2109 extensions::ExtensionRegistry::Get(profile_)->RemoveObserver(this); 2113 extensions::ExtensionRegistry::Get(profile_)->RemoveObserver(this);
2110 2114
2111 PrefServiceSyncableFromProfile(profile_)->RemoveObserver(this); 2115 PrefServiceSyncableFromProfile(profile_)->RemoveObserver(this);
2112 2116
2113 pref_change_registrar_.RemoveAll(); 2117 pref_change_registrar_.RemoveAll();
2114 } 2118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698