| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/chromeos/login/terms_of_service_screen_handler
.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler
.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/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 13 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chromeos/base/locale_util.h" | 16 #include "chrome/browser/chromeos/base/locale_util.h" |
| 17 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h" | 17 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h" |
| 18 #include "chrome/browser/chromeos/login/users/user_manager.h" | |
| 19 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 18 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/profiles/profile_manager.h" |
| 21 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 21 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 23 #include "chromeos/ime/input_method_manager.h" | 23 #include "chromeos/ime/input_method_manager.h" |
| 24 #include "components/user_manager/user.h" | 24 #include "components/user_manager/user.h" |
| 25 #include "components/user_manager/user_manager.h" |
| 25 #include "content/public/browser/web_ui.h" | 26 #include "content/public/browser/web_ui.h" |
| 26 #include "grit/chromium_strings.h" | 27 #include "grit/chromium_strings.h" |
| 27 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 const char kJsScreenPath[] = "login.TermsOfServiceScreen"; | 32 const char kJsScreenPath[] = "login.TermsOfServiceScreen"; |
| 32 | 33 |
| 33 } // namespace | 34 } // namespace |
| 34 | 35 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } | 78 } |
| 78 | 79 |
| 79 void TermsOfServiceScreenHandler::Show() { | 80 void TermsOfServiceScreenHandler::Show() { |
| 80 if (!page_is_ready()) { | 81 if (!page_is_ready()) { |
| 81 show_on_init_ = true; | 82 show_on_init_ = true; |
| 82 return; | 83 return; |
| 83 } | 84 } |
| 84 | 85 |
| 85 const std::string locale = | 86 const std::string locale = |
| 86 ProfileHelper::Get() | 87 ProfileHelper::Get() |
| 87 ->GetProfileByUserUnsafe(UserManager::Get()->GetActiveUser()) | 88 ->GetProfileByUserUnsafe( |
| 89 user_manager::UserManager::Get()->GetActiveUser()) |
| 88 ->GetPrefs() | 90 ->GetPrefs() |
| 89 ->GetString(prefs::kApplicationLocale); | 91 ->GetString(prefs::kApplicationLocale); |
| 92 |
| 90 if (locale.empty() || locale == g_browser_process->GetApplicationLocale()) { | 93 if (locale.empty() || locale == g_browser_process->GetApplicationLocale()) { |
| 91 // If the user has not chosen a UI locale yet or the chosen locale matches | 94 // If the user has not chosen a UI locale yet or the chosen locale matches |
| 92 // the current UI locale, show the screen immediately. | 95 // the current UI locale, show the screen immediately. |
| 93 DoShow(); | 96 DoShow(); |
| 94 return; | 97 return; |
| 95 } | 98 } |
| 96 | 99 |
| 97 // Switch to the user's UI locale before showing the screen. | 100 // Switch to the user's UI locale before showing the screen. |
| 98 scoped_ptr<locale_util::SwitchLanguageCallback> callback( | 101 scoped_ptr<locale_util::SwitchLanguageCallback> callback( |
| 99 new locale_util::SwitchLanguageCallback( | 102 new locale_util::SwitchLanguageCallback( |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 core_oobe_actor_->ReloadContent(localized_strings); | 147 core_oobe_actor_->ReloadContent(localized_strings); |
| 145 | 148 |
| 146 DoShow(); | 149 DoShow(); |
| 147 } | 150 } |
| 148 | 151 |
| 149 void TermsOfServiceScreenHandler::DoShow() { | 152 void TermsOfServiceScreenHandler::DoShow() { |
| 150 // Determine the user's most preferred input method. | 153 // Determine the user's most preferred input method. |
| 151 std::vector<std::string> input_methods; | 154 std::vector<std::string> input_methods; |
| 152 base::SplitString( | 155 base::SplitString( |
| 153 ProfileHelper::Get() | 156 ProfileHelper::Get() |
| 154 ->GetProfileByUserUnsafe(UserManager::Get()->GetActiveUser()) | 157 ->GetProfileByUserUnsafe( |
| 158 user_manager::UserManager::Get()->GetActiveUser()) |
| 155 ->GetPrefs() | 159 ->GetPrefs() |
| 156 ->GetString(prefs::kLanguagePreloadEngines), | 160 ->GetString(prefs::kLanguagePreloadEngines), |
| 157 ',', | 161 ',', |
| 158 &input_methods); | 162 &input_methods); |
| 159 | 163 |
| 160 if (!input_methods.empty()) { | 164 if (!input_methods.empty()) { |
| 161 // If the user has a preferred input method, enable it and switch to it. | 165 // If the user has a preferred input method, enable it and switch to it. |
| 162 chromeos::input_method::InputMethodManager* input_method_manager = | 166 chromeos::input_method::InputMethodManager* input_method_manager = |
| 163 chromeos::input_method::InputMethodManager::Get(); | 167 chromeos::input_method::InputMethodManager::Get(); |
| 164 input_method_manager->EnableInputMethod(input_methods.front()); | 168 input_method_manager->EnableInputMethod(input_methods.front()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 // and continue" button should not be accessible. If the user managed to | 210 // and continue" button should not be accessible. If the user managed to |
| 207 // activate it somehow anway, do not treat this as acceptance of the Terms | 211 // activate it somehow anway, do not treat this as acceptance of the Terms |
| 208 // and Conditions and end the session instead, as if the user had declined. | 212 // and Conditions and end the session instead, as if the user had declined. |
| 209 if (terms_of_service_.empty()) | 213 if (terms_of_service_.empty()) |
| 210 screen_->OnDecline(); | 214 screen_->OnDecline(); |
| 211 else | 215 else |
| 212 screen_->OnAccept(); | 216 screen_->OnAccept(); |
| 213 } | 217 } |
| 214 | 218 |
| 215 } // namespace chromeos | 219 } // namespace chromeos |
| OLD | NEW |