| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 const std::string& gaia_id, | 144 const std::string& gaia_id, |
| 145 const std::string& password, | 145 const std::string& password, |
| 146 const std::string& session_index, | 146 const std::string& session_index, |
| 147 const std::string& auth_code, | 147 const std::string& auth_code, |
| 148 const std::string& signin_scoped_device_id, | 148 const std::string& signin_scoped_device_id, |
| 149 bool choose_what_to_sync, | 149 bool choose_what_to_sync, |
| 150 bool confirm_untrusted_signin); | 150 bool confirm_untrusted_signin); |
| 151 | 151 |
| 152 MOCK_METHOD1(OnClientOAuthSuccess, void(const ClientOAuthResult& result)); | 152 MOCK_METHOD1(OnClientOAuthSuccess, void(const ClientOAuthResult& result)); |
| 153 MOCK_METHOD1(OnClientOAuthFailure, void(const GoogleServiceAuthError& error)); | 153 MOCK_METHOD1(OnClientOAuthFailure, void(const GoogleServiceAuthError& error)); |
| 154 MOCK_METHOD7(CreateSyncStarter, | 154 MOCK_METHOD8(CreateSyncStarter, |
| 155 void(Browser*, | 155 void(Browser*, |
| 156 content::WebContents*, | 156 content::WebContents*, |
| 157 const GURL&, | 157 const GURL&, |
| 158 const GURL&, | 158 const GURL&, |
| 159 const std::string&, | 159 const std::string&, |
| 160 OneClickSigninSyncStarter::ProfileMode, |
| 160 OneClickSigninSyncStarter::StartSyncMode, | 161 OneClickSigninSyncStarter::StartSyncMode, |
| 161 OneClickSigninSyncStarter::ConfirmationRequired)); | 162 OneClickSigninSyncStarter::ConfirmationRequired)); |
| 162 | 163 |
| 163 private: | 164 private: |
| 164 DISALLOW_COPY_AND_ASSIGN(MockInlineSigninHelper); | 165 DISALLOW_COPY_AND_ASSIGN(MockInlineSigninHelper); |
| 165 }; | 166 }; |
| 166 | 167 |
| 167 MockInlineSigninHelper::MockInlineSigninHelper( | 168 MockInlineSigninHelper::MockInlineSigninHelper( |
| 168 base::WeakPtr<InlineLoginHandlerImpl> handler, | 169 base::WeakPtr<InlineLoginHandlerImpl> handler, |
| 169 net::URLRequestContextGetter* getter, | 170 net::URLRequestContextGetter* getter, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 const GURL& current_url, | 203 const GURL& current_url, |
| 203 const std::string& email, | 204 const std::string& email, |
| 204 const std::string& gaia_id, | 205 const std::string& gaia_id, |
| 205 const std::string& password, | 206 const std::string& password, |
| 206 const std::string& session_index, | 207 const std::string& session_index, |
| 207 const std::string& auth_code, | 208 const std::string& auth_code, |
| 208 const std::string& signin_scoped_device_id, | 209 const std::string& signin_scoped_device_id, |
| 209 bool choose_what_to_sync, | 210 bool choose_what_to_sync, |
| 210 bool confirm_untrusted_signin); | 211 bool confirm_untrusted_signin); |
| 211 | 212 |
| 212 MOCK_METHOD7(CreateSyncStarter, | 213 MOCK_METHOD8(CreateSyncStarter, |
| 213 void(Browser*, | 214 void(Browser*, |
| 214 content::WebContents*, | 215 content::WebContents*, |
| 215 const GURL&, | 216 const GURL&, |
| 216 const GURL&, | 217 const GURL&, |
| 217 const std::string&, | 218 const std::string&, |
| 219 OneClickSigninSyncStarter::ProfileMode, |
| 218 OneClickSigninSyncStarter::StartSyncMode, | 220 OneClickSigninSyncStarter::StartSyncMode, |
| 219 OneClickSigninSyncStarter::ConfirmationRequired)); | 221 OneClickSigninSyncStarter::ConfirmationRequired)); |
| 220 | 222 |
| 221 private: | 223 private: |
| 222 DISALLOW_COPY_AND_ASSIGN(MockSyncStarterInlineSigninHelper); | 224 DISALLOW_COPY_AND_ASSIGN(MockSyncStarterInlineSigninHelper); |
| 223 }; | 225 }; |
| 224 | 226 |
| 225 MockSyncStarterInlineSigninHelper::MockSyncStarterInlineSigninHelper( | 227 MockSyncStarterInlineSigninHelper::MockSyncStarterInlineSigninHelper( |
| 226 base::WeakPtr<InlineLoginHandlerImpl> handler, | 228 base::WeakPtr<InlineLoginHandlerImpl> handler, |
| 227 net::URLRequestContextGetter* getter, | 229 net::URLRequestContextGetter* getter, |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 "gaiaid-12345", | 588 "gaiaid-12345", |
| 587 "password", | 589 "password", |
| 588 "", // session index | 590 "", // session index |
| 589 "auth_code", // auth code | 591 "auth_code", // auth code |
| 590 std::string(), | 592 std::string(), |
| 591 false, // choose what to sync | 593 false, // choose what to sync |
| 592 false); // confirm untrusted signin | 594 false); // confirm untrusted signin |
| 593 EXPECT_CALL( | 595 EXPECT_CALL( |
| 594 *helper, | 596 *helper, |
| 595 CreateSyncStarter(_, _, _, _, "refresh_token", | 597 CreateSyncStarter(_, _, _, _, "refresh_token", |
| 598 OneClickSigninSyncStarter::CURRENT_PROFILE, |
| 596 OneClickSigninSyncStarter::CONFIRM_SYNC_SETTINGS_FIRST, | 599 OneClickSigninSyncStarter::CONFIRM_SYNC_SETTINGS_FIRST, |
| 597 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN)); | 600 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN)); |
| 598 | 601 |
| 599 SimulateOnClientOAuthSuccess(helper, "refresh_token"); | 602 SimulateOnClientOAuthSuccess(helper, "refresh_token"); |
| 600 base::RunLoop().RunUntilIdle(); | 603 base::RunLoop().RunUntilIdle(); |
| 601 } | 604 } |
| 602 | 605 |
| 603 // Test signin helper creates sync starter with correct confirmation when | 606 // Test signin helper creates sync starter with correct confirmation when |
| 604 // signing in and choosing what to sync first. | 607 // signing in and choosing what to sync first. |
| 605 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, | 608 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 620 "foo@gmail.com", | 623 "foo@gmail.com", |
| 621 "gaiaid-12345", | 624 "gaiaid-12345", |
| 622 "password", | 625 "password", |
| 623 "", // session index | 626 "", // session index |
| 624 "auth_code", // auth code | 627 "auth_code", // auth code |
| 625 std::string(), | 628 std::string(), |
| 626 true, // choose what to sync | 629 true, // choose what to sync |
| 627 false); // confirm untrusted signin | 630 false); // confirm untrusted signin |
| 628 EXPECT_CALL(*helper, CreateSyncStarter( | 631 EXPECT_CALL(*helper, CreateSyncStarter( |
| 629 _, _, _, _, "refresh_token", | 632 _, _, _, _, "refresh_token", |
| 633 OneClickSigninSyncStarter::CURRENT_PROFILE, |
| 630 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST, | 634 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST, |
| 631 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN)); | 635 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN)); |
| 632 | 636 |
| 633 SimulateOnClientOAuthSuccess(helper, "refresh_token"); | 637 SimulateOnClientOAuthSuccess(helper, "refresh_token"); |
| 634 base::RunLoop().RunUntilIdle(); | 638 base::RunLoop().RunUntilIdle(); |
| 635 } | 639 } |
| 636 | 640 |
| 637 // Test signin helper creates sync starter with correct confirmation when | 641 // Test signin helper creates sync starter with correct confirmation when |
| 638 // signing in with an untrusted sign occurs. | 642 // signing in with an untrusted sign occurs. |
| 639 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, | 643 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 655 "gaiaid-12345", | 659 "gaiaid-12345", |
| 656 "password", | 660 "password", |
| 657 "", // session index | 661 "", // session index |
| 658 "auth_code", // auth code | 662 "auth_code", // auth code |
| 659 std::string(), | 663 std::string(), |
| 660 false, // choose what to sync | 664 false, // choose what to sync |
| 661 true); // confirm untrusted signin | 665 true); // confirm untrusted signin |
| 662 EXPECT_CALL( | 666 EXPECT_CALL( |
| 663 *helper, | 667 *helper, |
| 664 CreateSyncStarter(_, _, _, _, "refresh_token", | 668 CreateSyncStarter(_, _, _, _, "refresh_token", |
| 669 OneClickSigninSyncStarter::CURRENT_PROFILE, |
| 665 OneClickSigninSyncStarter::CONFIRM_SYNC_SETTINGS_FIRST, | 670 OneClickSigninSyncStarter::CONFIRM_SYNC_SETTINGS_FIRST, |
| 666 OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN)); | 671 OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN)); |
| 667 | 672 |
| 668 SimulateOnClientOAuthSuccess(helper, "refresh_token"); | 673 SimulateOnClientOAuthSuccess(helper, "refresh_token"); |
| 669 base::RunLoop().RunUntilIdle(); | 674 base::RunLoop().RunUntilIdle(); |
| 670 } | 675 } |
| 671 | 676 |
| 672 // Test signin helper creates sync starter with correct confirmation during | 677 // Test signin helper creates sync starter with correct confirmation during |
| 673 // re-auth. | 678 // re-auth. |
| 674 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, | 679 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 692 "", // session index | 697 "", // session index |
| 693 "auth_code", // auth code | 698 "auth_code", // auth code |
| 694 std::string(), | 699 std::string(), |
| 695 false, // choose what to sync | 700 false, // choose what to sync |
| 696 false); // confirm untrusted signin | 701 false); // confirm untrusted signin |
| 697 | 702 |
| 698 // Even though "choose what to sync" is false, the source of the URL is | 703 // Even though "choose what to sync" is false, the source of the URL is |
| 699 // settings, which means the user wants to CONFIGURE_SYNC_FIRST. | 704 // settings, which means the user wants to CONFIGURE_SYNC_FIRST. |
| 700 EXPECT_CALL(*helper, CreateSyncStarter( | 705 EXPECT_CALL(*helper, CreateSyncStarter( |
| 701 _, _, _, _, "refresh_token", | 706 _, _, _, _, "refresh_token", |
| 707 OneClickSigninSyncStarter::CURRENT_PROFILE, |
| 702 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST, | 708 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST, |
| 703 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN)); | 709 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN)); |
| 704 | 710 |
| 705 SimulateOnClientOAuthSuccess(helper, "refresh_token"); | 711 SimulateOnClientOAuthSuccess(helper, "refresh_token"); |
| 706 base::RunLoop().RunUntilIdle(); | 712 base::RunLoop().RunUntilIdle(); |
| 707 } | 713 } |
| 708 | 714 |
| 709 // Test signin helper does not create sync starter when reauthenticating. | 715 // Test signin helper does not create sync starter when reauthenticating. |
| 710 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, | 716 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, |
| 711 ReauthCallsUpdateCredentials) { | 717 ReauthCallsUpdateCredentials) { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 content::WebContents* contents = | 851 content::WebContents* contents = |
| 846 browser()->tab_strip_model()->GetActiveWebContents(); | 852 browser()->tab_strip_model()->GetActiveWebContents(); |
| 847 ASSERT_TRUE(content::ExecuteScript( | 853 ASSERT_TRUE(content::ExecuteScript( |
| 848 contents, "window.location.href = 'chrome://foo'")); | 854 contents, "window.location.href = 'chrome://foo'")); |
| 849 | 855 |
| 850 content::TestNavigationObserver navigation_observer(contents, 1); | 856 content::TestNavigationObserver navigation_observer(contents, 1); |
| 851 navigation_observer.Wait(); | 857 navigation_observer.Wait(); |
| 852 | 858 |
| 853 EXPECT_EQ(GURL("about:blank"), contents->GetVisibleURL()); | 859 EXPECT_EQ(GURL("about:blank"), contents->GetVisibleURL()); |
| 854 } | 860 } |
| OLD | NEW |