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" |
21 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 20 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
22 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
23 #include "chromeos/ime/input_method_manager.h" | 22 #include "chromeos/ime/input_method_manager.h" |
24 #include "components/user_manager/user.h" | 23 #include "components/user_manager/user.h" |
24 #include "components/user_manager/user_manager.h" | |
25 #include "content/public/browser/web_ui.h" | 25 #include "content/public/browser/web_ui.h" |
26 #include "grit/chromium_strings.h" | 26 #include "grit/chromium_strings.h" |
27 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 const char kJsScreenPath[] = "login.TermsOfServiceScreen"; | 31 const char kJsScreenPath[] = "login.TermsOfServiceScreen"; |
32 | 32 |
33 } // namespace | 33 } // namespace |
34 | 34 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 void TermsOfServiceScreenHandler::SetDelegate(Delegate* screen) { | 75 void TermsOfServiceScreenHandler::SetDelegate(Delegate* screen) { |
76 screen_ = screen; | 76 screen_ = screen; |
77 } | 77 } |
78 | 78 |
79 void TermsOfServiceScreenHandler::Show() { | 79 void TermsOfServiceScreenHandler::Show() { |
80 if (!page_is_ready()) { | 80 if (!page_is_ready()) { |
81 show_on_init_ = true; | 81 show_on_init_ = true; |
82 return; | 82 return; |
83 } | 83 } |
84 | 84 |
85 const std::string locale = ProfileHelper::Get()->GetProfileByUser( | 85 const std::string locale = |
86 UserManager::Get()->GetActiveUser())->GetPrefs()->GetString( | 86 ProfileHelper::Get() |
87 prefs::kApplicationLocale); | 87 ->GetProfileByUser(user_manager::UserManager::Get()->GetActiveUser()) |
Dmitry Polukhin
2014/08/12 09:03:13
ProfileManager::GetActiveUserProfile()?
Nikita (slow)
2014/08/12 09:34:42
Done.
| |
88 ->GetPrefs() | |
89 ->GetString(prefs::kApplicationLocale); | |
88 if (locale.empty() || locale == g_browser_process->GetApplicationLocale()) { | 90 if (locale.empty() || locale == g_browser_process->GetApplicationLocale()) { |
89 // If the user has not chosen a UI locale yet or the chosen locale matches | 91 // If the user has not chosen a UI locale yet or the chosen locale matches |
90 // the current UI locale, show the screen immediately. | 92 // the current UI locale, show the screen immediately. |
91 DoShow(); | 93 DoShow(); |
92 return; | 94 return; |
93 } | 95 } |
94 | 96 |
95 // Switch to the user's UI locale before showing the screen. | 97 // Switch to the user's UI locale before showing the screen. |
96 scoped_ptr<locale_util::SwitchLanguageCallback> callback( | 98 scoped_ptr<locale_util::SwitchLanguageCallback> callback( |
97 new locale_util::SwitchLanguageCallback( | 99 new locale_util::SwitchLanguageCallback( |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 ->GetLocalizedStrings(&localized_strings); | 143 ->GetLocalizedStrings(&localized_strings); |
142 core_oobe_actor_->ReloadContent(localized_strings); | 144 core_oobe_actor_->ReloadContent(localized_strings); |
143 | 145 |
144 DoShow(); | 146 DoShow(); |
145 } | 147 } |
146 | 148 |
147 void TermsOfServiceScreenHandler::DoShow() { | 149 void TermsOfServiceScreenHandler::DoShow() { |
148 // Determine the user's most preferred input method. | 150 // Determine the user's most preferred input method. |
149 std::vector<std::string> input_methods; | 151 std::vector<std::string> input_methods; |
150 base::SplitString( | 152 base::SplitString( |
151 ProfileHelper::Get()->GetProfileByUser( | 153 ProfileHelper::Get() |
152 UserManager::Get()->GetActiveUser())->GetPrefs()->GetString( | 154 ->GetProfileByUser(user_manager::UserManager::Get()->GetActiveUser()) |
Dmitry Polukhin
2014/08/12 09:03:13
Use ProfileManager::GetActiveUserProfile()?
Nikita (slow)
2014/08/12 09:34:42
Done.
| |
153 prefs::kLanguagePreloadEngines), | 155 ->GetPrefs() |
156 ->GetString(prefs::kLanguagePreloadEngines), | |
154 ',', | 157 ',', |
155 &input_methods); | 158 &input_methods); |
156 | 159 |
157 if (!input_methods.empty()) { | 160 if (!input_methods.empty()) { |
158 // If the user has a preferred input method, enable it and switch to it. | 161 // If the user has a preferred input method, enable it and switch to it. |
159 chromeos::input_method::InputMethodManager* input_method_manager = | 162 chromeos::input_method::InputMethodManager* input_method_manager = |
160 chromeos::input_method::InputMethodManager::Get(); | 163 chromeos::input_method::InputMethodManager::Get(); |
161 input_method_manager->EnableInputMethod(input_methods.front()); | 164 input_method_manager->EnableInputMethod(input_methods.front()); |
162 input_method_manager->ChangeInputMethod(input_methods.front()); | 165 input_method_manager->ChangeInputMethod(input_methods.front()); |
163 } | 166 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 // and continue" button should not be accessible. If the user managed to | 206 // and continue" button should not be accessible. If the user managed to |
204 // activate it somehow anway, do not treat this as acceptance of the Terms | 207 // activate it somehow anway, do not treat this as acceptance of the Terms |
205 // and Conditions and end the session instead, as if the user had declined. | 208 // and Conditions and end the session instead, as if the user had declined. |
206 if (terms_of_service_.empty()) | 209 if (terms_of_service_.empty()) |
207 screen_->OnDecline(); | 210 screen_->OnDecline(); |
208 else | 211 else |
209 screen_->OnAccept(); | 212 screen_->OnAccept(); |
210 } | 213 } |
211 | 214 |
212 } // namespace chromeos | 215 } // namespace chromeos |
OLD | NEW |