| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 Profile* profile, | 170 Profile* profile, |
| 171 const GURL& current_url, | 171 const GURL& current_url, |
| 172 const std::string& email, | 172 const std::string& email, |
| 173 const std::string& gaia_id, | 173 const std::string& gaia_id, |
| 174 const std::string& password, | 174 const std::string& password, |
| 175 const std::string& session_index, | 175 const std::string& session_index, |
| 176 const std::string& auth_code, | 176 const std::string& auth_code, |
| 177 const std::string& signin_scoped_device_id, | 177 const std::string& signin_scoped_device_id, |
| 178 bool choose_what_to_sync, | 178 bool choose_what_to_sync, |
| 179 bool confirm_untrusted_signin) | 179 bool confirm_untrusted_signin) |
| 180 : InlineSigninHelper(handler, | 180 : InlineSigninHelper(handler, |
| 181 getter, | 181 getter, |
| 182 profile, | 182 profile, |
| 183 current_url, | 183 Profile::CreateStatus::CREATE_STATUS_INITIALIZED, |
| 184 email, | 184 current_url, |
| 185 gaia_id, | 185 email, |
| 186 password, | 186 gaia_id, |
| 187 session_index, | 187 password, |
| 188 auth_code, | 188 session_index, |
| 189 signin_scoped_device_id, | 189 auth_code, |
| 190 choose_what_to_sync, | 190 signin_scoped_device_id, |
| 191 confirm_untrusted_signin) {} | 191 choose_what_to_sync, |
| 192 confirm_untrusted_signin) {} |
| 192 | 193 |
| 193 // This class is used to mock out virtual methods with side effects so that | 194 // This class is used to mock out virtual methods with side effects so that |
| 194 // tests below can ensure they are called without causing side effects. | 195 // tests below can ensure they are called without causing side effects. |
| 195 class MockSyncStarterInlineSigninHelper : public InlineSigninHelper { | 196 class MockSyncStarterInlineSigninHelper : public InlineSigninHelper { |
| 196 public: | 197 public: |
| 197 MockSyncStarterInlineSigninHelper( | 198 MockSyncStarterInlineSigninHelper( |
| 198 base::WeakPtr<InlineLoginHandlerImpl> handler, | 199 base::WeakPtr<InlineLoginHandlerImpl> handler, |
| 199 net::URLRequestContextGetter* getter, | 200 net::URLRequestContextGetter* getter, |
| 200 Profile* profile, | 201 Profile* profile, |
| 201 const GURL& current_url, | 202 const GURL& current_url, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 227 Profile* profile, | 228 Profile* profile, |
| 228 const GURL& current_url, | 229 const GURL& current_url, |
| 229 const std::string& email, | 230 const std::string& email, |
| 230 const std::string& gaia_id, | 231 const std::string& gaia_id, |
| 231 const std::string& password, | 232 const std::string& password, |
| 232 const std::string& session_index, | 233 const std::string& session_index, |
| 233 const std::string& auth_code, | 234 const std::string& auth_code, |
| 234 const std::string& signin_scoped_device_id, | 235 const std::string& signin_scoped_device_id, |
| 235 bool choose_what_to_sync, | 236 bool choose_what_to_sync, |
| 236 bool confirm_untrusted_signin) | 237 bool confirm_untrusted_signin) |
| 237 : InlineSigninHelper(handler, | 238 : InlineSigninHelper(handler, |
| 238 getter, | 239 getter, |
| 239 profile, | 240 profile, |
| 240 current_url, | 241 Profile::CreateStatus::CREATE_STATUS_INITIALIZED, |
| 241 email, | 242 current_url, |
| 242 gaia_id, | 243 email, |
| 243 password, | 244 gaia_id, |
| 244 session_index, | 245 password, |
| 245 auth_code, | 246 session_index, |
| 246 signin_scoped_device_id, | 247 auth_code, |
| 247 choose_what_to_sync, | 248 signin_scoped_device_id, |
| 248 confirm_untrusted_signin) {} | 249 choose_what_to_sync, |
| 250 confirm_untrusted_signin) {} |
| 249 | 251 |
| 250 } // namespace | 252 } // namespace |
| 251 | 253 |
| 252 class InlineLoginUIBrowserTest : public InProcessBrowserTest { | 254 class InlineLoginUIBrowserTest : public InProcessBrowserTest { |
| 253 public: | 255 public: |
| 254 InlineLoginUIBrowserTest() {} | 256 InlineLoginUIBrowserTest() {} |
| 255 | 257 |
| 256 void SetUpSigninManager(const std::string& username); | 258 void SetUpSigninManager(const std::string& username); |
| 257 void EnableSigninAllowed(bool enable); | 259 void EnableSigninAllowed(bool enable); |
| 258 void EnableOneClick(bool enable); | 260 void EnableOneClick(bool enable); |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 | 708 |
| 707 // Test signin helper does not create sync starter when reauthenticating. | 709 // Test signin helper does not create sync starter when reauthenticating. |
| 708 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, | 710 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, |
| 709 ReauthCallsUpdateCredentials) { | 711 ReauthCallsUpdateCredentials) { |
| 710 ASSERT_EQ(0ul, token_service()->GetAccounts().size()); | 712 ASSERT_EQ(0ul, token_service()->GetAccounts().size()); |
| 711 | 713 |
| 712 // See Source enum in components/signin/core/browser/signin_metrics.h for | 714 // See Source enum in components/signin/core/browser/signin_metrics.h for |
| 713 // possible values of access_point=, reason=. | 715 // possible values of access_point=, reason=. |
| 714 GURL url("chrome://chrome-signin/?access_point=3&reason=2"); | 716 GURL url("chrome://chrome-signin/?access_point=3&reason=2"); |
| 715 base::WeakPtr<InlineLoginHandlerImpl> handler; | 717 base::WeakPtr<InlineLoginHandlerImpl> handler; |
| 716 InlineSigninHelper helper(handler, | 718 InlineSigninHelper helper(handler, browser()->profile()->GetRequestContext(), |
| 717 browser()->profile()->GetRequestContext(), | |
| 718 browser()->profile(), | 719 browser()->profile(), |
| 719 url, | 720 Profile::CreateStatus::CREATE_STATUS_INITIALIZED, |
| 720 "foo@gmail.com", | 721 url, "foo@gmail.com", "gaiaid-12345", "password", |
| 721 "gaiaid-12345", | 722 "", // session index |
| 722 "password", | |
| 723 "", // session index | |
| 724 "auth_code", // auth code | 723 "auth_code", // auth code |
| 725 std::string(), | 724 std::string(), |
| 726 false, // choose what to sync | 725 false, // choose what to sync |
| 727 false); // confirm untrusted signin | 726 false); // confirm untrusted signin |
| 728 SimulateOnClientOAuthSuccess(&helper, "refresh_token"); | 727 SimulateOnClientOAuthSuccess(&helper, "refresh_token"); |
| 729 ASSERT_EQ(1ul, token_service()->GetAccounts().size()); | 728 ASSERT_EQ(1ul, token_service()->GetAccounts().size()); |
| 730 base::RunLoop().RunUntilIdle(); | 729 base::RunLoop().RunUntilIdle(); |
| 731 } | 730 } |
| 732 | 731 |
| 733 // Test signin helper does not create sync starter when adding another account | 732 // Test signin helper does not create sync starter when adding another account |
| 734 // to profile. | 733 // to profile. |
| 735 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, | 734 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, |
| 736 AddAccountsCallsUpdateCredentials) { | 735 AddAccountsCallsUpdateCredentials) { |
| 737 ASSERT_EQ(0ul, token_service()->GetAccounts().size()); | 736 ASSERT_EQ(0ul, token_service()->GetAccounts().size()); |
| 738 | 737 |
| 739 // See Source enum in components/signin/core/browser/signin_metrics.h for | 738 // See Source enum in components/signin/core/browser/signin_metrics.h for |
| 740 // possible values of access_point=, reason=. | 739 // possible values of access_point=, reason=. |
| 741 GURL url("chrome://chrome-signin/?access_point=10&reason=1"); | 740 GURL url("chrome://chrome-signin/?access_point=10&reason=1"); |
| 742 base::WeakPtr<InlineLoginHandlerImpl> handler; | 741 base::WeakPtr<InlineLoginHandlerImpl> handler; |
| 743 InlineSigninHelper helper(handler, | 742 InlineSigninHelper helper(handler, browser()->profile()->GetRequestContext(), |
| 744 browser()->profile()->GetRequestContext(), | |
| 745 browser()->profile(), | 743 browser()->profile(), |
| 746 url, | 744 Profile::CreateStatus::CREATE_STATUS_INITIALIZED, |
| 747 "foo@gmail.com", | 745 url, "foo@gmail.com", "gaiaid-12345", "password", |
| 748 "gaiaid-12345", | 746 "", // session index |
| 749 "password", | |
| 750 "", // session index | |
| 751 "auth_code", // auth code | 747 "auth_code", // auth code |
| 752 std::string(), | 748 std::string(), |
| 753 false, // choose what to sync | 749 false, // choose what to sync |
| 754 false); // confirm untrusted signin | 750 false); // confirm untrusted signin |
| 755 SimulateOnClientOAuthSuccess(&helper, "refresh_token"); | 751 SimulateOnClientOAuthSuccess(&helper, "refresh_token"); |
| 756 ASSERT_EQ(1ul, token_service()->GetAccounts().size()); | 752 ASSERT_EQ(1ul, token_service()->GetAccounts().size()); |
| 757 base::RunLoop().RunUntilIdle(); | 753 base::RunLoop().RunUntilIdle(); |
| 758 } | 754 } |
| 759 | 755 |
| 760 class InlineLoginUISafeIframeBrowserTest : public InProcessBrowserTest { | 756 class InlineLoginUISafeIframeBrowserTest : public InProcessBrowserTest { |
| 761 public: | 757 public: |
| 762 FooWebUIProvider& foo_provider() { return foo_provider_; } | 758 FooWebUIProvider& foo_provider() { return foo_provider_; } |
| 763 | 759 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 content::WebContents* contents = | 845 content::WebContents* contents = |
| 850 browser()->tab_strip_model()->GetActiveWebContents(); | 846 browser()->tab_strip_model()->GetActiveWebContents(); |
| 851 ASSERT_TRUE(content::ExecuteScript( | 847 ASSERT_TRUE(content::ExecuteScript( |
| 852 contents, "window.location.href = 'chrome://foo'")); | 848 contents, "window.location.href = 'chrome://foo'")); |
| 853 | 849 |
| 854 content::TestNavigationObserver navigation_observer(contents, 1); | 850 content::TestNavigationObserver navigation_observer(contents, 1); |
| 855 navigation_observer.Wait(); | 851 navigation_observer.Wait(); |
| 856 | 852 |
| 857 EXPECT_EQ(GURL("about:blank"), contents->GetVisibleURL()); | 853 EXPECT_EQ(GURL("about:blank"), contents->GetVisibleURL()); |
| 858 } | 854 } |
| OLD | NEW |