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

Side by Side Diff: chrome/browser/chromeos/login/screens/chrome_user_selection_screen.cc

Issue 1463753002: ChromeOS: This CL fixes bug in UserManager::GetKnownUserAccountId . (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests. 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chromeos/login/screens/chrome_user_selection_screen.h" 5 #include "chrome/browser/chromeos/login/screens/chrome_user_selection_screen.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 CheckForPublicSessionLocalePolicyChange(broker); 70 CheckForPublicSessionLocalePolicyChange(broker);
71 } 71 }
72 72
73 void ChromeUserSelectionScreen::OnDeviceLocalAccountsChanged() { 73 void ChromeUserSelectionScreen::OnDeviceLocalAccountsChanged() {
74 // Nothing to do here. When the list of device-local accounts changes, the 74 // Nothing to do here. When the list of device-local accounts changes, the
75 // entire UI is reloaded. 75 // entire UI is reloaded.
76 } 76 }
77 77
78 void ChromeUserSelectionScreen::CheckForPublicSessionDisplayNameChange( 78 void ChromeUserSelectionScreen::CheckForPublicSessionDisplayNameChange(
79 policy::DeviceLocalAccountPolicyBroker* broker) { 79 policy::DeviceLocalAccountPolicyBroker* broker) {
80 const AccountId& account_id = GetAccountIdOfKnownUser(broker->user_id()); 80 const AccountId& account_id =
achuithb 2015/11/20 18:46:51 Shouldn't this be AccountId account_id= Why do yo
81 user_manager::UserManager::GetKnownUserAccountId(broker->user_id(),
82 std::string());
81 DCHECK(account_id.is_valid()); 83 DCHECK(account_id.is_valid());
82 const std::string& display_name = broker->GetDisplayName(); 84 const std::string& display_name = broker->GetDisplayName();
83 if (display_name == public_session_display_names_[account_id]) 85 if (display_name == public_session_display_names_[account_id])
84 return; 86 return;
85 87
86 public_session_display_names_[account_id] = display_name; 88 public_session_display_names_[account_id] = display_name;
87 89
88 if (!handler_initialized_) 90 if (!handler_initialized_)
89 return; 91 return;
90 92
91 if (!display_name.empty()) { 93 if (!display_name.empty()) {
92 // If a new display name was set by policy, notify the UI about it. 94 // If a new display name was set by policy, notify the UI about it.
93 view_->SetPublicSessionDisplayName(account_id, display_name); 95 view_->SetPublicSessionDisplayName(account_id, display_name);
94 return; 96 return;
95 } 97 }
96 98
97 // When no display name is set by policy, the |User|, owned by |UserManager|, 99 // When no display name is set by policy, the |User|, owned by |UserManager|,
98 // decides what display name to use. However, the order in which |UserManager| 100 // decides what display name to use. However, the order in which |UserManager|
99 // and |this| are informed of the display name change is undefined. Post a 101 // and |this| are informed of the display name change is undefined. Post a
100 // task that will update the UI after the UserManager is guaranteed to have 102 // task that will update the UI after the UserManager is guaranteed to have
101 // been informed of the change. 103 // been informed of the change.
102 base::MessageLoop::current()->PostTask( 104 base::MessageLoop::current()->PostTask(
103 FROM_HERE, 105 FROM_HERE,
104 base::Bind(&ChromeUserSelectionScreen::SetPublicSessionDisplayName, 106 base::Bind(&ChromeUserSelectionScreen::SetPublicSessionDisplayName,
105 weak_factory_.GetWeakPtr(), account_id)); 107 weak_factory_.GetWeakPtr(), account_id));
106 } 108 }
107 109
108 void ChromeUserSelectionScreen::CheckForPublicSessionLocalePolicyChange( 110 void ChromeUserSelectionScreen::CheckForPublicSessionLocalePolicyChange(
109 policy::DeviceLocalAccountPolicyBroker* broker) { 111 policy::DeviceLocalAccountPolicyBroker* broker) {
110 const AccountId& account_id = GetAccountIdOfKnownUser(broker->user_id()); 112 const AccountId& account_id =
achuithb 2015/11/20 18:46:51 Shouldn't this be AccountId account_id =
113 user_manager::UserManager::GetKnownUserAccountId(broker->user_id(),
114 std::string());
111 DCHECK(account_id.is_valid()); 115 DCHECK(account_id.is_valid());
112 const policy::PolicyMap::Entry* entry = 116 const policy::PolicyMap::Entry* entry =
113 broker->core()->store()->policy_map().Get(policy::key::kSessionLocales); 117 broker->core()->store()->policy_map().Get(policy::key::kSessionLocales);
114 118
115 // Parse the list of recommended locales set by policy. 119 // Parse the list of recommended locales set by policy.
116 std::vector<std::string> new_recommended_locales; 120 std::vector<std::string> new_recommended_locales;
117 base::ListValue const* list = NULL; 121 base::ListValue const* list = NULL;
118 if (entry && 122 if (entry &&
119 entry->level == policy::POLICY_LEVEL_RECOMMENDED && 123 entry->level == policy::POLICY_LEVEL_RECOMMENDED &&
120 entry->value && 124 entry->value &&
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // advanced form (two or more recommended locales). 182 // advanced form (two or more recommended locales).
179 const bool two_or_more_recommended_locales = recommended_locales.size() >= 2; 183 const bool two_or_more_recommended_locales = recommended_locales.size() >= 2;
180 184
181 // Notify the UI. 185 // Notify the UI.
182 view_->SetPublicSessionLocales(account_id, available_locales.Pass(), 186 view_->SetPublicSessionLocales(account_id, available_locales.Pass(),
183 default_locale, 187 default_locale,
184 two_or_more_recommended_locales); 188 two_or_more_recommended_locales);
185 } 189 }
186 190
187 } // namespace chromeos 191 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698