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

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

Issue 483523005: Default to current UI locale when recommended locales are invalid (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit tests, for real this time. 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 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/user_selection_screen.h" 5 #include "chrome/browser/chromeos/login/screens/user_selection_screen.h"
6 6
7 #include <vector>
8
9 #include "ash/shell.h" 7 #include "ash/shell.h"
10 #include "base/location.h" 8 #include "base/location.h"
11 #include "base/logging.h" 9 #include "base/logging.h"
12 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
13 #include "base/values.h" 11 #include "base/values.h"
14 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/browser_process_platform_part.h" 13 #include "chrome/browser/browser_process_platform_part.h"
16 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 14 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
17 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" 15 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
18 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" 16 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 const std::vector<std::string>* public_session_recommended_locales) { 57 const std::vector<std::string>* public_session_recommended_locales) {
60 policy::BrowserPolicyConnectorChromeOS* policy_connector = 58 policy::BrowserPolicyConnectorChromeOS* policy_connector =
61 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 59 g_browser_process->platform_part()->browser_policy_connector_chromeos();
62 60
63 if (policy_connector->IsEnterpriseManaged()) { 61 if (policy_connector->IsEnterpriseManaged()) {
64 user_dict->SetString(kKeyEnterpriseDomain, 62 user_dict->SetString(kKeyEnterpriseDomain,
65 policy_connector->GetEnterpriseDomain()); 63 policy_connector->GetEnterpriseDomain());
66 } 64 }
67 65
68 std::vector<std::string> kEmptyRecommendedLocales; 66 std::vector<std::string> kEmptyRecommendedLocales;
69 const std::vector<std::string>* recommended_locales = 67 const std::vector<std::string>& recommended_locales =
70 public_session_recommended_locales ? 68 public_session_recommended_locales ?
71 public_session_recommended_locales : &kEmptyRecommendedLocales; 69 *public_session_recommended_locales : kEmptyRecommendedLocales;
72 70
73 // Set |kKeyInitialLocales| to the list of available locales. This list 71 // Construct the list of available locales. This list consists of the
74 // consists of the recommended locales, followed by all others. 72 // recommended locales, followed by all others.
75 user_dict->Set( 73 scoped_ptr<base::ListValue> available_locales =
76 kKeyInitialLocales, 74 GetUILanguageList(&recommended_locales, std::string());
77 GetUILanguageList(recommended_locales, std::string()).release());
78 75
79 // Set |kKeyInitialLocale| to the initially selected locale. If the list of 76 // Select the the first recommended locale that is actually available or the
80 // recommended locales is not empty, select its first entry. Otherwise, 77 // current UI locale if none of them are available.
81 // select the current UI locale. 78 const std::string selected_locale = FindMostRelevantLocale(
82 user_dict->SetString(kKeyInitialLocale, 79 recommended_locales,
83 recommended_locales->empty() ? 80 *available_locales.get(),
84 g_browser_process->GetApplicationLocale() : 81 g_browser_process->GetApplicationLocale());
85 recommended_locales->front()); 82
83 // Set |kKeyInitialLocales| to the list of available locales.
84 user_dict->Set(kKeyInitialLocales, available_locales.release());
85
86 // Set |kKeyInitialLocale| to the initially selected locale.
87 user_dict->SetString(kKeyInitialLocale, selected_locale);
86 88
87 // Set |kKeyInitialMultipleRecommendedLocales| to indicate whether the list 89 // Set |kKeyInitialMultipleRecommendedLocales| to indicate whether the list
88 // of recommended locales contains at least two entries. This is used to 90 // of recommended locales contains at least two entries. This is used to
89 // decide whether the public session pod expands to its basic form (for zero 91 // decide whether the public session pod expands to its basic form (for zero
90 // or one recommended locales) or the advanced form (two or more recommended 92 // or one recommended locales) or the advanced form (two or more recommended
91 // locales). 93 // locales).
92 user_dict->SetBoolean(kKeyInitialMultipleRecommendedLocales, 94 user_dict->SetBoolean(kKeyInitialMultipleRecommendedLocales,
93 recommended_locales->size() >= 2); 95 recommended_locales.size() >= 2);
94 96
95 // Set |kKeyInitialKeyboardLayout| to the current keyboard layout. This 97 // Set |kKeyInitialKeyboardLayout| to the current keyboard layout. This
96 // value will be used temporarily only because the UI immediately requests a 98 // value will be used temporarily only because the UI immediately requests a
97 // list of keyboard layouts suitable for the currently selected locale. 99 // list of keyboard layouts suitable for the currently selected locale.
98 user_dict->Set(kKeyInitialKeyboardLayout, 100 user_dict->Set(kKeyInitialKeyboardLayout,
99 GetCurrentKeyboardLayout().release()); 101 GetCurrentKeyboardLayout().release());
100 } 102 }
101 103
102 } // namespace 104 } // namespace
103 105
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 } 371 }
370 372
371 ScreenlockBridge::LockHandler::AuthType UserSelectionScreen::GetAuthType( 373 ScreenlockBridge::LockHandler::AuthType UserSelectionScreen::GetAuthType(
372 const std::string& username) const { 374 const std::string& username) const {
373 if (user_auth_type_map_.find(username) == user_auth_type_map_.end()) 375 if (user_auth_type_map_.find(username) == user_auth_type_map_.end())
374 return ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; 376 return ScreenlockBridge::LockHandler::OFFLINE_PASSWORD;
375 return user_auth_type_map_.find(username)->second; 377 return user_auth_type_map_.find(username)->second;
376 } 378 }
377 379
378 } // namespace chromeos 380 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698