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

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc

Issue 1831523003: FR: SAML Sign In - Interstitial page to send users directly to IdP login screen (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove the <br> comment Created 4 years, 8 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
« no previous file with comments | « chrome/browser/resources/gaia_auth_host/authenticator.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ash/system/chromeos/devicetype_utils.h" 7 #include "ash/system/chromeos/devicetype_utils.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/browser_shutdown.h" 15 #include "chrome/browser/browser_shutdown.h"
16 #include "chrome/browser/chromeos/input_method/input_method_util.h" 16 #include "chrome/browser/chromeos/input_method/input_method_util.h"
17 #include "chrome/browser/chromeos/language_preferences.h" 17 #include "chrome/browser/chromeos/language_preferences.h"
18 #include "chrome/browser/chromeos/login/screens/network_error.h" 18 #include "chrome/browser/chromeos/login/screens/network_error.h"
19 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" 19 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
20 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" 20 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
21 #include "chrome/browser/chromeos/net/network_portal_detector_impl.h" 21 #include "chrome/browser/chromeos/net/network_portal_detector_impl.h"
22 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 22 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
23 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
23 #include "chrome/browser/chromeos/profiles/profile_helper.h" 24 #include "chrome/browser/chromeos/profiles/profile_helper.h"
24 #include "chrome/browser/chromeos/settings/cros_settings.h" 25 #include "chrome/browser/chromeos/settings/cros_settings.h"
25 #include "chrome/browser/io_thread.h" 26 #include "chrome/browser/io_thread.h"
26 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" 27 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
27 #include "chrome/browser/ui/webui/signin/get_auth_frame.h" 28 #include "chrome/browser/ui/webui/signin/get_auth_frame.h"
28 #include "chrome/common/channel_info.h" 29 #include "chrome/common/channel_info.h"
29 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
30 #include "chrome/grit/generated_resources.h" 31 #include "chrome/grit/generated_resources.h"
31 #include "chromeos/chromeos_switches.h" 32 #include "chromeos/chromeos_switches.h"
32 #include "chromeos/login/auth/user_context.h" 33 #include "chromeos/login/auth/user_context.h"
33 #include "chromeos/settings/cros_settings_names.h" 34 #include "chromeos/settings/cros_settings_names.h"
34 #include "chromeos/system/devicetype.h" 35 #include "chromeos/system/devicetype.h"
35 #include "chromeos/system/version_loader.h" 36 #include "chromeos/system/version_loader.h"
36 #include "components/login/localized_values_builder.h" 37 #include "components/login/localized_values_builder.h"
37 #include "components/prefs/pref_service.h" 38 #include "components/prefs/pref_service.h"
38 #include "components/user_manager/known_user.h" 39 #include "components/user_manager/known_user.h"
39 #include "components/user_manager/user_manager.h" 40 #include "components/user_manager/user_manager.h"
40 #include "components/version_info/version_info.h" 41 #include "components/version_info/version_info.h"
41 #include "content/public/browser/browser_thread.h" 42 #include "content/public/browser/browser_thread.h"
42 #include "content/public/browser/render_frame_host.h" 43 #include "content/public/browser/render_frame_host.h"
43 #include "google_apis/gaia/gaia_auth_util.h" 44 #include "google_apis/gaia/gaia_auth_util.h"
44 #include "google_apis/gaia/gaia_urls.h" 45 #include "google_apis/gaia/gaia_urls.h"
45 #include "grit/components_strings.h" 46 #include "grit/components_strings.h"
46 #include "ui/base/ime/chromeos/input_method_manager.h" 47 #include "ui/base/ime/chromeos/input_method_manager.h"
47 #include "ui/base/l10n/l10n_util.h" 48 #include "ui/base/l10n/l10n_util.h"
48 49
49 using content::BrowserThread; 50 using content::BrowserThread;
51 namespace em = enterprise_management;
50 52
51 namespace chromeos { 53 namespace chromeos {
52 54
53 namespace { 55 namespace {
54 56
55 const char kJsScreenPath[] = "login.GaiaSigninScreen"; 57 const char kJsScreenPath[] = "login.GaiaSigninScreen";
56 const char kAuthIframeParentName[] = "signin-frame"; 58 const char kAuthIframeParentName[] = "signin-frame";
57 59
58 const char kRestrictiveProxyURL[] = "https://www.google.com/generate_204"; 60 const char kRestrictiveProxyURL[] = "https://www.google.com/generate_204";
59 61
60 const char kEndpointGen[] = "1.0"; 62 const char kEndpointGen[] = "1.0";
61 63
64 // The possible modes that the Gaia signin screen can be in.
65 enum GaiaScreenMode {
66 // Default Gaia authentication will be used.
67 GAIA_SCREEN_MODE_DEFAULT = 0,
68
69 // Gaia offline mode will be used.
70 GAIA_SCREEN_MODE_OFFLINE = 1,
71
72 // An interstitial page will be used before SAML redirection.
73 GAIA_SCREEN_MODE_SAML_INTERSTITIAL = 2,
74 };
75
76 GaiaScreenMode GetGaiaScreenMode(bool use_offline) {
77 if (use_offline)
78 return GAIA_SCREEN_MODE_OFFLINE;
79
80 int authentication_behavior = 0;
81 CrosSettings::Get()->GetInteger(kLoginAuthenticationBehavior,
82 &authentication_behavior);
83 if (authentication_behavior ==
84 em::LoginAuthenticationBehaviorProto::SAML_INTERSTITIAL) {
85 return GAIA_SCREEN_MODE_SAML_INTERSTITIAL;
86 }
87
88 return GAIA_SCREEN_MODE_DEFAULT;
89 }
90
91 std::string GetEnterpriseDomain() {
92 policy::BrowserPolicyConnectorChromeOS* connector =
93 g_browser_process->platform_part()->browser_policy_connector_chromeos();
94 return connector->GetEnterpriseDomain();
95 }
96
62 std::string GetChromeType() { 97 std::string GetChromeType() {
63 switch (chromeos::GetDeviceType()) { 98 switch (chromeos::GetDeviceType()) {
64 case chromeos::DeviceType::kChromebox: 99 case chromeos::DeviceType::kChromebox:
65 return "chromebox"; 100 return "chromebox";
66 case chromeos::DeviceType::kChromebase: 101 case chromeos::DeviceType::kChromebase:
67 return "chromebase"; 102 return "chromebase";
68 case chromeos::DeviceType::kChromebit: 103 case chromeos::DeviceType::kChromebit:
69 return "chromebit"; 104 return "chromebit";
70 case chromeos::DeviceType::kChromebook: 105 case chromeos::DeviceType::kChromebook:
71 return "chromebook"; 106 return "chromebook";
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 base::Bind(&GaiaScreenHandler::LoadGaiaWithVersion, 215 base::Bind(&GaiaScreenHandler::LoadGaiaWithVersion,
181 weak_factory_.GetWeakPtr(), context)); 216 weak_factory_.GetWeakPtr(), context));
182 } 217 }
183 218
184 void GaiaScreenHandler::LoadGaiaWithVersion( 219 void GaiaScreenHandler::LoadGaiaWithVersion(
185 const GaiaContext& context, 220 const GaiaContext& context,
186 const std::string& platform_version) { 221 const std::string& platform_version) {
187 base::DictionaryValue params; 222 base::DictionaryValue params;
188 223
189 params.SetBoolean("forceReload", context.force_reload); 224 params.SetBoolean("forceReload", context.force_reload);
190 params.SetBoolean("useOffline", context.use_offline);
191 params.SetString("gaiaId", context.gaia_id); 225 params.SetString("gaiaId", context.gaia_id);
192 params.SetBoolean("readOnlyEmail", true); 226 params.SetBoolean("readOnlyEmail", true);
193 params.SetString("email", context.email); 227 params.SetString("email", context.email);
194 params.SetString("gapsCookie", context.gaps_cookie); 228 params.SetString("gapsCookie", context.gaps_cookie);
195 229
196 UpdateAuthParams(&params, IsRestrictiveProxy()); 230 UpdateAuthParams(&params, IsRestrictiveProxy());
197 231
198 if (!context.use_offline) { 232 GaiaScreenMode screen_mode = GetGaiaScreenMode(context.use_offline);
233 params.SetInteger("screenMode", screen_mode);
234 if (screen_mode != GAIA_SCREEN_MODE_OFFLINE) {
199 const std::string app_locale = g_browser_process->GetApplicationLocale(); 235 const std::string app_locale = g_browser_process->GetApplicationLocale();
200 if (!app_locale.empty()) 236 if (!app_locale.empty())
201 params.SetString("hl", app_locale); 237 params.SetString("hl", app_locale);
202 } else {
203 policy::BrowserPolicyConnectorChromeOS* connector =
204 g_browser_process->platform_part()->browser_policy_connector_chromeos();
205 std::string enterprise_domain(connector->GetEnterpriseDomain());
206 if (!enterprise_domain.empty()) {
207 params.SetString(
208 "enterpriseInfoMessage",
209 l10n_util::GetStringFUTF16(IDS_OFFLINE_LOGIN_DEVICE_MANAGED_BY_NOTICE,
210 base::UTF8ToUTF16(enterprise_domain)));
211 }
212 } 238 }
213 239
214 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 240 std::string enterprise_domain(GetEnterpriseDomain());
215
216 policy::BrowserPolicyConnectorChromeOS* connector =
217 g_browser_process->platform_part()->browser_policy_connector_chromeos();
218 std::string enterprise_domain(connector->GetEnterpriseDomain());
219 if (!enterprise_domain.empty()) 241 if (!enterprise_domain.empty())
220 params.SetString("enterpriseDomain", enterprise_domain); 242 params.SetString("enterpriseDomain", enterprise_domain);
221 243
222 params.SetString("chromeType", GetChromeType()); 244 params.SetString("chromeType", GetChromeType());
223 params.SetString("clientId", 245 params.SetString("clientId",
224 GaiaUrls::GetInstance()->oauth2_chrome_client_id()); 246 GaiaUrls::GetInstance()->oauth2_chrome_client_id());
225 params.SetString("clientVersion", version_info::GetVersionNumber()); 247 params.SetString("clientVersion", version_info::GetVersionNumber());
226 if (!platform_version.empty()) 248 if (!platform_version.empty())
227 params.SetString("platformVersion", platform_version); 249 params.SetString("platformVersion", platform_version);
228 params.SetString("releaseChannel", chrome::GetChannelString()); 250 params.SetString("releaseChannel", chrome::GetChannelString());
229 params.SetString("endpointGen", kEndpointGen); 251 params.SetString("endpointGen", kEndpointGen);
230 252
231 std::string email_domain; 253 std::string email_domain;
232 if (CrosSettings::Get()->GetString(kAccountsPrefLoginScreenDomainAutoComplete, 254 if (CrosSettings::Get()->GetString(kAccountsPrefLoginScreenDomainAutoComplete,
233 &email_domain) && 255 &email_domain) &&
234 !email_domain.empty()) { 256 !email_domain.empty()) {
235 params.SetString("emailDomain", email_domain); 257 params.SetString("emailDomain", email_domain);
236 } 258 }
237 259
238 params.SetString("gaiaUrl", GaiaUrls::GetInstance()->gaia_url().spec()); 260 params.SetString("gaiaUrl", GaiaUrls::GetInstance()->gaia_url().spec());
239 261
240 if (use_easy_bootstrap_) { 262 if (use_easy_bootstrap_) {
241 params.SetBoolean("useEafe", true); 263 params.SetBoolean("useEafe", true);
242 // Easy login overrides. 264 // Easy login overrides.
243 std::string eafe_url = "https://easylogin.corp.google.com/"; 265 std::string eafe_url = "https://easylogin.corp.google.com/";
266 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
244 if (command_line->HasSwitch(switches::kEafeUrl)) 267 if (command_line->HasSwitch(switches::kEafeUrl))
245 eafe_url = command_line->GetSwitchValueASCII(switches::kEafeUrl); 268 eafe_url = command_line->GetSwitchValueASCII(switches::kEafeUrl);
246 std::string eafe_path = "planters/cbaudioChrome"; 269 std::string eafe_path = "planters/cbaudioChrome";
247 if (command_line->HasSwitch(switches::kEafePath)) 270 if (command_line->HasSwitch(switches::kEafePath))
248 eafe_path = command_line->GetSwitchValueASCII(switches::kEafePath); 271 eafe_path = command_line->GetSwitchValueASCII(switches::kEafePath);
249 272
250 params.SetString("gaiaUrl", eafe_url); 273 params.SetString("gaiaUrl", eafe_url);
251 params.SetString("gaiaPath", eafe_path); 274 params.SetString("gaiaPath", eafe_path);
252 params.SetString("clientId",
253 GaiaUrls::GetInstance()->oauth2_chrome_client_id());
254 } 275 }
255 276
256 frame_state_ = FRAME_STATE_LOADING; 277 frame_state_ = FRAME_STATE_LOADING;
257 CallJS("loadAuthExtension", params); 278 CallJS("loadAuthExtension", params);
258 } 279 }
259 280
260 void GaiaScreenHandler::ReloadGaia(bool force_reload) { 281 void GaiaScreenHandler::ReloadGaia(bool force_reload) {
261 if (frame_state_ == FRAME_STATE_LOADING && !force_reload) { 282 if (frame_state_ == FRAME_STATE_LOADING && !force_reload) {
262 VLOG(1) << "Skipping reloading of Gaia since gaia is loading."; 283 VLOG(1) << "Skipping reloading of Gaia since gaia is loading.";
263 return; 284 return;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 builder->Add("fatalErrorMessageNoPassword", 317 builder->Add("fatalErrorMessageNoPassword",
297 IDS_LOGIN_FATAL_ERROR_NO_PASSWORD); 318 IDS_LOGIN_FATAL_ERROR_NO_PASSWORD);
298 builder->Add("fatalErrorMessageVerificationFailed", 319 builder->Add("fatalErrorMessageVerificationFailed",
299 IDS_LOGIN_FATAL_ERROR_PASSWORD_VERIFICATION); 320 IDS_LOGIN_FATAL_ERROR_PASSWORD_VERIFICATION);
300 builder->Add("fatalErrorMessageInsecureURL", 321 builder->Add("fatalErrorMessageInsecureURL",
301 IDS_LOGIN_FATAL_ERROR_TEXT_INSECURE_URL); 322 IDS_LOGIN_FATAL_ERROR_TEXT_INSECURE_URL);
302 builder->Add("fatalErrorDoneButton", IDS_DONE); 323 builder->Add("fatalErrorDoneButton", IDS_DONE);
303 builder->Add("fatalErrorTryAgainButton", 324 builder->Add("fatalErrorTryAgainButton",
304 IDS_LOGIN_FATAL_ERROR_TRY_AGAIN_BUTTON); 325 IDS_LOGIN_FATAL_ERROR_TRY_AGAIN_BUTTON);
305 326
306 builder->AddF("offlineLoginWelcome", IDS_OFFLINE_LOGIN_WELCOME, 327 builder->AddF("loginWelcomeMessage", IDS_LOGIN_WELCOME_MESSAGE,
307 ash::GetChromeOSDeviceTypeResourceId()); 328 ash::GetChromeOSDeviceTypeResourceId());
308 builder->Add("offlineLoginEmail", IDS_OFFLINE_LOGIN_EMAIL); 329 builder->Add("offlineLoginEmail", IDS_OFFLINE_LOGIN_EMAIL);
309 builder->Add("offlineLoginPassword", IDS_OFFLINE_LOGIN_PASSWORD); 330 builder->Add("offlineLoginPassword", IDS_OFFLINE_LOGIN_PASSWORD);
310 builder->Add("offlineLoginInvalidEmail", IDS_OFFLINE_LOGIN_INVALID_EMAIL); 331 builder->Add("offlineLoginInvalidEmail", IDS_OFFLINE_LOGIN_INVALID_EMAIL);
311 builder->Add("offlineLoginInvalidPassword", 332 builder->Add("offlineLoginInvalidPassword",
312 IDS_OFFLINE_LOGIN_INVALID_PASSWORD); 333 IDS_OFFLINE_LOGIN_INVALID_PASSWORD);
313 builder->Add("offlineLoginNextBtn", IDS_OFFLINE_LOGIN_NEXT_BUTTON_TEXT); 334 builder->Add("offlineLoginNextBtn", IDS_OFFLINE_LOGIN_NEXT_BUTTON_TEXT);
314 builder->Add("offlineLoginForgotPasswordBtn", 335 builder->Add("offlineLoginForgotPasswordBtn",
315 IDS_OFFLINE_LOGIN_FORGOT_PASSWORD_BUTTON_TEXT); 336 IDS_OFFLINE_LOGIN_FORGOT_PASSWORD_BUTTON_TEXT);
316 builder->Add("offlineLoginForgotPasswordDlg", 337 builder->Add("offlineLoginForgotPasswordDlg",
317 IDS_OFFLINE_LOGIN_FORGOT_PASSWORD_DIALOG_TEXT); 338 IDS_OFFLINE_LOGIN_FORGOT_PASSWORD_DIALOG_TEXT);
318 builder->Add("offlineLoginCloseBtn", IDS_OFFLINE_LOGIN_CLOSE_BUTTON_TEXT); 339 builder->Add("offlineLoginCloseBtn", IDS_OFFLINE_LOGIN_CLOSE_BUTTON_TEXT);
340 builder->AddF("enterpriseInfoMessage",
341 IDS_LOGIN_DEVICE_MANAGED_BY_NOTICE,
342 base::UTF8ToUTF16(GetEnterpriseDomain()));
343 builder->Add("samlInterstitialMessage",
344 IDS_LOGIN_SAML_INTERSTITIAL_MESSAGE);
345 builder->Add("samlInterstitialChangeAccountLink",
346 IDS_LOGIN_SAML_INTERSTITIAL_CHANGE_ACCOUNT_LINK_TEXT);
347 builder->Add("samlInterstitialNextBtn",
348 IDS_LOGIN_SAML_INTERSTITIAL_NEXT_BUTTON_TEXT);
319 } 349 }
320 350
321 void GaiaScreenHandler::Initialize() { 351 void GaiaScreenHandler::Initialize() {
322 } 352 }
323 353
324 void GaiaScreenHandler::RegisterMessages() { 354 void GaiaScreenHandler::RegisterMessages() {
325 AddCallback("webviewLoadAborted", 355 AddCallback("webviewLoadAborted",
326 &GaiaScreenHandler::HandleWebviewLoadAborted); 356 &GaiaScreenHandler::HandleWebviewLoadAborted);
327 AddCallback("completeLogin", &GaiaScreenHandler::HandleCompleteLogin); 357 AddCallback("completeLogin", &GaiaScreenHandler::HandleCompleteLogin);
328 AddCallback("completeAuthentication", 358 AddCallback("completeAuthentication",
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 bool GaiaScreenHandler::IsRestrictiveProxy() const { 812 bool GaiaScreenHandler::IsRestrictiveProxy() const {
783 return !disable_restrictive_proxy_check_for_test_ && 813 return !disable_restrictive_proxy_check_for_test_ &&
784 !IsOnline(captive_portal_status_); 814 !IsOnline(captive_portal_status_);
785 } 815 }
786 816
787 void GaiaScreenHandler::DisableRestrictiveProxyCheckForTest() { 817 void GaiaScreenHandler::DisableRestrictiveProxyCheckForTest() {
788 disable_restrictive_proxy_check_for_test_ = true; 818 disable_restrictive_proxy_check_for_test_ = true;
789 } 819 }
790 820
791 } // namespace chromeos 821 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/resources/gaia_auth_host/authenticator.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698