OLD | NEW |
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" | |
26 #include "chrome/browser/chrome_notification_types.h" | 25 #include "chrome/browser/chrome_notification_types.h" |
27 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 26 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
28 #include "chrome/browser/chromeos/boot_times_loader.h" | 27 #include "chrome/browser/chromeos/boot_times_loader.h" |
29 #include "chrome/browser/chromeos/customization_document.h" | 28 #include "chrome/browser/chromeos/customization_document.h" |
30 #include "chrome/browser/chromeos/first_run/first_run.h" | 29 #include "chrome/browser/chromeos/first_run/first_run.h" |
31 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" | 30 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" |
32 #include "chrome/browser/chromeos/login/helper.h" | 31 #include "chrome/browser/chromeos/login/helper.h" |
33 #include "chrome/browser/chromeos/login/login_utils.h" | 32 #include "chrome/browser/chromeos/login/login_utils.h" |
34 #include "chrome/browser/chromeos/login/startup_utils.h" | 33 #include "chrome/browser/chromeos/login/startup_utils.h" |
35 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 34 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
36 #include "chrome/browser/chromeos/login/users/user_manager.h" | 35 #include "chrome/browser/chromeos/login/users/user_manager.h" |
37 #include "chrome/browser/chromeos/login/wizard_controller.h" | 36 #include "chrome/browser/chromeos/login/wizard_controller.h" |
38 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 37 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
39 #include "chrome/browser/chromeos/policy/device_local_account.h" | 38 #include "chrome/browser/chromeos/policy/device_local_account.h" |
40 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" | |
41 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 39 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
42 #include "chrome/browser/chromeos/settings/cros_settings.h" | 40 #include "chrome/browser/chromeos/settings/cros_settings.h" |
43 #include "chrome/browser/prefs/session_startup_pref.h" | 41 #include "chrome/browser/prefs/session_startup_pref.h" |
44 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" | |
45 #include "chrome/common/chrome_switches.h" | 42 #include "chrome/common/chrome_switches.h" |
46 #include "chrome/common/chrome_version_info.h" | 43 #include "chrome/common/chrome_version_info.h" |
47 #include "chrome/common/pref_names.h" | 44 #include "chrome/common/pref_names.h" |
48 #include "chrome/common/url_constants.h" | 45 #include "chrome/common/url_constants.h" |
49 #include "chromeos/chromeos_switches.h" | 46 #include "chromeos/chromeos_switches.h" |
50 #include "chromeos/dbus/dbus_thread_manager.h" | 47 #include "chromeos/dbus/dbus_thread_manager.h" |
51 #include "chromeos/dbus/power_manager_client.h" | 48 #include "chromeos/dbus/power_manager_client.h" |
52 #include "chromeos/dbus/session_manager_client.h" | 49 #include "chromeos/dbus/session_manager_client.h" |
53 #include "chromeos/login/auth/user_context.h" | 50 #include "chromeos/login/auth/user_context.h" |
54 #include "chromeos/login/user_names.h" | 51 #include "chromeos/login/user_names.h" |
55 #include "chromeos/settings/cros_settings_names.h" | 52 #include "chromeos/settings/cros_settings_names.h" |
56 #include "components/google/core/browser/google_util.h" | 53 #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" | |
60 #include "components/policy/core/common/policy_service.h" | 54 #include "components/policy/core/common/policy_service.h" |
61 #include "components/policy/core/common/policy_types.h" | |
62 #include "components/user_manager/user_type.h" | 55 #include "components/user_manager/user_type.h" |
63 #include "content/public/browser/browser_thread.h" | 56 #include "content/public/browser/browser_thread.h" |
64 #include "content/public/browser/notification_service.h" | 57 #include "content/public/browser/notification_service.h" |
65 #include "content/public/browser/notification_types.h" | 58 #include "content/public/browser/notification_types.h" |
66 #include "content/public/browser/user_metrics.h" | 59 #include "content/public/browser/user_metrics.h" |
67 #include "google_apis/gaia/gaia_auth_util.h" | 60 #include "google_apis/gaia/gaia_auth_util.h" |
68 #include "google_apis/gaia/google_service_auth_error.h" | 61 #include "google_apis/gaia/google_service_auth_error.h" |
69 #include "grit/generated_resources.h" | 62 #include "grit/generated_resources.h" |
70 #include "net/http/http_auth_cache.h" | 63 #include "net/http/http_auth_cache.h" |
71 #include "net/http/http_network_session.h" | 64 #include "net/http/http_network_session.h" |
72 #include "net/http/http_transaction_factory.h" | 65 #include "net/http/http_transaction_factory.h" |
73 #include "net/url_request/url_request_context.h" | 66 #include "net/url_request/url_request_context.h" |
74 #include "net/url_request/url_request_context_getter.h" | 67 #include "net/url_request/url_request_context_getter.h" |
75 #include "policy/policy_constants.h" | |
76 #include "ui/accessibility/ax_enums.h" | 68 #include "ui/accessibility/ax_enums.h" |
77 #include "ui/base/l10n/l10n_util.h" | 69 #include "ui/base/l10n/l10n_util.h" |
78 #include "ui/views/widget/widget.h" | 70 #include "ui/views/widget/widget.h" |
79 | 71 |
80 namespace chromeos { | 72 namespace chromeos { |
81 | 73 |
82 namespace { | 74 namespace { |
83 | 75 |
84 // URL for account creation. | 76 // URL for account creation. |
85 const char kCreateAccountURL[] = | 77 const char kCreateAccountURL[] = |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 // possible. | 575 // possible. |
584 const user_manager::User* user = | 576 const user_manager::User* user = |
585 UserManager::Get()->FindUser(user_context.GetUserID()); | 577 UserManager::Get()->FindUser(user_context.GetUserID()); |
586 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) { | 578 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) { |
587 // Re-enable clicking on other windows. | 579 // Re-enable clicking on other windows. |
588 login_display_->SetUIEnabled(true); | 580 login_display_->SetUIEnabled(true); |
589 StartPublicSessionAutoLoginTimer(); | 581 StartPublicSessionAutoLoginTimer(); |
590 return; | 582 return; |
591 } | 583 } |
592 | 584 |
593 UserContext new_user_context = user_context; | 585 // Only one instance of LoginPerformer should exist at a time. |
594 std::string locale = user_context.GetPublicSessionLocale(); | 586 login_performer_.reset(NULL); |
595 if (locale.empty()) { | 587 login_performer_.reset(new LoginPerformer(this)); |
596 // When performing auto-login, no locale is chosen by the user. Check | 588 is_login_in_progress_ = true; |
597 // whether a list of recommended locales was set by policy. If so, use its | 589 login_performer_->LoginAsPublicSession(user_context); |
598 // first entry. Otherwise, |locale| will remain blank, indicating that the | 590 SendAccessibilityAlert( |
599 // public session should use the current UI locale. | 591 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); |
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); | |
644 } | 592 } |
645 | 593 |
646 void ExistingUserController::LoginAsKioskApp(const std::string& app_id, | 594 void ExistingUserController::LoginAsKioskApp(const std::string& app_id, |
647 bool diagnostic_mode) { | 595 bool diagnostic_mode) { |
648 host_->StartAppLaunch(app_id, diagnostic_mode); | 596 host_->StartAppLaunch(app_id, diagnostic_mode); |
649 } | 597 } |
650 | 598 |
651 void ExistingUserController::OnSigninScreenReady() { | 599 void ExistingUserController::OnSigninScreenReady() { |
652 signin_screen_ready_ = true; | 600 signin_screen_ready_ = true; |
653 StartPublicSessionAutoLoginTimer(); | 601 StartPublicSessionAutoLoginTimer(); |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 login_display_->ShowGaiaPasswordChanged(username); | 1157 login_display_->ShowGaiaPasswordChanged(username); |
1210 } | 1158 } |
1211 | 1159 |
1212 void ExistingUserController::SendAccessibilityAlert( | 1160 void ExistingUserController::SendAccessibilityAlert( |
1213 const std::string& alert_text) { | 1161 const std::string& alert_text) { |
1214 AccessibilityAlertInfo event(ProfileHelper::GetSigninProfile(), alert_text); | 1162 AccessibilityAlertInfo event(ProfileHelper::GetSigninProfile(), alert_text); |
1215 SendControlAccessibilityNotification( | 1163 SendControlAccessibilityNotification( |
1216 ui::AX_EVENT_VALUE_CHANGED, &event); | 1164 ui::AX_EVENT_VALUE_CHANGED, &event); |
1217 } | 1165 } |
1218 | 1166 |
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 | |
1251 } // namespace chromeos | 1167 } // namespace chromeos |
OLD | NEW |