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

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

Issue 385073008: Browser-based guest policy implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
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/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
9 #include "base/value_conversions.h" 10 #include "base/value_conversions.h"
10 #include "base/values.h" 11 #include "base/values.h"
11 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/extensions/api/screenlock_private/screenlock_private_ap i.h" 13 #include "chrome/browser/extensions/api/screenlock_private/screenlock_private_ap i.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 15 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
15 #include "chrome/browser/profiles/profile_info_cache.h" 16 #include "chrome/browser/profiles/profile_info_cache.h"
16 #include "chrome/browser/profiles/profile_info_cache_observer.h" 17 #include "chrome/browser/profiles/profile_info_cache_observer.h"
17 #include "chrome/browser/profiles/profile_manager.h" 18 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/browser/profiles/profile_window.h" 19 #include "chrome/browser/profiles/profile_window.h"
19 #include "chrome/browser/profiles/profiles_state.h" 20 #include "chrome/browser/profiles/profiles_state.h"
20 #include "chrome/browser/signin/local_auth.h" 21 #include "chrome/browser/signin/local_auth.h"
21 #include "chrome/browser/ui/browser_dialogs.h" 22 #include "chrome/browser/ui/browser_dialogs.h"
22 #include "chrome/browser/ui/browser_finder.h" 23 #include "chrome/browser/ui/browser_finder.h"
23 #include "chrome/browser/ui/singleton_tabs.h" 24 #include "chrome/browser/ui/singleton_tabs.h"
25 #include "chrome/common/pref_names.h"
24 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
25 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
26 #include "content/public/browser/web_ui.h" 28 #include "content/public/browser/web_ui.h"
27 #include "google_apis/gaia/gaia_auth_fetcher.h" 29 #include "google_apis/gaia/gaia_auth_fetcher.h"
28 #include "google_apis/gaia/gaia_constants.h" 30 #include "google_apis/gaia/gaia_constants.h"
29 #include "grit/browser_resources.h" 31 #include "grit/browser_resources.h"
30 #include "grit/chromium_strings.h" 32 #include "grit/chromium_strings.h"
31 #include "grit/generated_resources.h" 33 #include "grit/generated_resources.h"
32 #include "grit/theme_resources.h" 34 #include "grit/theme_resources.h"
33 #include "third_party/skia/include/core/SkBitmap.h" 35 #include "third_party/skia/include/core/SkBitmap.h"
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 364
363 if (!profiles::IsMultipleProfilesEnabled()) 365 if (!profiles::IsMultipleProfilesEnabled())
364 return; 366 return;
365 367
366 g_browser_process->profile_manager()->ScheduleProfileForDeletion( 368 g_browser_process->profile_manager()->ScheduleProfileForDeletion(
367 profile_path, 369 profile_path,
368 base::Bind(&OpenNewWindowForProfile, desktop_type_)); 370 base::Bind(&OpenNewWindowForProfile, desktop_type_));
369 ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::PROFILE_DELETED); 371 ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::PROFILE_DELETED);
370 } 372 }
371 373
372 void UserManagerScreenHandler::HandleLaunchGuest(const base::ListValue* args) { 374 void UserManagerScreenHandler::HandleLaunchGuest(const base::ListValue* args) {
Joao da Silva 2014/07/14 17:11:59 As a defensive measure, I suggest checking the pre
Mike Lerman 2014/07/15 14:28:12 Done.
373 profiles::SwitchToGuestProfile(desktop_type_, 375 profiles::SwitchToGuestProfile(desktop_type_,
374 base::Bind(&OnSwitchToProfileComplete)); 376 base::Bind(&OnSwitchToProfileComplete));
375 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::SWITCH_PROFILE_GUEST); 377 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::SWITCH_PROFILE_GUEST);
376 } 378 }
377 379
378 void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) { 380 void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) {
379 base::string16 email_address; 381 base::string16 email_address;
380 base::string16 display_name; 382 base::string16 display_name;
381 383
382 if (!args->GetString(0, &email_address) || 384 if (!args->GetString(0, &email_address) ||
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 profile_value->SetString( 618 profile_value->SetString(
617 kKeyAvatarUrl, GetAvatarImageAtIndex(i, info_cache)); 619 kKeyAvatarUrl, GetAvatarImageAtIndex(i, info_cache));
618 620
619 // The row of user pods should display the active user first. 621 // The row of user pods should display the active user first.
620 if (is_active_user) 622 if (is_active_user)
621 users_list.Insert(0, profile_value); 623 users_list.Insert(0, profile_value);
622 else 624 else
623 users_list.Append(profile_value); 625 users_list.Append(profile_value);
624 } 626 }
625 627
628
Joao da Silva 2014/07/14 17:11:59 nit: single newline
Mike Lerman 2014/07/15 14:28:12 Done.
629 PrefService* service = g_browser_process->local_state();
630 DCHECK(service);
631 bool guest_mode_enabled_by_policy =
632 service->GetBoolean(prefs::kBrowserGuestModeEnabled);
633
626 web_ui()->CallJavascriptFunction("login.AccountPickerScreen.loadUsers", 634 web_ui()->CallJavascriptFunction("login.AccountPickerScreen.loadUsers",
627 users_list, base::FundamentalValue(false), base::FundamentalValue(true)); 635 users_list,
636 base::FundamentalValue(false),
637 base::FundamentalValue(guest_mode_enabled_by_policy));
628 } 638 }
629 639
630 void UserManagerScreenHandler::ReportAuthenticationResult( 640 void UserManagerScreenHandler::ReportAuthenticationResult(
631 bool success, 641 bool success,
632 ProfileMetrics::ProfileAuth auth) { 642 ProfileMetrics::ProfileAuth auth) {
633 ProfileMetrics::LogProfileAuthResult(auth); 643 ProfileMetrics::LogProfileAuthResult(auth);
634 password_attempt_.clear(); 644 password_attempt_.clear();
635 645
636 if (success) { 646 if (success) {
637 ProfileInfoCache& info_cache = 647 ProfileInfoCache& info_cache =
638 g_browser_process->profile_manager()->GetProfileInfoCache(); 648 g_browser_process->profile_manager()->GetProfileInfoCache();
639 info_cache.SetProfileSigninRequiredAtIndex( 649 info_cache.SetProfileSigninRequiredAtIndex(
640 authenticating_profile_index_, false); 650 authenticating_profile_index_, false);
641 base::FilePath path = info_cache.GetPathOfProfileAtIndex( 651 base::FilePath path = info_cache.GetPathOfProfileAtIndex(
642 authenticating_profile_index_); 652 authenticating_profile_index_);
643 profiles::SwitchToProfile(path, desktop_type_, true, 653 profiles::SwitchToProfile(path, desktop_type_, true,
644 base::Bind(&OnSwitchToProfileComplete), 654 base::Bind(&OnSwitchToProfileComplete),
645 ProfileMetrics::SWITCH_PROFILE_UNLOCK); 655 ProfileMetrics::SWITCH_PROFILE_UNLOCK);
646 } else { 656 } else {
647 web_ui()->CallJavascriptFunction( 657 web_ui()->CallJavascriptFunction(
648 "cr.ui.Oobe.showSignInError", 658 "cr.ui.Oobe.showSignInError",
649 base::FundamentalValue(0), 659 base::FundamentalValue(0),
650 base::StringValue( 660 base::StringValue(
651 l10n_util::GetStringUTF8(IDS_LOGIN_ERROR_AUTHENTICATING)), 661 l10n_util::GetStringUTF8(IDS_LOGIN_ERROR_AUTHENTICATING)),
652 base::StringValue(""), 662 base::StringValue(""),
653 base::FundamentalValue(0)); 663 base::FundamentalValue(0));
654 } 664 }
655 } 665 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698