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

Side by Side Diff: chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc

Issue 1473543002: Implement newly designed sign-in related histograms for desktop platorms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comments Created 5 years 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
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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/prefs/pref_service.h" 6 #include "base/prefs/pref_service.h"
7 #include "base/prefs/scoped_user_pref_update.h" 7 #include "base/prefs/scoped_user_pref_update.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/content_settings/cookie_settings_factory.h" 9 #include "chrome/browser/content_settings/cookie_settings_factory.h"
10 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" 10 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 const std::string& gaia_id, 137 const std::string& gaia_id,
138 const std::string& password, 138 const std::string& password,
139 const std::string& session_index, 139 const std::string& session_index,
140 const std::string& auth_code, 140 const std::string& auth_code,
141 const std::string& signin_scoped_device_id, 141 const std::string& signin_scoped_device_id,
142 bool choose_what_to_sync, 142 bool choose_what_to_sync,
143 bool confirm_untrusted_signin); 143 bool confirm_untrusted_signin);
144 144
145 MOCK_METHOD1(OnClientOAuthSuccess, void(const ClientOAuthResult& result)); 145 MOCK_METHOD1(OnClientOAuthSuccess, void(const ClientOAuthResult& result));
146 MOCK_METHOD1(OnClientOAuthFailure, void(const GoogleServiceAuthError& error)); 146 MOCK_METHOD1(OnClientOAuthFailure, void(const GoogleServiceAuthError& error));
147 MOCK_METHOD6(CreateSyncStarter, 147 MOCK_METHOD7(CreateSyncStarter,
148 void(Browser*, 148 void(Browser*,
149 content::WebContents*, 149 content::WebContents*,
150 const GURL&, 150 const GURL&,
151 const GURL&,
151 const std::string&, 152 const std::string&,
152 OneClickSigninSyncStarter::StartSyncMode, 153 OneClickSigninSyncStarter::StartSyncMode,
153 OneClickSigninSyncStarter::ConfirmationRequired)); 154 OneClickSigninSyncStarter::ConfirmationRequired));
154 155
155 private: 156 private:
156 DISALLOW_COPY_AND_ASSIGN(MockInlineSigninHelper); 157 DISALLOW_COPY_AND_ASSIGN(MockInlineSigninHelper);
157 }; 158 };
158 159
159 MockInlineSigninHelper::MockInlineSigninHelper( 160 MockInlineSigninHelper::MockInlineSigninHelper(
160 base::WeakPtr<InlineLoginHandlerImpl> handler, 161 base::WeakPtr<InlineLoginHandlerImpl> handler,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 const GURL& current_url, 194 const GURL& current_url,
194 const std::string& email, 195 const std::string& email,
195 const std::string& gaia_id, 196 const std::string& gaia_id,
196 const std::string& password, 197 const std::string& password,
197 const std::string& session_index, 198 const std::string& session_index,
198 const std::string& auth_code, 199 const std::string& auth_code,
199 const std::string& signin_scoped_device_id, 200 const std::string& signin_scoped_device_id,
200 bool choose_what_to_sync, 201 bool choose_what_to_sync,
201 bool confirm_untrusted_signin); 202 bool confirm_untrusted_signin);
202 203
203 MOCK_METHOD6(CreateSyncStarter, 204 MOCK_METHOD7(CreateSyncStarter,
204 void(Browser*, 205 void(Browser*,
205 content::WebContents*, 206 content::WebContents*,
206 const GURL&, 207 const GURL&,
208 const GURL&,
207 const std::string&, 209 const std::string&,
208 OneClickSigninSyncStarter::StartSyncMode, 210 OneClickSigninSyncStarter::StartSyncMode,
209 OneClickSigninSyncStarter::ConfirmationRequired)); 211 OneClickSigninSyncStarter::ConfirmationRequired));
210 212
211 private: 213 private:
212 DISALLOW_COPY_AND_ASSIGN(MockSyncStarterInlineSigninHelper); 214 DISALLOW_COPY_AND_ASSIGN(MockSyncStarterInlineSigninHelper);
213 }; 215 };
214 216
215 MockSyncStarterInlineSigninHelper::MockSyncStarterInlineSigninHelper( 217 MockSyncStarterInlineSigninHelper::MockSyncStarterInlineSigninHelper(
216 base::WeakPtr<InlineLoginHandlerImpl> handler, 218 base::WeakPtr<InlineLoginHandlerImpl> handler,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 299
298 #if defined(OS_LINUX) || defined(OS_WIN) 300 #if defined(OS_LINUX) || defined(OS_WIN)
299 // crbug.com/422868 301 // crbug.com/422868
300 #define MAYBE_DifferentStorageId DISABLED_DifferentStorageId 302 #define MAYBE_DifferentStorageId DISABLED_DifferentStorageId
301 #else 303 #else
302 #define MAYBE_DifferentStorageId DifferentStorageId 304 #define MAYBE_DifferentStorageId DifferentStorageId
303 #endif 305 #endif
304 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, MAYBE_DifferentStorageId) { 306 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, MAYBE_DifferentStorageId) {
305 if (switches::IsEnableWebviewBasedSignin()) { 307 if (switches::IsEnableWebviewBasedSignin()) {
306 ContentInfo info = NavigateAndGetInfo( 308 ContentInfo info = NavigateAndGetInfo(
307 browser(), 309 browser(), signin::GetPromoURL(
308 signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE, false), 310 signin_metrics::ACCESS_POINT_START_PAGE,
311 signin_metrics::REASON_SIGNIN_PRIMARY_ACCOUNT, false),
309 CURRENT_TAB); 312 CURRENT_TAB);
310 WaitUntilUIReady(browser()); 313 WaitUntilUIReady(browser());
311 314
312 // Make sure storage partition of embedded webview is different from 315 // Make sure storage partition of embedded webview is different from
313 // parent. 316 // parent.
314 std::set<content::WebContents*> set; 317 std::set<content::WebContents*> set;
315 GuestViewManager* manager = GuestViewManager::FromBrowserContext( 318 GuestViewManager* manager = GuestViewManager::FromBrowserContext(
316 info.contents->GetBrowserContext()); 319 info.contents->GetBrowserContext());
317 manager->ForEachGuest(info.contents, base::Bind(&AddToSet, &set)); 320 manager->ForEachGuest(info.contents, base::Bind(&AddToSet, &set));
318 ASSERT_EQ(1u, set.size()); 321 ASSERT_EQ(1u, set.size());
319 content::WebContents* webview_contents = *set.begin(); 322 content::WebContents* webview_contents = *set.begin();
320 content::RenderProcessHost* process = 323 content::RenderProcessHost* process =
321 webview_contents->GetRenderProcessHost(); 324 webview_contents->GetRenderProcessHost();
322 ASSERT_NE(info.pid, process->GetID()); 325 ASSERT_NE(info.pid, process->GetID());
323 ASSERT_NE(info.storage_partition, process->GetStoragePartition()); 326 ASSERT_NE(info.storage_partition, process->GetStoragePartition());
324 } else { 327 } else {
325 GURL test_url = ui_test_utils::GetTestUrl( 328 GURL test_url = ui_test_utils::GetTestUrl(
326 base::FilePath(base::FilePath::kCurrentDirectory), 329 base::FilePath(base::FilePath::kCurrentDirectory),
327 base::FilePath(FILE_PATH_LITERAL("title1.html"))); 330 base::FilePath(FILE_PATH_LITERAL("title1.html")));
328 331
329 ContentInfo info1 = 332 ContentInfo info1 =
330 NavigateAndGetInfo(browser(), test_url, CURRENT_TAB); 333 NavigateAndGetInfo(browser(), test_url, CURRENT_TAB);
331 ContentInfo info2 = NavigateAndGetInfo( 334 ContentInfo info2 = NavigateAndGetInfo(
332 browser(), 335 browser(), signin::GetPromoURL(
333 signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE, false), 336 signin_metrics::ACCESS_POINT_START_PAGE,
337 signin_metrics::REASON_SIGNIN_PRIMARY_ACCOUNT, false),
334 CURRENT_TAB); 338 CURRENT_TAB);
335 NavigateAndGetInfo(browser(), test_url, CURRENT_TAB); 339 NavigateAndGetInfo(browser(), test_url, CURRENT_TAB);
336 ContentInfo info3 = NavigateAndGetInfo( 340 ContentInfo info3 = NavigateAndGetInfo(
337 browser(), 341 browser(), signin::GetPromoURL(
338 signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE, false), 342 signin_metrics::ACCESS_POINT_START_PAGE,
343 signin_metrics::REASON_SIGNIN_PRIMARY_ACCOUNT, false),
339 NEW_FOREGROUND_TAB); 344 NEW_FOREGROUND_TAB);
340 345
341 // The info for signin should be the same. 346 // The info for signin should be the same.
342 ASSERT_EQ(info2.storage_partition, info3.storage_partition); 347 ASSERT_EQ(info2.storage_partition, info3.storage_partition);
343 // The info for test_url and signin should be different. 348 // The info for test_url and signin should be different.
344 ASSERT_NE(info1.storage_partition, info2.storage_partition); 349 ASSERT_NE(info1.storage_partition, info2.storage_partition);
345 } 350 }
346 } 351 }
347 352
348 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, OneProcessLimit) { 353 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, OneProcessLimit) {
349 GURL test_url_1 = ui_test_utils::GetTestUrl( 354 GURL test_url_1 = ui_test_utils::GetTestUrl(
350 base::FilePath(base::FilePath::kCurrentDirectory), 355 base::FilePath(base::FilePath::kCurrentDirectory),
351 base::FilePath(FILE_PATH_LITERAL("title1.html"))); 356 base::FilePath(FILE_PATH_LITERAL("title1.html")));
352 GURL test_url_2 = ui_test_utils::GetTestUrl( 357 GURL test_url_2 = ui_test_utils::GetTestUrl(
353 base::FilePath(base::FilePath::kCurrentDirectory), 358 base::FilePath(base::FilePath::kCurrentDirectory),
354 base::FilePath(FILE_PATH_LITERAL("data:text/html,Hello world!"))); 359 base::FilePath(FILE_PATH_LITERAL("data:text/html,Hello world!")));
355 360
356 // Even when the process limit is set to one, the signin process should 361 // Even when the process limit is set to one, the signin process should
357 // still be given its own process and storage partition. 362 // still be given its own process and storage partition.
358 content::RenderProcessHost::SetMaxRendererProcessCount(1); 363 content::RenderProcessHost::SetMaxRendererProcessCount(1);
359 364
360 ContentInfo info1 = 365 ContentInfo info1 =
361 NavigateAndGetInfo(browser(), test_url_1, CURRENT_TAB); 366 NavigateAndGetInfo(browser(), test_url_1, CURRENT_TAB);
362 ContentInfo info2 = 367 ContentInfo info2 =
363 NavigateAndGetInfo(browser(), test_url_2, CURRENT_TAB); 368 NavigateAndGetInfo(browser(), test_url_2, CURRENT_TAB);
364 ContentInfo info3 = NavigateAndGetInfo( 369 ContentInfo info3 = NavigateAndGetInfo(
365 browser(), 370 browser(),
366 signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE, false), 371 signin::GetPromoURL(signin_metrics::ACCESS_POINT_START_PAGE,
372 signin_metrics::REASON_SIGNIN_PRIMARY_ACCOUNT, false),
367 CURRENT_TAB); 373 CURRENT_TAB);
368 374
369 ASSERT_EQ(info1.pid, info2.pid); 375 ASSERT_EQ(info1.pid, info2.pid);
370 ASSERT_NE(info1.pid, info3.pid); 376 ASSERT_NE(info1.pid, info3.pid);
371 } 377 }
372 378
373 #if !defined(OS_CHROMEOS) 379 #if !defined(OS_CHROMEOS)
374 380
375 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, CanOfferNoProfile) { 381 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, CanOfferNoProfile) {
376 std::string error_message; 382 std::string error_message;
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 SimulateStartAuthCodeForOAuth2TokenExchangeSuccess( 586 SimulateStartAuthCodeForOAuth2TokenExchangeSuccess(
581 "{\"access_token\": \"access_token\", \"expires_in\": 1234567890," 587 "{\"access_token\": \"access_token\", \"expires_in\": 1234567890,"
582 " \"refresh_token\": \"refresh_token\"}"); 588 " \"refresh_token\": \"refresh_token\"}");
583 } 589 }
584 590
585 // Test signin helper creates sync starter with correct confirmation when 591 // Test signin helper creates sync starter with correct confirmation when
586 // signing in with default sync options. 592 // signing in with default sync options.
587 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, 593 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest,
588 SigninCreatesSyncStarter1) { 594 SigninCreatesSyncStarter1) {
589 // See Source enum in components/signin/core/browser/signin_metrics.h for 595 // See Source enum in components/signin/core/browser/signin_metrics.h for
590 // possible values of source=. 596 // possible values of access_point=, reason=.
591 GURL url("chrome://chrome-signin/?source=0"); 597 GURL url("chrome://chrome-signin/?access_point=0&reason=0");
592 base::WeakPtr<InlineLoginHandlerImpl> handler; 598 base::WeakPtr<InlineLoginHandlerImpl> handler;
593 // MockSyncStarterInlineSigninHelper will delete itself when done using 599 // MockSyncStarterInlineSigninHelper will delete itself when done using
594 // base::ThreadTaskRunnerHandle::DeleteSoon(), so need to delete here. But 600 // base::ThreadTaskRunnerHandle::DeleteSoon(), so need to delete here. But
595 // do need the RunUntilIdle() at the end. 601 // do need the RunUntilIdle() at the end.
596 MockSyncStarterInlineSigninHelper* helper = 602 MockSyncStarterInlineSigninHelper* helper =
597 new MockSyncStarterInlineSigninHelper( 603 new MockSyncStarterInlineSigninHelper(
598 handler, 604 handler,
599 browser()->profile()->GetRequestContext(), 605 browser()->profile()->GetRequestContext(),
600 browser()->profile(), 606 browser()->profile(),
601 url, 607 url,
602 "foo@gmail.com", 608 "foo@gmail.com",
603 "gaiaid-12345", 609 "gaiaid-12345",
604 "password", 610 "password",
605 "", // session index 611 "", // session index
606 "auth_code", // auth code 612 "auth_code", // auth code
607 std::string(), 613 std::string(),
608 false, // choose what to sync 614 false, // choose what to sync
609 false); // confirm untrusted signin 615 false); // confirm untrusted signin
610 EXPECT_CALL(*helper, CreateSyncStarter( 616 EXPECT_CALL(
611 _, _, _, "refresh_token", 617 *helper,
612 OneClickSigninSyncStarter::CONFIRM_SYNC_SETTINGS_FIRST, 618 CreateSyncStarter(_, _, _, _, "refresh_token",
613 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN)); 619 OneClickSigninSyncStarter::CONFIRM_SYNC_SETTINGS_FIRST,
620 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN));
614 621
615 SimulateOnClientOAuthSuccess(helper, "refresh_token"); 622 SimulateOnClientOAuthSuccess(helper, "refresh_token");
616 base::MessageLoop::current()->RunUntilIdle(); 623 base::MessageLoop::current()->RunUntilIdle();
617 } 624 }
618 625
619 // Test signin helper creates sync starter with correct confirmation when 626 // Test signin helper creates sync starter with correct confirmation when
620 // signing in and choosing what to sync first. 627 // signing in and choosing what to sync first.
621 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, 628 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest,
622 SigninCreatesSyncStarter2) { 629 SigninCreatesSyncStarter2) {
623 // See Source enum in components/signin/core/browser/signin_metrics.h for 630 // See Source enum in components/signin/core/browser/signin_metrics.h for
624 // possible values of source=. 631 // possible values of access_point=, reason=.
625 const GURL url("chrome://chrome-signin/?source=0"); 632 const GURL url("chrome://chrome-signin/?access_point=0&reason=0");
626 base::WeakPtr<InlineLoginHandlerImpl> handler; 633 base::WeakPtr<InlineLoginHandlerImpl> handler;
627 // MockSyncStarterInlineSigninHelper will delete itself when done using 634 // MockSyncStarterInlineSigninHelper will delete itself when done using
628 // base::ThreadTaskRunnerHandle::DeleteSoon(), so need to delete here. But 635 // base::ThreadTaskRunnerHandle::DeleteSoon(), so need to delete here. But
629 // do need the RunUntilIdle() at the end. 636 // do need the RunUntilIdle() at the end.
630 MockSyncStarterInlineSigninHelper* helper = 637 MockSyncStarterInlineSigninHelper* helper =
631 new MockSyncStarterInlineSigninHelper( 638 new MockSyncStarterInlineSigninHelper(
632 handler, 639 handler,
633 browser()->profile()->GetRequestContext(), 640 browser()->profile()->GetRequestContext(),
634 browser()->profile(), 641 browser()->profile(),
635 url, 642 url,
636 "foo@gmail.com", 643 "foo@gmail.com",
637 "gaiaid-12345", 644 "gaiaid-12345",
638 "password", 645 "password",
639 "", // session index 646 "", // session index
640 "auth_code", // auth code 647 "auth_code", // auth code
641 std::string(), 648 std::string(),
642 true, // choose what to sync 649 true, // choose what to sync
643 false); // confirm untrusted signin 650 false); // confirm untrusted signin
644 EXPECT_CALL(*helper, CreateSyncStarter( 651 EXPECT_CALL(*helper, CreateSyncStarter(
645 _, _, _, "refresh_token", 652 _, _, _, _, "refresh_token",
646 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST, 653 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST,
647 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN)); 654 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN));
648 655
649 SimulateOnClientOAuthSuccess(helper, "refresh_token"); 656 SimulateOnClientOAuthSuccess(helper, "refresh_token");
650 base::MessageLoop::current()->RunUntilIdle(); 657 base::MessageLoop::current()->RunUntilIdle();
651 } 658 }
652 659
653 // Test signin helper creates sync starter with correct confirmation when 660 // Test signin helper creates sync starter with correct confirmation when
654 // signing in with an untrusted sign occurs. 661 // signing in with an untrusted sign occurs.
655 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, 662 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest,
656 SigninCreatesSyncStarter3) { 663 SigninCreatesSyncStarter3) {
657 // See Source enum in components/signin/core/browser/signin_metrics.h for 664 // See Source enum in components/signin/core/browser/signin_metrics.h for
658 // possible values of source=. 665 // possible values of access_point=, reason=.
659 GURL url("chrome://chrome-signin/?source=0"); 666 GURL url("chrome://chrome-signin/?access_point=0&reason=0");
660 base::WeakPtr<InlineLoginHandlerImpl> handler; 667 base::WeakPtr<InlineLoginHandlerImpl> handler;
661 // MockSyncStarterInlineSigninHelper will delete itself when done using 668 // MockSyncStarterInlineSigninHelper will delete itself when done using
662 // base::ThreadTaskRunnerHandle::DeleteSoon(), so need to delete here. But 669 // base::ThreadTaskRunnerHandle::DeleteSoon(), so need to delete here. But
663 // do need the RunUntilIdle() at the end. 670 // do need the RunUntilIdle() at the end.
664 MockSyncStarterInlineSigninHelper* helper = 671 MockSyncStarterInlineSigninHelper* helper =
665 new MockSyncStarterInlineSigninHelper( 672 new MockSyncStarterInlineSigninHelper(
666 handler, 673 handler,
667 browser()->profile()->GetRequestContext(), 674 browser()->profile()->GetRequestContext(),
668 browser()->profile(), 675 browser()->profile(),
669 url, 676 url,
670 "foo@gmail.com", 677 "foo@gmail.com",
671 "gaiaid-12345", 678 "gaiaid-12345",
672 "password", 679 "password",
673 "", // session index 680 "", // session index
674 "auth_code", // auth code 681 "auth_code", // auth code
675 std::string(), 682 std::string(),
676 false, // choose what to sync 683 false, // choose what to sync
677 true); // confirm untrusted signin 684 true); // confirm untrusted signin
678 EXPECT_CALL(*helper, CreateSyncStarter( 685 EXPECT_CALL(
679 _, _, _, "refresh_token", 686 *helper,
680 OneClickSigninSyncStarter::CONFIRM_SYNC_SETTINGS_FIRST, 687 CreateSyncStarter(_, _, _, _, "refresh_token",
681 OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN)); 688 OneClickSigninSyncStarter::CONFIRM_SYNC_SETTINGS_FIRST,
689 OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN));
682 690
683 SimulateOnClientOAuthSuccess(helper, "refresh_token"); 691 SimulateOnClientOAuthSuccess(helper, "refresh_token");
684 base::MessageLoop::current()->RunUntilIdle(); 692 base::MessageLoop::current()->RunUntilIdle();
685 } 693 }
686 694
687 // Test signin helper creates sync starter with correct confirmation during 695 // Test signin helper creates sync starter with correct confirmation during
688 // re-auth. 696 // re-auth.
689 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, 697 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest,
690 SigninCreatesSyncStarter4) { 698 SigninCreatesSyncStarter4) {
691 // See Source enum in components/signin/core/browser/signin_metrics.h for 699 // See Source enum in components/signin/core/browser/signin_metrics.h for
692 // possible values of source=. 700 // possible values of access_point=, reason=.
693 const GURL url("chrome://chrome-signin/?source=3"); 701 const GURL url("chrome://chrome-signin/?access_point=3&reason=0");
694 base::WeakPtr<InlineLoginHandlerImpl> handler; 702 base::WeakPtr<InlineLoginHandlerImpl> handler;
695 // MockSyncStarterInlineSigninHelper will delete itself when done using 703 // MockSyncStarterInlineSigninHelper will delete itself when done using
696 // base::ThreadTaskRunnerHandle::DeleteSoon(), so need to delete here. But 704 // base::ThreadTaskRunnerHandle::DeleteSoon(), so need to delete here. But
697 // do need the RunUntilIdle() at the end. 705 // do need the RunUntilIdle() at the end.
698 MockSyncStarterInlineSigninHelper* helper = 706 MockSyncStarterInlineSigninHelper* helper =
699 new MockSyncStarterInlineSigninHelper( 707 new MockSyncStarterInlineSigninHelper(
700 handler, 708 handler,
701 browser()->profile()->GetRequestContext(), 709 browser()->profile()->GetRequestContext(),
702 browser()->profile(), 710 browser()->profile(),
703 url, 711 url,
704 "foo@gmail.com", 712 "foo@gmail.com",
705 "gaiaid-12345", 713 "gaiaid-12345",
706 "password", 714 "password",
707 "", // session index 715 "", // session index
708 "auth_code", // auth code 716 "auth_code", // auth code
709 std::string(), 717 std::string(),
710 false, // choose what to sync 718 false, // choose what to sync
711 false); // confirm untrusted signin 719 false); // confirm untrusted signin
712 720
713 // Even though "choose what to sync" is false, the source of the URL is 721 // Even though "choose what to sync" is false, the source of the URL is
714 // settings, which means the user wants to CONFIGURE_SYNC_FIRST. 722 // settings, which means the user wants to CONFIGURE_SYNC_FIRST.
715 EXPECT_CALL(*helper, CreateSyncStarter( 723 EXPECT_CALL(*helper, CreateSyncStarter(
716 _, _, _, "refresh_token", 724 _, _, _, _, "refresh_token",
717 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST, 725 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST,
718 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN)); 726 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN));
719 727
720 SimulateOnClientOAuthSuccess(helper, "refresh_token"); 728 SimulateOnClientOAuthSuccess(helper, "refresh_token");
721 base::MessageLoop::current()->RunUntilIdle(); 729 base::MessageLoop::current()->RunUntilIdle();
722 } 730 }
723 731
724 // Test signin helper does not create sync starter when reauthenticating. 732 // Test signin helper does not create sync starter when reauthenticating.
725 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, 733 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest,
726 ReauthCallsUpdateCredentials) { 734 ReauthCallsUpdateCredentials) {
727 ASSERT_EQ(0ul, token_service()->GetAccounts().size()); 735 ASSERT_EQ(0ul, token_service()->GetAccounts().size());
728 736
729 // See Source enum in components/signin/core/browser/signin_metrics.h for 737 // See Source enum in components/signin/core/browser/signin_metrics.h for
730 // possible values of source=. 738 // possible values of access_point=, reason=.
731 GURL url("chrome://chrome-signin/?source=11"); 739 GURL url("chrome://chrome-signin/?access_point=3&reason=2");
732 base::WeakPtr<InlineLoginHandlerImpl> handler; 740 base::WeakPtr<InlineLoginHandlerImpl> handler;
733 InlineSigninHelper helper(handler, 741 InlineSigninHelper helper(handler,
734 browser()->profile()->GetRequestContext(), 742 browser()->profile()->GetRequestContext(),
735 browser()->profile(), 743 browser()->profile(),
736 url, 744 url,
737 "foo@gmail.com", 745 "foo@gmail.com",
738 "gaiaid-12345", 746 "gaiaid-12345",
739 "password", 747 "password",
740 "", // session index 748 "", // session index
741 "auth_code", // auth code 749 "auth_code", // auth code
742 std::string(), 750 std::string(),
743 false, // choose what to sync 751 false, // choose what to sync
744 false); // confirm untrusted signin 752 false); // confirm untrusted signin
745 SimulateOnClientOAuthSuccess(&helper, "refresh_token"); 753 SimulateOnClientOAuthSuccess(&helper, "refresh_token");
746 ASSERT_EQ(1ul, token_service()->GetAccounts().size()); 754 ASSERT_EQ(1ul, token_service()->GetAccounts().size());
747 base::MessageLoop::current()->RunUntilIdle(); 755 base::MessageLoop::current()->RunUntilIdle();
748 } 756 }
749 757
750 // Test signin helper does not create sync starter when adding another account 758 // Test signin helper does not create sync starter when adding another account
751 // to profile. 759 // to profile.
752 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, 760 IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest,
753 AddAccountsCallsUpdateCredentials) { 761 AddAccountsCallsUpdateCredentials) {
754 ASSERT_EQ(0ul, token_service()->GetAccounts().size()); 762 ASSERT_EQ(0ul, token_service()->GetAccounts().size());
755 763
756 // See Source enum in components/signin/core/browser/signin_metrics.h for 764 // See Source enum in components/signin/core/browser/signin_metrics.h for
757 // possible values of source=. 765 // possible values of access_point=, reason=.
758 GURL url("chrome://chrome-signin/?source=9"); 766 GURL url("chrome://chrome-signin/?access_point=10&reason=1");
759 base::WeakPtr<InlineLoginHandlerImpl> handler; 767 base::WeakPtr<InlineLoginHandlerImpl> handler;
760 InlineSigninHelper helper(handler, 768 InlineSigninHelper helper(handler,
761 browser()->profile()->GetRequestContext(), 769 browser()->profile()->GetRequestContext(),
762 browser()->profile(), 770 browser()->profile(),
763 url, 771 url,
764 "foo@gmail.com", 772 "foo@gmail.com",
765 "gaiaid-12345", 773 "gaiaid-12345",
766 "password", 774 "password",
767 "", // session index 775 "", // session index
768 "auth_code", // auth code 776 "auth_code", // auth code
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, Basic) { 833 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, Basic) {
826 const GURL kUrl(kFooWebUIURL); 834 const GURL kUrl(kFooWebUIURL);
827 EXPECT_CALL(foo_provider(), NewWebUI(_, ::testing::Eq(kUrl))) 835 EXPECT_CALL(foo_provider(), NewWebUI(_, ::testing::Eq(kUrl)))
828 .WillOnce(ReturnNewWebUI()); 836 .WillOnce(ReturnNewWebUI());
829 ui_test_utils::NavigateToURL(browser(), GURL(kFooWebUIURL)); 837 ui_test_utils::NavigateToURL(browser(), GURL(kFooWebUIURL));
830 } 838 }
831 839
832 // Make sure that the foo webui handler does not get created when we try to 840 // Make sure that the foo webui handler does not get created when we try to
833 // load it inside the iframe of the login ui. 841 // load it inside the iframe of the login ui.
834 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, NoWebUIInIframe) { 842 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, NoWebUIInIframe) {
835 GURL url = signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE, false). 843 GURL url =
836 Resolve("?source=0&frameUrl=chrome://foo"); 844 signin::GetPromoURL(signin_metrics::ACCESS_POINT_START_PAGE,
845 signin_metrics::REASON_SIGNIN_PRIMARY_ACCOUNT, false)
846 .Resolve("?source=0&access_point=0&reason=0&frameUrl=chrome://foo");
837 EXPECT_CALL(foo_provider(), NewWebUI(_, _)).Times(0); 847 EXPECT_CALL(foo_provider(), NewWebUI(_, _)).Times(0);
838 ui_test_utils::NavigateToURL(browser(), url); 848 ui_test_utils::NavigateToURL(browser(), url);
839 } 849 }
840 850
841 // Flaky on CrOS, http://crbug.com/364759. 851 // Flaky on CrOS, http://crbug.com/364759.
842 #if defined(OS_CHROMEOS) 852 #if defined(OS_CHROMEOS)
843 #define MAYBE_TopFrameNavigationDisallowed DISABLED_TopFrameNavigationDisallowed 853 #define MAYBE_TopFrameNavigationDisallowed DISABLED_TopFrameNavigationDisallowed
844 #else 854 #else
845 #define MAYBE_TopFrameNavigationDisallowed TopFrameNavigationDisallowed 855 #define MAYBE_TopFrameNavigationDisallowed TopFrameNavigationDisallowed
846 #endif 856 #endif
847 857
848 // Make sure that the gaia iframe cannot trigger top-frame navigation. 858 // Make sure that the gaia iframe cannot trigger top-frame navigation.
849 // TODO(guohui): flaky on trybot crbug/364759. 859 // TODO(guohui): flaky on trybot crbug/364759.
850 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, 860 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest,
851 MAYBE_TopFrameNavigationDisallowed) { 861 MAYBE_TopFrameNavigationDisallowed) {
852 // Loads into gaia iframe a web page that attempts to deframe on load. 862 // Loads into gaia iframe a web page that attempts to deframe on load.
853 GURL deframe_url(embedded_test_server()->GetURL("/login/deframe.html")); 863 GURL deframe_url(embedded_test_server()->GetURL("/login/deframe.html"));
854 GURL url(net::AppendOrReplaceQueryParameter( 864 GURL url(net::AppendOrReplaceQueryParameter(
855 signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE, false), 865 signin::GetPromoURL(signin_metrics::ACCESS_POINT_START_PAGE,
866 signin_metrics::REASON_SIGNIN_PRIMARY_ACCOUNT, false),
856 "frameUrl", deframe_url.spec())); 867 "frameUrl", deframe_url.spec()));
857 ui_test_utils::NavigateToURL(browser(), url); 868 ui_test_utils::NavigateToURL(browser(), url);
858 WaitUntilUIReady(browser()); 869 WaitUntilUIReady(browser());
859 870
860 content::WebContents* contents = 871 content::WebContents* contents =
861 browser()->tab_strip_model()->GetActiveWebContents(); 872 browser()->tab_strip_model()->GetActiveWebContents();
862 EXPECT_EQ(url, contents->GetVisibleURL()); 873 EXPECT_EQ(url, contents->GetVisibleURL());
863 874
864 content::NavigationController& controller = contents->GetController(); 875 content::NavigationController& controller = contents->GetController();
865 EXPECT_TRUE(controller.GetPendingEntry() == NULL); 876 EXPECT_TRUE(controller.GetPendingEntry() == NULL);
866 } 877 }
867 878
868 // Flaky on CrOS, http://crbug.com/364759. 879 // Flaky on CrOS, http://crbug.com/364759.
869 // Also flaky on Mac, http://crbug.com/442674. 880 // Also flaky on Mac, http://crbug.com/442674.
870 // Also flaky on Linux which is just too flaky 881 // Also flaky on Linux which is just too flaky
871 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, 882 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest,
872 DISABLED_NavigationToOtherChromeURLDisallowed) { 883 DISABLED_NavigationToOtherChromeURLDisallowed) {
873 ui_test_utils::NavigateToURL( 884 ui_test_utils::NavigateToURL(
874 browser(), signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE, false)); 885 browser(), signin::GetPromoURL(
886 signin_metrics::ACCESS_POINT_START_PAGE,
887 signin_metrics::REASON_SIGNIN_PRIMARY_ACCOUNT, false));
875 WaitUntilUIReady(browser()); 888 WaitUntilUIReady(browser());
876 889
877 content::WebContents* contents = 890 content::WebContents* contents =
878 browser()->tab_strip_model()->GetActiveWebContents(); 891 browser()->tab_strip_model()->GetActiveWebContents();
879 ASSERT_TRUE(content::ExecuteScript( 892 ASSERT_TRUE(content::ExecuteScript(
880 contents, "window.location.href = 'chrome://foo'")); 893 contents, "window.location.href = 'chrome://foo'"));
881 894
882 content::TestNavigationObserver navigation_observer(contents, 1); 895 content::TestNavigationObserver navigation_observer(contents, 1);
883 navigation_observer.Wait(); 896 navigation_observer.Wait();
884 897
885 EXPECT_EQ(GURL("about:blank"), contents->GetVisibleURL()); 898 EXPECT_EQ(GURL("about:blank"), contents->GetVisibleURL());
886 } 899 }
887 900
888 #if !defined(OS_CHROMEOS) 901 #if !defined(OS_CHROMEOS)
889 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, 902 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest,
890 ConfirmationRequiredForNonsecureSignin) { 903 ConfirmationRequiredForNonsecureSignin) {
891 FakeGaia fake_gaia; 904 FakeGaia fake_gaia;
892 fake_gaia.Initialize(); 905 fake_gaia.Initialize();
893 906
894 embedded_test_server()->RegisterRequestHandler( 907 embedded_test_server()->RegisterRequestHandler(
895 base::Bind(&FakeGaia::HandleRequest, 908 base::Bind(&FakeGaia::HandleRequest,
896 base::Unretained(&fake_gaia))); 909 base::Unretained(&fake_gaia)));
897 fake_gaia.SetFakeMergeSessionParams( 910 fake_gaia.SetFakeMergeSessionParams(
898 "email@gmail.com", "fake-sid-cookie", "fake-lsid-cookie"); 911 "email@gmail.com", "fake-sid-cookie", "fake-lsid-cookie");
899 912
900 // Navigates to the Chrome signin page which loads the fake gaia auth page. 913 // Navigates to the Chrome signin page which loads the fake gaia auth page.
901 // Since the fake gaia auth page is served over HTTP, thus expects to see an 914 // Since the fake gaia auth page is served over HTTP, thus expects to see an
902 // untrusted signin confirmation dialog upon submitting credentials below. 915 // untrusted signin confirmation dialog upon submitting credentials below.
903 ui_test_utils::NavigateToURL( 916 ui_test_utils::NavigateToURL(
904 browser(), signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE, false)); 917 browser(), signin::GetPromoURL(
918 signin_metrics::ACCESS_POINT_START_PAGE,
919 signin_metrics::REASON_SIGNIN_PRIMARY_ACCOUNT, false));
905 WaitUntilUIReady(browser()); 920 WaitUntilUIReady(browser());
906 921
907 MockLoginUIObserver observer; 922 MockLoginUIObserver observer;
908 LoginUIServiceFactory::GetForProfile(browser()->profile()) 923 LoginUIServiceFactory::GetForProfile(browser()->profile())
909 ->AddObserver(&observer); 924 ->AddObserver(&observer);
910 base::RunLoop run_loop; 925 base::RunLoop run_loop;
911 EXPECT_CALL(observer, OnUntrustedLoginUIShown()) 926 EXPECT_CALL(observer, OnUntrustedLoginUIShown())
912 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); 927 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
913 928
914 ExecuteJsToSigninInSigninFrame(browser(), "email@gmail.com", "password"); 929 ExecuteJsToSigninInSigninFrame(browser(), "email@gmail.com", "password");
915 run_loop.Run(); 930 run_loop.Run();
916 base::MessageLoop::current()->RunUntilIdle(); 931 base::MessageLoop::current()->RunUntilIdle();
917 } 932 }
918 #endif // OS_CHROMEOS 933 #endif // OS_CHROMEOS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698