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

Side by Side Diff: chrome/browser/chromeos/login/existing_user_controller.cc

Issue 426063005: Allow recommended locales to be set for public sessions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix buffer overflow in test. Created 6 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/existing_user_controller.h" 5 #include "chrome/browser/chromeos/login/existing_user_controller.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/prefs/pref_service.h" 17 #include "base/prefs/pref_service.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/values.h" 21 #include "base/values.h"
22 #include "base/version.h" 22 #include "base/version.h"
23 #include "chrome/browser/accessibility/accessibility_events.h" 23 #include "chrome/browser/accessibility/accessibility_events.h"
24 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/browser_process_platform_part.h"
25 #include "chrome/browser/chrome_notification_types.h" 26 #include "chrome/browser/chrome_notification_types.h"
26 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 27 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
27 #include "chrome/browser/chromeos/boot_times_loader.h" 28 #include "chrome/browser/chromeos/boot_times_loader.h"
28 #include "chrome/browser/chromeos/customization_document.h" 29 #include "chrome/browser/chromeos/customization_document.h"
29 #include "chrome/browser/chromeos/first_run/first_run.h" 30 #include "chrome/browser/chromeos/first_run/first_run.h"
30 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" 31 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
31 #include "chrome/browser/chromeos/login/helper.h" 32 #include "chrome/browser/chromeos/login/helper.h"
32 #include "chrome/browser/chromeos/login/login_utils.h" 33 #include "chrome/browser/chromeos/login/login_utils.h"
33 #include "chrome/browser/chromeos/login/startup_utils.h" 34 #include "chrome/browser/chromeos/login/startup_utils.h"
34 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 35 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
35 #include "chrome/browser/chromeos/login/users/user_manager.h" 36 #include "chrome/browser/chromeos/login/users/user_manager.h"
36 #include "chrome/browser/chromeos/login/wizard_controller.h" 37 #include "chrome/browser/chromeos/login/wizard_controller.h"
37 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 38 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
38 #include "chrome/browser/chromeos/policy/device_local_account.h" 39 #include "chrome/browser/chromeos/policy/device_local_account.h"
40 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h"
39 #include "chrome/browser/chromeos/profiles/profile_helper.h" 41 #include "chrome/browser/chromeos/profiles/profile_helper.h"
40 #include "chrome/browser/chromeos/settings/cros_settings.h" 42 #include "chrome/browser/chromeos/settings/cros_settings.h"
41 #include "chrome/browser/prefs/session_startup_pref.h" 43 #include "chrome/browser/prefs/session_startup_pref.h"
44 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h"
42 #include "chrome/common/chrome_switches.h" 45 #include "chrome/common/chrome_switches.h"
43 #include "chrome/common/chrome_version_info.h" 46 #include "chrome/common/chrome_version_info.h"
44 #include "chrome/common/pref_names.h" 47 #include "chrome/common/pref_names.h"
45 #include "chrome/common/url_constants.h" 48 #include "chrome/common/url_constants.h"
46 #include "chromeos/chromeos_switches.h" 49 #include "chromeos/chromeos_switches.h"
47 #include "chromeos/dbus/dbus_thread_manager.h" 50 #include "chromeos/dbus/dbus_thread_manager.h"
48 #include "chromeos/dbus/power_manager_client.h" 51 #include "chromeos/dbus/power_manager_client.h"
49 #include "chromeos/dbus/session_manager_client.h" 52 #include "chromeos/dbus/session_manager_client.h"
50 #include "chromeos/login/auth/user_context.h" 53 #include "chromeos/login/auth/user_context.h"
51 #include "chromeos/login/user_names.h" 54 #include "chromeos/login/user_names.h"
52 #include "chromeos/settings/cros_settings_names.h" 55 #include "chromeos/settings/cros_settings_names.h"
53 #include "components/google/core/browser/google_util.h" 56 #include "components/google/core/browser/google_util.h"
57 #include "components/policy/core/common/cloud/cloud_policy_core.h"
58 #include "components/policy/core/common/cloud/cloud_policy_store.h"
59 #include "components/policy/core/common/policy_map.h"
54 #include "components/policy/core/common/policy_service.h" 60 #include "components/policy/core/common/policy_service.h"
61 #include "components/policy/core/common/policy_types.h"
55 #include "components/user_manager/user_type.h" 62 #include "components/user_manager/user_type.h"
56 #include "content/public/browser/browser_thread.h" 63 #include "content/public/browser/browser_thread.h"
57 #include "content/public/browser/notification_service.h" 64 #include "content/public/browser/notification_service.h"
58 #include "content/public/browser/notification_types.h" 65 #include "content/public/browser/notification_types.h"
59 #include "content/public/browser/user_metrics.h" 66 #include "content/public/browser/user_metrics.h"
60 #include "google_apis/gaia/gaia_auth_util.h" 67 #include "google_apis/gaia/gaia_auth_util.h"
61 #include "google_apis/gaia/google_service_auth_error.h" 68 #include "google_apis/gaia/google_service_auth_error.h"
62 #include "grit/generated_resources.h" 69 #include "grit/generated_resources.h"
63 #include "net/http/http_auth_cache.h" 70 #include "net/http/http_auth_cache.h"
64 #include "net/http/http_network_session.h" 71 #include "net/http/http_network_session.h"
65 #include "net/http/http_transaction_factory.h" 72 #include "net/http/http_transaction_factory.h"
66 #include "net/url_request/url_request_context.h" 73 #include "net/url_request/url_request_context.h"
67 #include "net/url_request/url_request_context_getter.h" 74 #include "net/url_request/url_request_context_getter.h"
75 #include "policy/policy_constants.h"
68 #include "ui/accessibility/ax_enums.h" 76 #include "ui/accessibility/ax_enums.h"
69 #include "ui/base/l10n/l10n_util.h" 77 #include "ui/base/l10n/l10n_util.h"
70 #include "ui/views/widget/widget.h" 78 #include "ui/views/widget/widget.h"
71 79
72 namespace chromeos { 80 namespace chromeos {
73 81
74 namespace { 82 namespace {
75 83
76 // URL for account creation. 84 // URL for account creation.
77 const char kCreateAccountURL[] = 85 const char kCreateAccountURL[] =
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 // possible. 583 // possible.
576 const user_manager::User* user = 584 const user_manager::User* user =
577 UserManager::Get()->FindUser(user_context.GetUserID()); 585 UserManager::Get()->FindUser(user_context.GetUserID());
578 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) { 586 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) {
579 // Re-enable clicking on other windows. 587 // Re-enable clicking on other windows.
580 login_display_->SetUIEnabled(true); 588 login_display_->SetUIEnabled(true);
581 StartPublicSessionAutoLoginTimer(); 589 StartPublicSessionAutoLoginTimer();
582 return; 590 return;
583 } 591 }
584 592
585 // Only one instance of LoginPerformer should exist at a time. 593 UserContext new_user_context = user_context;
586 login_performer_.reset(NULL); 594 std::string locale = user_context.GetPublicSessionLocale();
587 login_performer_.reset(new LoginPerformer(this)); 595 if (locale.empty()) {
588 is_login_in_progress_ = true; 596 // When performing auto-login, no locale is chosen by the user. Check
589 login_performer_->LoginAsPublicSession(user_context); 597 // whether a list of recommended locales was set by policy. If so, use its
590 SendAccessibilityAlert( 598 // first entry. Otherwise, |locale| will remain blank, indicating that the
591 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); 599 // public session should use the current UI locale.
600 const policy::PolicyMap::Entry* entry = g_browser_process->platform_part()->
601 browser_policy_connector_chromeos()->
602 GetDeviceLocalAccountPolicyService()->
603 GetBrokerForUser(user_context.GetUserID())->core()->store()->
604 policy_map().Get(policy::key::kSessionLocales);
605 base::ListValue const* list = NULL;
606 if (entry &&
607 entry->level == policy::POLICY_LEVEL_RECOMMENDED &&
608 entry->value &&
609 entry->value->GetAsList(&list)) {
610 if (list->GetString(0, &locale))
611 new_user_context.SetPublicSessionLocale(locale);
612 }
613 }
614
615 if (!locale.empty() &&
616 new_user_context.GetPublicSessionInputMethod().empty()) {
617 // When |locale| is set, a suitable keyboard layout should be chosen. In
618 // most cases, this will already be the case because the UI shows a list of
619 // keyboard layouts suitable for the |locale| and ensures that one of them
620 // us selected. However, it is still possible that |locale| is set but no
621 // keyboard layout was chosen:
622 // * The list of keyboard layouts is updated asynchronously. If the user
623 // enters the public session before the list of keyboard layouts for the
624 // |locale| has been retrieved, the UI will indicate that no keyboard
625 // layout was chosen.
626 // * During auto-login, the |locale| is set in this method and a suitable
627 // keyboard layout must be chosen next.
628 //
629 // The list of suitable keyboard layouts is constructed asynchronously. Once
630 // it has been retrieved, |SetPublicSessionKeyboardLayoutAndLogin| will
631 // select the first layout from the list and continue login.
632 GetKeyboardLayoutsForLocale(
633 base::Bind(
634 &ExistingUserController::SetPublicSessionKeyboardLayoutAndLogin,
635 weak_factory_.GetWeakPtr(),
636 new_user_context),
637 locale);
638 return;
639 }
640
641 // The user chose a locale and a suitable keyboard layout or left both unset.
642 // Login can continue immediately.
643 LoginAsPublicSessionInternal(new_user_context);
592 } 644 }
593 645
594 void ExistingUserController::LoginAsKioskApp(const std::string& app_id, 646 void ExistingUserController::LoginAsKioskApp(const std::string& app_id,
595 bool diagnostic_mode) { 647 bool diagnostic_mode) {
596 host_->StartAppLaunch(app_id, diagnostic_mode); 648 host_->StartAppLaunch(app_id, diagnostic_mode);
597 } 649 }
598 650
599 void ExistingUserController::OnSigninScreenReady() { 651 void ExistingUserController::OnSigninScreenReady() {
600 signin_screen_ready_ = true; 652 signin_screen_ready_ = true;
601 StartPublicSessionAutoLoginTimer(); 653 StartPublicSessionAutoLoginTimer();
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 login_display_->ShowGaiaPasswordChanged(username); 1209 login_display_->ShowGaiaPasswordChanged(username);
1158 } 1210 }
1159 1211
1160 void ExistingUserController::SendAccessibilityAlert( 1212 void ExistingUserController::SendAccessibilityAlert(
1161 const std::string& alert_text) { 1213 const std::string& alert_text) {
1162 AccessibilityAlertInfo event(ProfileHelper::GetSigninProfile(), alert_text); 1214 AccessibilityAlertInfo event(ProfileHelper::GetSigninProfile(), alert_text);
1163 SendControlAccessibilityNotification( 1215 SendControlAccessibilityNotification(
1164 ui::AX_EVENT_VALUE_CHANGED, &event); 1216 ui::AX_EVENT_VALUE_CHANGED, &event);
1165 } 1217 }
1166 1218
1219 void ExistingUserController::SetPublicSessionKeyboardLayoutAndLogin(
1220 const UserContext& user_context,
1221 scoped_ptr<base::ListValue> keyboard_layouts) {
1222 UserContext new_user_context = user_context;
1223 std::string keyboard_layout;
1224 for (size_t i = 0; i < keyboard_layouts->GetSize(); ++i) {
1225 base::DictionaryValue* entry = NULL;
1226 keyboard_layouts->GetDictionary(i, &entry);
1227 bool selected = false;
1228 entry->GetBoolean("selected", &selected);
1229 if (selected) {
1230 entry->GetString("value", &keyboard_layout);
1231 break;
1232 }
1233 }
1234 DCHECK(!keyboard_layout.empty());
1235 new_user_context.SetPublicSessionInputMethod(keyboard_layout);
1236
1237 LoginAsPublicSessionInternal(new_user_context);
1238 }
1239
1240 void ExistingUserController::LoginAsPublicSessionInternal(
1241 const UserContext& user_context) {
1242 // Only one instance of LoginPerformer should exist at a time.
1243 login_performer_.reset(NULL);
1244 login_performer_.reset(new LoginPerformer(this));
1245 is_login_in_progress_ = true;
1246 login_performer_->LoginAsPublicSession(user_context);
1247 SendAccessibilityAlert(
1248 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT));
1249 }
1250
1167 } // namespace chromeos 1251 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698