OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/gaia_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/browser_shutdown.h" | 14 #include "chrome/browser/browser_shutdown.h" |
15 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 15 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
16 #include "chrome/browser/chromeos/language_preferences.h" | 16 #include "chrome/browser/chromeos/language_preferences.h" |
17 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 17 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
18 #include "chrome/browser/chromeos/policy/consumer_management_service.h" | 18 #include "chrome/browser/chromeos/policy/consumer_management_service.h" |
19 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 19 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
20 #include "chrome/browser/chromeos/settings/cros_settings.h" | 20 #include "chrome/browser/chromeos/settings/cros_settings.h" |
21 #include "chrome/browser/io_thread.h" | 21 #include "chrome/browser/io_thread.h" |
22 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" | 22 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
23 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" | 23 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" |
| 24 #include "chrome/common/chrome_version_info.h" |
24 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
25 #include "chrome/grit/generated_resources.h" | 26 #include "chrome/grit/generated_resources.h" |
26 #include "chromeos/chromeos_switches.h" | 27 #include "chromeos/chromeos_switches.h" |
27 #include "chromeos/ime/input_method_manager.h" | 28 #include "chromeos/ime/input_method_manager.h" |
28 #include "chromeos/settings/cros_settings_names.h" | 29 #include "chromeos/settings/cros_settings_names.h" |
29 #include "components/user_manager/user_manager.h" | 30 #include "components/user_manager/user_manager.h" |
30 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
31 #include "content/public/browser/render_frame_host.h" | 32 #include "content/public/browser/render_frame_host.h" |
32 #include "google_apis/gaia/gaia_auth_util.h" | 33 #include "google_apis/gaia/gaia_auth_util.h" |
33 #include "google_apis/gaia/gaia_switches.h" | 34 #include "google_apis/gaia/gaia_switches.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 consumer_management_(consumer_management), | 140 consumer_management_(consumer_management), |
140 core_oobe_actor_(core_oobe_actor), | 141 core_oobe_actor_(core_oobe_actor), |
141 dns_cleared_(false), | 142 dns_cleared_(false), |
142 dns_clear_task_running_(false), | 143 dns_clear_task_running_(false), |
143 cookies_cleared_(false), | 144 cookies_cleared_(false), |
144 focus_stolen_(false), | 145 focus_stolen_(false), |
145 gaia_silent_load_(false), | 146 gaia_silent_load_(false), |
146 using_saml_api_(false), | 147 using_saml_api_(false), |
147 is_enrolling_consumer_management_(false), | 148 is_enrolling_consumer_management_(false), |
148 test_expects_complete_login_(false), | 149 test_expects_complete_login_(false), |
| 150 embedded_signin_enabled_by_shortcut_(false), |
149 signin_screen_handler_(NULL), | 151 signin_screen_handler_(NULL), |
150 weak_factory_(this) { | 152 weak_factory_(this) { |
151 DCHECK(network_state_informer_.get()); | 153 DCHECK(network_state_informer_.get()); |
152 } | 154 } |
153 | 155 |
154 GaiaScreenHandler::~GaiaScreenHandler() { | 156 GaiaScreenHandler::~GaiaScreenHandler() { |
155 } | 157 } |
156 | 158 |
157 void GaiaScreenHandler::LoadGaia(const GaiaContext& context) { | 159 void GaiaScreenHandler::LoadGaia(const GaiaContext& context) { |
158 base::DictionaryValue params; | 160 base::DictionaryValue params; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 199 } |
198 | 200 |
199 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 201 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
200 | 202 |
201 const GURL gaia_url = | 203 const GURL gaia_url = |
202 command_line->HasSwitch(::switches::kGaiaUrl) | 204 command_line->HasSwitch(::switches::kGaiaUrl) |
203 ? GURL(command_line->GetSwitchValueASCII(::switches::kGaiaUrl)) | 205 ? GURL(command_line->GetSwitchValueASCII(::switches::kGaiaUrl)) |
204 : GaiaUrls::GetInstance()->gaia_url(); | 206 : GaiaUrls::GetInstance()->gaia_url(); |
205 params.SetString("gaiaUrl", gaia_url.spec()); | 207 params.SetString("gaiaUrl", gaia_url.spec()); |
206 | 208 |
207 if (command_line->HasSwitch(chromeos::switches::kEnableEmbeddedSignin)) | 209 if (context.embedded_signin_enabled) |
208 params.SetBoolean("useEmbedded", true); | 210 params.SetBoolean("useEmbedded", true); |
209 | 211 |
210 frame_state_ = FRAME_STATE_LOADING; | 212 frame_state_ = FRAME_STATE_LOADING; |
211 CallJS("loadAuthExtension", params); | 213 CallJS("loadAuthExtension", params); |
212 } | 214 } |
213 | 215 |
214 void GaiaScreenHandler::UpdateGaia(const GaiaContext& context) { | 216 void GaiaScreenHandler::UpdateGaia(const GaiaContext& context) { |
215 base::DictionaryValue params; | 217 base::DictionaryValue params; |
216 UpdateAuthParams(¶ms, context.has_users, | 218 UpdateAuthParams(¶ms, context.has_users, |
217 context.is_enrolling_consumer_management); | 219 context.is_enrolling_consumer_management); |
218 CallJS("updateAuthExtension", params); | 220 CallJS("updateAuthExtension", params); |
219 } | 221 } |
220 | 222 |
221 void GaiaScreenHandler::ReloadGaia(bool force_reload) { | 223 void GaiaScreenHandler::ReloadGaia(bool force_reload) { |
222 if (frame_state_ == FRAME_STATE_LOADING && !force_reload) { | 224 if (frame_state_ == FRAME_STATE_LOADING && !force_reload) { |
223 VLOG(1) << "Skipping reloading of Gaia since gaia is loading."; | 225 VLOG(1) << "Skipping reloading of Gaia since gaia is loading."; |
224 return; | 226 return; |
225 } | 227 } |
226 NetworkStateInformer::State state = network_state_informer_->state(); | 228 NetworkStateInformer::State state = network_state_informer_->state(); |
227 if (state != NetworkStateInformer::ONLINE) { | 229 if (state != NetworkStateInformer::ONLINE) { |
228 VLOG(1) << "Skipping reloading of Gaia since network state=" | 230 VLOG(1) << "Skipping reloading of Gaia since network state=" |
229 << NetworkStateInformer::StatusString(state); | 231 << NetworkStateInformer::StatusString(state); |
230 return; | 232 return; |
231 } | 233 } |
232 VLOG(1) << "Reloading Gaia."; | 234 VLOG(1) << "Reloading Gaia."; |
233 frame_state_ = FRAME_STATE_LOADING; | 235 frame_state_ = FRAME_STATE_LOADING; |
234 CallJS("doReload"); | 236 CallJS("doReload"); |
235 } | 237 } |
236 | 238 |
| 239 void GaiaScreenHandler::SwitchToEmbeddedSignin() { |
| 240 // This feature should not be working on Stable,Beta images. |
| 241 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 242 if (channel == chrome::VersionInfo::CHANNEL_STABLE || |
| 243 channel == chrome::VersionInfo::CHANNEL_BETA) { |
| 244 return; |
| 245 } |
| 246 embedded_signin_enabled_by_shortcut_ = true; |
| 247 LoadAuthExtension( |
| 248 true /* force */, true /* silent_load */, false /* offline */); |
| 249 } |
| 250 |
| 251 void GaiaScreenHandler::CancelEmbeddedSignin() { |
| 252 embedded_signin_enabled_by_shortcut_ = false; |
| 253 } |
| 254 |
237 void GaiaScreenHandler::DeclareLocalizedValues( | 255 void GaiaScreenHandler::DeclareLocalizedValues( |
238 LocalizedValuesBuilder* builder) { | 256 LocalizedValuesBuilder* builder) { |
239 builder->Add("signinScreenTitle", IDS_SIGNIN_SCREEN_TITLE); | 257 builder->Add("signinScreenTitle", IDS_SIGNIN_SCREEN_TITLE); |
240 builder->Add("signinScreenPasswordChanged", | 258 builder->Add("signinScreenPasswordChanged", |
241 IDS_SIGNIN_SCREEN_PASSWORD_CHANGED); | 259 IDS_SIGNIN_SCREEN_PASSWORD_CHANGED); |
242 builder->Add("createAccount", IDS_CREATE_ACCOUNT_HTML); | 260 builder->Add("createAccount", IDS_CREATE_ACCOUNT_HTML); |
243 builder->Add("guestSignin", IDS_BROWSE_WITHOUT_SIGNING_IN_HTML); | 261 builder->Add("guestSignin", IDS_BROWSE_WITHOUT_SIGNING_IN_HTML); |
244 builder->Add("createSupervisedUser", | 262 builder->Add("createSupervisedUser", |
245 IDS_CREATE_SUPERVISED_USER_HTML); | 263 IDS_CREATE_SUPERVISED_USER_HTML); |
246 builder->Add("createSupervisedUserFeatureName", | 264 builder->Add("createSupervisedUserFeatureName", |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 context.password_changed = !populated_email_.empty() && | 665 context.password_changed = !populated_email_.empty() && |
648 password_changed_for_.count(populated_email_); | 666 password_changed_for_.count(populated_email_); |
649 context.use_offline = offline; | 667 context.use_offline = offline; |
650 context.email = populated_email_; | 668 context.email = populated_email_; |
651 context.is_enrolling_consumer_management = is_enrolling_consumer_management_; | 669 context.is_enrolling_consumer_management = is_enrolling_consumer_management_; |
652 if (Delegate()) { | 670 if (Delegate()) { |
653 context.show_users = Delegate()->IsShowUsers(); | 671 context.show_users = Delegate()->IsShowUsers(); |
654 context.has_users = !Delegate()->GetUsers().empty(); | 672 context.has_users = !Delegate()->GetUsers().empty(); |
655 } | 673 } |
656 | 674 |
| 675 context.embedded_signin_enabled = |
| 676 CommandLine::ForCurrentProcess()->HasSwitch( |
| 677 chromeos::switches::kEnableEmbeddedSignin) || |
| 678 embedded_signin_enabled_by_shortcut_; |
| 679 |
657 populated_email_.clear(); | 680 populated_email_.clear(); |
658 | 681 |
659 LoadGaia(context); | 682 LoadGaia(context); |
660 } | 683 } |
661 | 684 |
662 void GaiaScreenHandler::UpdateState(ErrorScreenActor::ErrorReason reason) { | 685 void GaiaScreenHandler::UpdateState(ErrorScreenActor::ErrorReason reason) { |
663 if (signin_screen_handler_) | 686 if (signin_screen_handler_) |
664 signin_screen_handler_->UpdateState(reason); | 687 signin_screen_handler_->UpdateState(reason); |
665 } | 688 } |
666 | 689 |
667 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { | 690 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { |
668 DCHECK(signin_screen_handler_); | 691 DCHECK(signin_screen_handler_); |
669 return signin_screen_handler_->delegate_; | 692 return signin_screen_handler_->delegate_; |
670 } | 693 } |
671 | 694 |
672 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { | 695 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { |
673 signin_screen_handler_ = handler; | 696 signin_screen_handler_ = handler; |
674 } | 697 } |
675 } // namespace chromeos | 698 } // namespace chromeos |
OLD | NEW |