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 "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/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.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/browser_shutdown.h" | 16 #include "chrome/browser/browser_shutdown.h" |
17 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 17 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
18 #include "chrome/browser/chromeos/language_preferences.h" | 18 #include "chrome/browser/chromeos/language_preferences.h" |
19 #include "chrome/browser/chromeos/login/screens/network_error.h" | 19 #include "chrome/browser/chromeos/login/screens/network_error.h" |
20 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 20 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
21 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 21 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
22 #include "chrome/browser/chromeos/net/network_portal_detector_impl.h" | 22 #include "chrome/browser/chromeos/net/network_portal_detector_impl.h" |
23 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 23 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
24 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 24 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
25 #include "chrome/browser/chromeos/settings/cros_settings.h" | 25 #include "chrome/browser/chromeos/settings/cros_settings.h" |
26 #include "chrome/browser/io_thread.h" | 26 #include "chrome/browser/io_thread.h" |
27 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" | 27 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
28 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" | 28 #include "chrome/browser/ui/webui/signin/get_auth_frame.h" |
29 #include "chrome/common/channel_info.h" | 29 #include "chrome/common/channel_info.h" |
30 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
31 #include "chrome/grit/generated_resources.h" | 31 #include "chrome/grit/generated_resources.h" |
32 #include "chromeos/chromeos_switches.h" | 32 #include "chromeos/chromeos_switches.h" |
33 #include "chromeos/login/auth/user_context.h" | 33 #include "chromeos/login/auth/user_context.h" |
34 #include "chromeos/settings/cros_settings_names.h" | 34 #include "chromeos/settings/cros_settings_names.h" |
35 #include "chromeos/system/devicetype.h" | 35 #include "chromeos/system/devicetype.h" |
36 #include "chromeos/system/version_loader.h" | 36 #include "chromeos/system/version_loader.h" |
37 #include "components/login/localized_values_builder.h" | 37 #include "components/login/localized_values_builder.h" |
38 #include "components/user_manager/known_user.h" | 38 #include "components/user_manager/known_user.h" |
39 #include "components/user_manager/user_manager.h" | 39 #include "components/user_manager/user_manager.h" |
40 #include "components/version_info/version_info.h" | 40 #include "components/version_info/version_info.h" |
41 #include "content/public/browser/browser_thread.h" | 41 #include "content/public/browser/browser_thread.h" |
42 #include "content/public/browser/render_frame_host.h" | 42 #include "content/public/browser/render_frame_host.h" |
43 #include "google_apis/gaia/gaia_auth_util.h" | 43 #include "google_apis/gaia/gaia_auth_util.h" |
44 #include "google_apis/gaia/gaia_urls.h" | 44 #include "google_apis/gaia/gaia_urls.h" |
45 #include "grit/components_strings.h" | 45 #include "grit/components_strings.h" |
46 #include "ui/base/ime/chromeos/input_method_manager.h" | 46 #include "ui/base/ime/chromeos/input_method_manager.h" |
47 #include "ui/base/l10n/l10n_util.h" | 47 #include "ui/base/l10n/l10n_util.h" |
48 | 48 |
49 using content::BrowserThread; | 49 using content::BrowserThread; |
50 | 50 |
51 namespace chromeos { | 51 namespace chromeos { |
52 | 52 |
53 namespace { | 53 namespace { |
54 | 54 |
55 const char kJsScreenPath[] = "login.GaiaSigninScreen"; | 55 const char kJsScreenPath[] = "login.GaiaSigninScreen"; |
56 const char kAuthIframeParentName[] = "signin-frame"; | 56 const char kAuthIframeParentName[] = "signin-frame"; |
57 const char kAuthIframeParentOrigin[] = | |
58 "chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/"; | |
59 | 57 |
60 const char kRestrictiveProxyURL[] = "https://www.google.com/generate_204"; | 58 const char kRestrictiveProxyURL[] = "https://www.google.com/generate_204"; |
61 | 59 |
62 const char kEndpointGen[] = "1.0"; | 60 const char kEndpointGen[] = "1.0"; |
63 | 61 |
64 std::string GetChromeType() { | 62 std::string GetChromeType() { |
65 switch (chromeos::GetDeviceType()) { | 63 switch (chromeos::GetDeviceType()) { |
66 case chromeos::DeviceType::kChromebox: | 64 case chromeos::DeviceType::kChromebox: |
67 return "chromebox"; | 65 return "chromebox"; |
68 case chromeos::DeviceType::kChromebase: | 66 case chromeos::DeviceType::kChromebase: |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 if (frame_state() == GaiaScreenHandler::FRAME_STATE_LOADED) { | 595 if (frame_state() == GaiaScreenHandler::FRAME_STATE_LOADED) { |
598 SubmitLoginFormForTest(); | 596 SubmitLoginFormForTest(); |
599 } else if (frame_state() != GaiaScreenHandler::FRAME_STATE_LOADING) { | 597 } else if (frame_state() != GaiaScreenHandler::FRAME_STATE_LOADING) { |
600 signin_screen_handler_->OnShowAddUser(); | 598 signin_screen_handler_->OnShowAddUser(); |
601 } | 599 } |
602 } | 600 } |
603 | 601 |
604 void GaiaScreenHandler::SubmitLoginFormForTest() { | 602 void GaiaScreenHandler::SubmitLoginFormForTest() { |
605 VLOG(2) << "Submit login form for test, user=" << test_user_; | 603 VLOG(2) << "Submit login form for test, user=" << test_user_; |
606 | 604 |
607 content::RenderFrameHost* frame = InlineLoginUI::GetAuthFrame( | 605 content::RenderFrameHost* frame = |
608 web_ui()->GetWebContents(), | 606 signin::GetAuthFrame(web_ui()->GetWebContents(), kAuthIframeParentName); |
609 GURL(kAuthIframeParentOrigin), | |
610 kAuthIframeParentName); | |
611 | 607 |
612 std::string code = | 608 std::string code = |
613 "document.getElementById('identifier').value = '" + test_user_ + "';" | 609 "document.getElementById('identifier').value = '" + test_user_ + "';" |
614 "document.getElementById('nextButton').click();"; | 610 "document.getElementById('nextButton').click();"; |
615 frame->ExecuteJavaScriptForTests(base::ASCIIToUTF16(code)); | 611 frame->ExecuteJavaScriptForTests(base::ASCIIToUTF16(code)); |
616 | 612 |
617 if (!test_pass_.empty()) { | 613 if (!test_pass_.empty()) { |
618 code = "document.getElementById('password').value = '" + test_pass_ + "';"; | 614 code = "document.getElementById('password').value = '" + test_pass_ + "';"; |
619 code += "document.getElementById('nextButton').click();"; | 615 code += "document.getElementById('nextButton').click();"; |
620 frame->ExecuteJavaScriptForTests(base::ASCIIToUTF16(code)); | 616 frame->ExecuteJavaScriptForTests(base::ASCIIToUTF16(code)); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 bool GaiaScreenHandler::IsRestrictiveProxy() const { | 792 bool GaiaScreenHandler::IsRestrictiveProxy() const { |
797 return !disable_restrictive_proxy_check_for_test_ && | 793 return !disable_restrictive_proxy_check_for_test_ && |
798 !IsOnline(captive_portal_status_); | 794 !IsOnline(captive_portal_status_); |
799 } | 795 } |
800 | 796 |
801 void GaiaScreenHandler::DisableRestrictiveProxyCheckForTest() { | 797 void GaiaScreenHandler::DisableRestrictiveProxyCheckForTest() { |
802 disable_restrictive_proxy_check_for_test_ = true; | 798 disable_restrictive_proxy_check_for_test_ = true; |
803 } | 799 } |
804 | 800 |
805 } // namespace chromeos | 801 } // namespace chromeos |
OLD | NEW |