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

Unified Diff: chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc
diff --git a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc
index 0535f8cbc5be840ba29a1206092fbc1840e2fa8e..c3175bae152ea9f63f170d86cea3539a82a1c6e2 100644
--- a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc
+++ b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc
@@ -30,6 +30,7 @@
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
+#include "components/user_manager/user_id.h"
#include "content/public/browser/notification_service.h"
#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/app_window/app_window_registry.h"
@@ -191,7 +192,7 @@ class AnimationSetter {
// window observer will take care of that.
class AppObserver : public extensions::AppWindowRegistry::Observer {
public:
- explicit AppObserver(const std::string& user_id) : user_id_(user_id) {}
+ explicit AppObserver(const user_manager::UserID& user_id) : user_id_(user_id) {}
~AppObserver() override {}
// AppWindowRegistry::Observer overrides:
@@ -203,14 +204,15 @@ class AppObserver : public extensions::AppWindowRegistry::Observer {
}
private:
- std::string user_id_;
+ const user_manager::UserID user_id_;
DISALLOW_COPY_AND_ASSIGN(AppObserver);
};
MultiUserWindowManagerChromeOS::MultiUserWindowManagerChromeOS(
- const std::string& current_user_id)
+ const user_manager::UserID& current_user_id)
: current_user_id_(current_user_id),
+ null_user_id_(std::string(), std::string()),
notification_blocker_(new MultiUserNotificationBlockerChromeOS(
message_center::MessageCenter::Get(), current_user_id)),
suppress_visibility_changes_(false),
@@ -275,7 +277,7 @@ void MultiUserWindowManagerChromeOS::Init() {
void MultiUserWindowManagerChromeOS::SetWindowOwner(
aura::Window* window,
- const std::string& user_id) {
+ const user_manager::UserID& user_id) {
// Make sure the window is valid and there was no owner yet.
DCHECK(window);
DCHECK(!user_id.empty());
@@ -307,17 +309,17 @@ void MultiUserWindowManagerChromeOS::SetWindowOwner(
SetWindowVisibility(window, false, 0);
}
-const std::string& MultiUserWindowManagerChromeOS::GetWindowOwner(
+const user_manager::UserID& MultiUserWindowManagerChromeOS::GetWindowOwner(
aura::Window* window) const {
WindowToEntryMap::const_iterator it = window_to_entry_.find(window);
return it != window_to_entry_.end() ? it->second->owner()
- : base::EmptyString();
+ : user_manager::EmptyUserID();
}
void MultiUserWindowManagerChromeOS::ShowWindowForUser(
aura::Window* window,
- const std::string& user_id) {
- std::string previous_owner(GetUserPresentingWindow(window));
+ const user_manager::UserID& user_id) {
+ user_manager::UserID previous_owner(GetUserPresentingWindow(window));
if (!ShowWindowForUserIntern(window, user_id))
return;
// The window switched to a new desktop and we have to switch to that desktop,
@@ -340,7 +342,7 @@ bool MultiUserWindowManagerChromeOS::AreWindowsSharedAmongUsers() const {
}
void MultiUserWindowManagerChromeOS::GetOwnersOfVisibleWindows(
- std::set<std::string>* user_ids) const {
+ std::set<user_manager::UserID>* user_ids) const {
for (WindowToEntryMap::const_iterator it = window_to_entry_.begin();
it != window_to_entry_.end();
++it) {
@@ -351,25 +353,26 @@ void MultiUserWindowManagerChromeOS::GetOwnersOfVisibleWindows(
bool MultiUserWindowManagerChromeOS::IsWindowOnDesktopOfUser(
aura::Window* window,
- const std::string& user_id) const {
- const std::string& presenting_user = GetUserPresentingWindow(window);
+ const user_manager::UserID& user_id) const {
+ const user_manager::UserID& presenting_user = GetUserPresentingWindow(window);
return presenting_user.empty() || presenting_user == user_id;
}
-const std::string& MultiUserWindowManagerChromeOS::GetUserPresentingWindow(
+const user_manager::UserID& MultiUserWindowManagerChromeOS::GetUserPresentingWindow(
aura::Window* window) const {
WindowToEntryMap::const_iterator it = window_to_entry_.find(window);
// If the window is not owned by anyone it is shown on all desktops and we
// return the empty string.
if (it == window_to_entry_.end())
- return base::EmptyString();
+ return user_manager::EmptyUserID();
+
// Otherwise we ask the object for its desktop.
return it->second->show_for_user();
}
void MultiUserWindowManagerChromeOS::AddUser(content::BrowserContext* context) {
Profile* profile = Profile::FromBrowserContext(context);
- const std::string& user_id = multi_user_util::GetUserIDFromProfile(profile);
+ const user_manager::UserID& user_id = multi_user_util::GetUserIDFromProfile(profile);
if (user_id_to_app_observer_.find(user_id) != user_id_to_app_observer_.end())
return;
@@ -417,7 +420,7 @@ void MultiUserWindowManagerChromeOS::RemoveObserver(Observer* observer) {
}
void MultiUserWindowManagerChromeOS::ActiveUserChanged(
- const std::string& user_id) {
+ const user_manager::UserID& user_id) {
// This needs to be set before the animation starts.
current_user_id_ = user_id;
@@ -534,17 +537,17 @@ bool MultiUserWindowManagerChromeOS::IsAnimationRunningForTest() {
return animation_.get() != NULL && !animation_->IsAnimationFinished();
}
-const std::string& MultiUserWindowManagerChromeOS::GetCurrentUserForTest()
+const user_manager::UserID& MultiUserWindowManagerChromeOS::GetCurrentUserForTest()
const {
return current_user_id_;
}
bool MultiUserWindowManagerChromeOS::ShowWindowForUserIntern(
aura::Window* window,
- const std::string& user_id) {
+ const user_manager::UserID& user_id) {
// If there is either no owner, or the owner is the current user, no action
// is required.
- const std::string& owner = GetWindowOwner(window);
+ const user_manager::UserID& owner = GetWindowOwner(window);
if (owner.empty() ||
(owner == user_id && IsWindowOnDesktopOfUser(window, user_id)))
return false;
@@ -598,7 +601,7 @@ void MultiUserWindowManagerChromeOS::SetWindowVisibility(
if (window->parent() == system_modal_container) {
// The window is system modal and we need to find the parent which owns
// it so that we can switch to the desktop accordingly.
- std::string user_id = GetUserPresentingWindow(window);
+ user_manager::UserID user_id = GetUserPresentingWindow(window);
if (user_id.empty()) {
aura::Window* owning_window = GetOwningWindowInTransientChain(window);
DCHECK(owning_window);

Powered by Google App Engine
This is Rietveld 408576698