| OLD | NEW |
| 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/chrome_user_selection_screen.h" | 5 #include "chrome/browser/chromeos/login/screens/chrome_user_selection_screen.h" |
| 6 | 6 |
| 7 #include <memory> |
| 7 #include <utility> | 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/location.h" | 11 #include "base/location.h" |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/browser_process_platform_part.h" | 17 #include "chrome/browser/browser_process_platform_part.h" |
| 18 #include "chrome/browser/chromeos/login/ui/views/user_board_view.h" | 18 #include "chrome/browser/chromeos/login/ui/views/user_board_view.h" |
| 19 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 19 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 20 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" | 20 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" |
| 21 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" | 21 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
| 22 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 22 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 160 } |
| 161 | 161 |
| 162 void ChromeUserSelectionScreen::SetPublicSessionLocales( | 162 void ChromeUserSelectionScreen::SetPublicSessionLocales( |
| 163 const AccountId& account_id, | 163 const AccountId& account_id, |
| 164 const std::vector<std::string>& recommended_locales) { | 164 const std::vector<std::string>& recommended_locales) { |
| 165 if (!handler_initialized_) | 165 if (!handler_initialized_) |
| 166 return; | 166 return; |
| 167 | 167 |
| 168 // Construct the list of available locales. This list consists of the | 168 // Construct the list of available locales. This list consists of the |
| 169 // recommended locales, followed by all others. | 169 // recommended locales, followed by all others. |
| 170 scoped_ptr<base::ListValue> available_locales = | 170 std::unique_ptr<base::ListValue> available_locales = |
| 171 GetUILanguageList(&recommended_locales, std::string()); | 171 GetUILanguageList(&recommended_locales, std::string()); |
| 172 | 172 |
| 173 // Set the initially selected locale to the first recommended locale that is | 173 // Set the initially selected locale to the first recommended locale that is |
| 174 // actually available or the current UI locale if none of them are available. | 174 // actually available or the current UI locale if none of them are available. |
| 175 const std::string default_locale = FindMostRelevantLocale( | 175 const std::string default_locale = FindMostRelevantLocale( |
| 176 recommended_locales, | 176 recommended_locales, |
| 177 *available_locales.get(), | 177 *available_locales.get(), |
| 178 g_browser_process->GetApplicationLocale()); | 178 g_browser_process->GetApplicationLocale()); |
| 179 | 179 |
| 180 // Set a flag to indicate whether the list of recommended locales contains at | 180 // Set a flag to indicate whether the list of recommended locales contains at |
| 181 // least two entries. This is used to decide whether the public session pod | 181 // least two entries. This is used to decide whether the public session pod |
| 182 // expands to its basic form (for zero or one recommended locales) or the | 182 // expands to its basic form (for zero or one recommended locales) or the |
| 183 // advanced form (two or more recommended locales). | 183 // advanced form (two or more recommended locales). |
| 184 const bool two_or_more_recommended_locales = recommended_locales.size() >= 2; | 184 const bool two_or_more_recommended_locales = recommended_locales.size() >= 2; |
| 185 | 185 |
| 186 // Notify the UI. | 186 // Notify the UI. |
| 187 view_->SetPublicSessionLocales(account_id, std::move(available_locales), | 187 view_->SetPublicSessionLocales(account_id, std::move(available_locales), |
| 188 default_locale, | 188 default_locale, |
| 189 two_or_more_recommended_locales); | 189 two_or_more_recommended_locales); |
| 190 } | 190 } |
| 191 | 191 |
| 192 } // namespace chromeos | 192 } // namespace chromeos |
| OLD | NEW |