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

Side by Side Diff: chrome/browser/ui/ash/multi_user/multi_user_window_manager_test.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/multi_user/multi_user_window_manager_test.h" 5 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_test.h"
6 6
7 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 7 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
8 #include "chrome/browser/ui/browser_window.h" 8 #include "chrome/browser/ui/browser_window.h"
9 #include "components/signin/core/account_id/account_id.h"
9 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
10 11
11 TestMultiUserWindowManager::TestMultiUserWindowManager( 12 TestMultiUserWindowManager::TestMultiUserWindowManager(
12 Browser* visiting_browser, 13 Browser* visiting_browser,
13 const std::string& desktop_owner) 14 const AccountId& desktop_owner)
14 : browser_window_(visiting_browser->window()->GetNativeWindow()), 15 : browser_window_(visiting_browser->window()->GetNativeWindow()),
15 browser_owner_( 16 browser_owner_(multi_user_util::GetAccountIdFromProfile(
16 multi_user_util::GetUserIDFromProfile(visiting_browser->profile())), 17 visiting_browser->profile())),
17 desktop_owner_(desktop_owner), 18 desktop_owner_(desktop_owner),
18 created_window_(NULL), 19 created_window_(NULL),
19 created_window_shown_for_(browser_owner_), 20 created_window_shown_for_(browser_owner_),
20 current_user_id_(desktop_owner) { 21 current_account_id_(desktop_owner) {
21 // Register this object with the system (which will take ownership). It will 22 // Register this object with the system (which will take ownership). It will
22 // be deleted by ChromeLauncherController::~ChromeLauncherController(). 23 // be deleted by ChromeLauncherController::~ChromeLauncherController().
23 chrome::MultiUserWindowManager::SetInstanceForTest( 24 chrome::MultiUserWindowManager::SetInstanceForTest(
24 this, chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED); 25 this, chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED);
25 } 26 }
26 27
27 TestMultiUserWindowManager::~TestMultiUserWindowManager() { 28 TestMultiUserWindowManager::~TestMultiUserWindowManager() {
28 // This object is owned by the MultiUserWindowManager since the 29 // This object is owned by the MultiUserWindowManager since the
29 // SetInstanceForTest call. As such no uninstall is required. 30 // SetInstanceForTest call. As such no uninstall is required.
30 } 31 }
31 32
32 void TestMultiUserWindowManager::SetWindowOwner(aura::Window* window, 33 void TestMultiUserWindowManager::SetWindowOwner(
33 const std::string& user_id) { 34 aura::Window* window,
35 const AccountId& account_id) {
34 NOTREACHED(); 36 NOTREACHED();
35 } 37 }
36 38
37 const std::string& TestMultiUserWindowManager::GetWindowOwner( 39 const AccountId& TestMultiUserWindowManager::GetWindowOwner(
38 aura::Window* window) const { 40 aura::Window* window) const {
39 // No matter which window will get queried - all browsers belong to the 41 // No matter which window will get queried - all browsers belong to the
40 // original browser's user. 42 // original browser's user.
41 return browser_owner_; 43 return browser_owner_;
42 } 44 }
43 45
44 void TestMultiUserWindowManager::ShowWindowForUser(aura::Window* window, 46 void TestMultiUserWindowManager::ShowWindowForUser(
45 const std::string& user_id) { 47 aura::Window* window,
48 const AccountId& account_id) {
46 // This class is only able to handle one additional window <-> user 49 // This class is only able to handle one additional window <-> user
47 // association beside the creation parameters. 50 // association beside the creation parameters.
48 // If no association has yet been requested remember it now. 51 // If no association has yet been requested remember it now.
49 DCHECK(!created_window_); 52 DCHECK(!created_window_);
50 created_window_ = window; 53 created_window_ = window;
51 created_window_shown_for_ = user_id; 54 created_window_shown_for_ = account_id;
52 55
53 if (browser_window_ == window) 56 if (browser_window_ == window)
54 desktop_owner_ = user_id; 57 desktop_owner_ = account_id;
55 58
56 if (user_id == current_user_id_) 59 if (account_id == current_account_id_)
57 return; 60 return;
58 61
59 // Change the visibility of the window to update the view recursively. 62 // Change the visibility of the window to update the view recursively.
60 window->Hide(); 63 window->Hide();
61 window->Show(); 64 window->Show();
62 current_user_id_ = user_id; 65 current_account_id_ = account_id;
63 } 66 }
64 67
65 bool TestMultiUserWindowManager::AreWindowsSharedAmongUsers() const { 68 bool TestMultiUserWindowManager::AreWindowsSharedAmongUsers() const {
66 return browser_owner_ != desktop_owner_; 69 return browser_owner_ != desktop_owner_;
67 } 70 }
68 71
69 void TestMultiUserWindowManager::GetOwnersOfVisibleWindows( 72 void TestMultiUserWindowManager::GetOwnersOfVisibleWindows(
70 std::set<std::string>* user_ids) const { 73 std::set<AccountId>* account_ids) const {}
71 }
72 74
73 bool TestMultiUserWindowManager::IsWindowOnDesktopOfUser( 75 bool TestMultiUserWindowManager::IsWindowOnDesktopOfUser(
74 aura::Window* window, 76 aura::Window* window,
75 const std::string& user_id) const { 77 const AccountId& account_id) const {
76 return GetUserPresentingWindow(window) == user_id; 78 return GetUserPresentingWindow(window) == account_id;
77 } 79 }
78 80
79 const std::string& TestMultiUserWindowManager::GetUserPresentingWindow( 81 const AccountId& TestMultiUserWindowManager::GetUserPresentingWindow(
80 aura::Window* window) const { 82 aura::Window* window) const {
81 if (window == browser_window_) 83 if (window == browser_window_)
82 return desktop_owner_; 84 return desktop_owner_;
83 if (created_window_ && window == created_window_) 85 if (created_window_ && window == created_window_)
84 return created_window_shown_for_; 86 return created_window_shown_for_;
85 // We can come here before the window gets registered. 87 // We can come here before the window gets registered.
86 return browser_owner_; 88 return browser_owner_;
87 } 89 }
88 90
89 void TestMultiUserWindowManager::AddUser(content::BrowserContext* profile) { 91 void TestMultiUserWindowManager::AddUser(content::BrowserContext* profile) {
90 } 92 }
91 93
92 void TestMultiUserWindowManager::AddObserver(Observer* observer) { 94 void TestMultiUserWindowManager::AddObserver(Observer* observer) {
93 } 95 }
94 96
95 void TestMultiUserWindowManager::RemoveObserver(Observer* observer) { 97 void TestMultiUserWindowManager::RemoveObserver(Observer* observer) {
96 } 98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698