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

Side by Side Diff: chrome/browser/ui/webui/signin/user_manager_screen_handler.cc

Issue 289013002: cros: Clean up screenlockPrivate plumbing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/signin/user_manager_screen_handler.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/webui/signin/user_manager_screen_handler.h" 5 #include "chrome/browser/ui/webui/signin/user_manager_screen_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/value_conversions.h" 9 #include "base/value_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 const char kKeyAvatarUrl[] = "userImage"; 54 const char kKeyAvatarUrl[] = "userImage";
55 const char kKeyNeedsSignin[] = "needsSignin"; 55 const char kKeyNeedsSignin[] = "needsSignin";
56 56
57 // JS API callback names. 57 // JS API callback names.
58 const char kJsApiUserManagerInitialize[] = "userManagerInitialize"; 58 const char kJsApiUserManagerInitialize[] = "userManagerInitialize";
59 const char kJsApiUserManagerAddUser[] = "addUser"; 59 const char kJsApiUserManagerAddUser[] = "addUser";
60 const char kJsApiUserManagerAuthLaunchUser[] = "authenticatedLaunchUser"; 60 const char kJsApiUserManagerAuthLaunchUser[] = "authenticatedLaunchUser";
61 const char kJsApiUserManagerLaunchGuest[] = "launchGuest"; 61 const char kJsApiUserManagerLaunchGuest[] = "launchGuest";
62 const char kJsApiUserManagerLaunchUser[] = "launchUser"; 62 const char kJsApiUserManagerLaunchUser[] = "launchUser";
63 const char kJsApiUserManagerRemoveUser[] = "removeUser"; 63 const char kJsApiUserManagerRemoveUser[] = "removeUser";
64 const char kJsApiUserManagerCustomButtonClicked[] = "customButtonClicked";
65 const char kJsApiUserManagerAttemptUnlock[] = "attemptUnlock"; 64 const char kJsApiUserManagerAttemptUnlock[] = "attemptUnlock";
66 65
67 const size_t kAvatarIconSize = 180; 66 const size_t kAvatarIconSize = 180;
68 67
69 void HandleAndDoNothing(const base::ListValue* args) { 68 void HandleAndDoNothing(const base::ListValue* args) {
70 } 69 }
71 70
72 // This callback is run if the only profile has been deleted, and a new 71 // This callback is run if the only profile has been deleted, and a new
73 // profile has been created to replace it. 72 // profile has been created to replace it.
74 void OpenNewWindowForProfile( 73 void OpenNewWindowForProfile(
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 ProfileInfoCache& info_cache = 133 ProfileInfoCache& info_cache =
135 g_browser_process->profile_manager()->GetProfileInfoCache(); 134 g_browser_process->profile_manager()->GetProfileInfoCache();
136 const size_t profile_index = GetIndexOfProfileWithEmailAndName( 135 const size_t profile_index = GetIndexOfProfileWithEmailAndName(
137 info_cache, base::UTF8ToUTF16(email), base::string16()); 136 info_cache, base::UTF8ToUTF16(email), base::string16());
138 Profile* profile = g_browser_process->profile_manager() 137 Profile* profile = g_browser_process->profile_manager()
139 ->GetProfileByPath(info_cache.GetPathOfProfileAtIndex(profile_index)); 138 ->GetProfileByPath(info_cache.GetPathOfProfileAtIndex(profile_index));
140 return extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get( 139 return extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get(
141 profile); 140 profile);
142 } 141 }
143 142
144 } // namespace 143 } // namespace
145 144
146 // ProfileUpdateObserver ------------------------------------------------------ 145 // ProfileUpdateObserver ------------------------------------------------------
147 146
148 class UserManagerScreenHandler::ProfileUpdateObserver 147 class UserManagerScreenHandler::ProfileUpdateObserver
149 : public ProfileInfoCacheObserver { 148 : public ProfileInfoCacheObserver {
150 public: 149 public:
151 ProfileUpdateObserver( 150 ProfileUpdateObserver(
152 ProfileManager* profile_manager, UserManagerScreenHandler* handler) 151 ProfileManager* profile_manager, UserManagerScreenHandler* handler)
153 : profile_manager_(profile_manager), 152 : profile_manager_(profile_manager),
154 user_manager_handler_(handler) { 153 user_manager_handler_(handler) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 UserManagerScreenHandler::~UserManagerScreenHandler() { 212 UserManagerScreenHandler::~UserManagerScreenHandler() {
214 ScreenlockBridge::Get()->SetLockHandler(NULL); 213 ScreenlockBridge::Get()->SetLockHandler(NULL);
215 } 214 }
216 215
217 void UserManagerScreenHandler::ShowBannerMessage(const std::string& message) { 216 void UserManagerScreenHandler::ShowBannerMessage(const std::string& message) {
218 web_ui()->CallJavascriptFunction( 217 web_ui()->CallJavascriptFunction(
219 "login.AccountPickerScreen.showBannerMessage", 218 "login.AccountPickerScreen.showBannerMessage",
220 base::StringValue(message)); 219 base::StringValue(message));
221 } 220 }
222 221
223 void UserManagerScreenHandler::ShowUserPodButton( 222 void UserManagerScreenHandler::ShowUserPodCustomIcon(
224 const std::string& user_email, 223 const std::string& user_email,
225 const gfx::Image& icon, 224 const gfx::Image& icon) {
226 const base::Closure& callback) {
227 GURL icon_url(webui::GetBitmapDataUrl(icon.AsBitmap())); 225 GURL icon_url(webui::GetBitmapDataUrl(icon.AsBitmap()));
228 web_ui()->CallJavascriptFunction( 226 web_ui()->CallJavascriptFunction(
229 "login.AccountPickerScreen.showUserPodButton", 227 "login.AccountPickerScreen.showUserPodCustomIcon",
230 base::StringValue(user_email), 228 base::StringValue(user_email),
231 base::StringValue(icon_url.spec())); 229 base::StringValue(icon_url.spec()));
232 } 230 }
233 231
234 void UserManagerScreenHandler::HideUserPodButton( 232 void UserManagerScreenHandler::HideUserPodCustomIcon(
235 const std::string& user_email) { 233 const std::string& user_email) {
236 web_ui()->CallJavascriptFunction( 234 web_ui()->CallJavascriptFunction(
237 "login.AccountPickerScreen.hideUserPodButton", 235 "login.AccountPickerScreen.hideUserPodCustomIcon",
238 base::StringValue(user_email)); 236 base::StringValue(user_email));
239 } 237 }
240 238
241 void UserManagerScreenHandler::EnableInput() { 239 void UserManagerScreenHandler::EnableInput() {
242 // Nothing here because UI is not disabled when starting to authenticate. 240 // Nothing here because UI is not disabled when starting to authenticate.
243 } 241 }
244 242
245 void UserManagerScreenHandler::SetAuthType( 243 void UserManagerScreenHandler::SetAuthType(
246 const std::string& user_email, 244 const std::string& user_email,
247 ScreenlockBridge::LockHandler::AuthType auth_type, 245 ScreenlockBridge::LockHandler::AuthType auth_type,
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 ProfileMetrics::LogProfileAuthResult(ProfileMetrics::AUTH_UNNECESSARY); 394 ProfileMetrics::LogProfileAuthResult(ProfileMetrics::AUTH_UNNECESSARY);
397 395
398 base::FilePath path = info_cache.GetPathOfProfileAtIndex(profile_index); 396 base::FilePath path = info_cache.GetPathOfProfileAtIndex(profile_index);
399 profiles::SwitchToProfile(path, 397 profiles::SwitchToProfile(path,
400 desktop_type_, 398 desktop_type_,
401 false, /* reuse any existing windows */ 399 false, /* reuse any existing windows */
402 base::Bind(&OnSwitchToProfileComplete), 400 base::Bind(&OnSwitchToProfileComplete),
403 ProfileMetrics::SWITCH_PROFILE_MANAGER); 401 ProfileMetrics::SWITCH_PROFILE_MANAGER);
404 } 402 }
405 403
406 void UserManagerScreenHandler::HandleCustomButtonClicked(
407 const base::ListValue* args) {
408 // TODO(xiyuan): Remove this. Deprecated now.
409 }
410
411 void UserManagerScreenHandler::HandleAttemptUnlock( 404 void UserManagerScreenHandler::HandleAttemptUnlock(
412 const base::ListValue* args) { 405 const base::ListValue* args) {
413 std::string email; 406 std::string email;
414 CHECK(args->GetString(0, &email)); 407 CHECK(args->GetString(0, &email));
415 GetScreenlockRouter(email)->OnAuthAttempted(GetAuthType(email), ""); 408 GetScreenlockRouter(email)->OnAuthAttempted(GetAuthType(email), "");
416 } 409 }
417 410
418 void UserManagerScreenHandler::OnClientLoginSuccess( 411 void UserManagerScreenHandler::OnClientLoginSuccess(
419 const ClientLoginResult& result) { 412 const ClientLoginResult& result) {
420 chrome::SetLocalAuthCredentials(authenticating_profile_index_, 413 chrome::SetLocalAuthCredentials(authenticating_profile_index_,
(...skipping 29 matching lines...) Expand all
450 base::Unretained(this))); 443 base::Unretained(this)));
451 web_ui()->RegisterMessageCallback(kJsApiUserManagerLaunchGuest, 444 web_ui()->RegisterMessageCallback(kJsApiUserManagerLaunchGuest,
452 base::Bind(&UserManagerScreenHandler::HandleLaunchGuest, 445 base::Bind(&UserManagerScreenHandler::HandleLaunchGuest,
453 base::Unretained(this))); 446 base::Unretained(this)));
454 web_ui()->RegisterMessageCallback(kJsApiUserManagerLaunchUser, 447 web_ui()->RegisterMessageCallback(kJsApiUserManagerLaunchUser,
455 base::Bind(&UserManagerScreenHandler::HandleLaunchUser, 448 base::Bind(&UserManagerScreenHandler::HandleLaunchUser,
456 base::Unretained(this))); 449 base::Unretained(this)));
457 web_ui()->RegisterMessageCallback(kJsApiUserManagerRemoveUser, 450 web_ui()->RegisterMessageCallback(kJsApiUserManagerRemoveUser,
458 base::Bind(&UserManagerScreenHandler::HandleRemoveUser, 451 base::Bind(&UserManagerScreenHandler::HandleRemoveUser,
459 base::Unretained(this))); 452 base::Unretained(this)));
460 web_ui()->RegisterMessageCallback(kJsApiUserManagerCustomButtonClicked,
461 base::Bind(&UserManagerScreenHandler::HandleCustomButtonClicked,
462 base::Unretained(this)));
463 web_ui()->RegisterMessageCallback(kJsApiUserManagerAttemptUnlock, 453 web_ui()->RegisterMessageCallback(kJsApiUserManagerAttemptUnlock,
464 base::Bind(&UserManagerScreenHandler::HandleAttemptUnlock, 454 base::Bind(&UserManagerScreenHandler::HandleAttemptUnlock,
465 base::Unretained(this))); 455 base::Unretained(this)));
466 456
467 const content::WebUI::MessageCallback& kDoNothingCallback = 457 const content::WebUI::MessageCallback& kDoNothingCallback =
468 base::Bind(&HandleAndDoNothing); 458 base::Bind(&HandleAndDoNothing);
469 459
470 // Unused callbacks from screen_account_picker.js 460 // Unused callbacks from screen_account_picker.js
471 web_ui()->RegisterMessageCallback("accountPickerReady", kDoNothingCallback); 461 web_ui()->RegisterMessageCallback("accountPickerReady", kDoNothingCallback);
472 web_ui()->RegisterMessageCallback("loginUIStateChanged", kDoNothingCallback); 462 web_ui()->RegisterMessageCallback("loginUIStateChanged", kDoNothingCallback);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 localized_strings->SetString("slideCompleteAddUser", 546 localized_strings->SetString("slideCompleteAddUser",
557 l10n_util::GetStringUTF16( 547 l10n_util::GetStringUTF16(
558 IDS_USER_MANAGER_TUTORIAL_SLIDE_OUTRO_ADD_USER)); 548 IDS_USER_MANAGER_TUTORIAL_SLIDE_OUTRO_ADD_USER));
559 549
560 // Strings needed for the user_pod_template public account div, but not ever 550 // Strings needed for the user_pod_template public account div, but not ever
561 // actually displayed for desktop users. 551 // actually displayed for desktop users.
562 localized_strings->SetString("publicAccountReminder", base::string16()); 552 localized_strings->SetString("publicAccountReminder", base::string16());
563 localized_strings->SetString("publicAccountEnter", base::string16()); 553 localized_strings->SetString("publicAccountEnter", base::string16());
564 localized_strings->SetString("publicAccountEnterAccessibleName", 554 localized_strings->SetString("publicAccountEnterAccessibleName",
565 base::string16()); 555 base::string16());
566 localized_strings->SetString("multiple-signin-banner-text",
567 base::string16());
568 localized_strings->SetString("signinBannerText", base::string16()); 556 localized_strings->SetString("signinBannerText", base::string16());
569 localized_strings->SetString("launchAppButton", base::string16()); 557 localized_strings->SetString("launchAppButton", base::string16());
570 localized_strings->SetString("multiProfilesRestrictedPolicyTitle", 558 localized_strings->SetString("multiProfilesRestrictedPolicyTitle",
571 base::string16()); 559 base::string16());
572 localized_strings->SetString("multiProfilesNotAllowedPolicyMsg", 560 localized_strings->SetString("multiProfilesNotAllowedPolicyMsg",
573 base::string16()); 561 base::string16());
574 localized_strings->SetString("multiProfilesPrimaryOnlyPolicyMsg", 562 localized_strings->SetString("multiProfilesPrimaryOnlyPolicyMsg",
575 base::string16()); 563 base::string16());
576 } 564 }
577 565
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 } else { 629 } else {
642 web_ui()->CallJavascriptFunction( 630 web_ui()->CallJavascriptFunction(
643 "cr.ui.Oobe.showSignInError", 631 "cr.ui.Oobe.showSignInError",
644 base::FundamentalValue(0), 632 base::FundamentalValue(0),
645 base::StringValue( 633 base::StringValue(
646 l10n_util::GetStringUTF8(IDS_LOGIN_ERROR_AUTHENTICATING)), 634 l10n_util::GetStringUTF8(IDS_LOGIN_ERROR_AUTHENTICATING)),
647 base::StringValue(""), 635 base::StringValue(""),
648 base::FundamentalValue(0)); 636 base::FundamentalValue(0));
649 } 637 }
650 } 638 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/signin/user_manager_screen_handler.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698