| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/sync/one_click_signin_sync_observer.h" | 5 #include "chrome/browser/ui/sync/one_click_signin_sync_observer.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | |
| 14 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 15 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 16 #include "chrome/browser/signin/signin_manager_factory.h" | 15 #include "chrome/browser/signin/signin_manager_factory.h" |
| 17 #include "chrome/browser/signin/signin_promo.h" | 16 #include "chrome/browser/signin/signin_promo.h" |
| 18 #include "chrome/browser/sync/profile_sync_service_factory.h" | 17 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 19 #include "chrome/browser/sync/profile_sync_test_util.h" | 18 #include "chrome/browser/sync/profile_sync_test_util.h" |
| 20 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 19 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 21 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
| 22 #include "components/browser_sync/test_profile_sync_service.h" | 21 #include "components/browser_sync/test_profile_sync_service.h" |
| 23 #include "components/signin/core/browser/signin_manager.h" | 22 #include "components/signin/core/browser/signin_manager.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 40 public: | 39 public: |
| 41 explicit MockWebContentsObserver(content::WebContents* web_contents) | 40 explicit MockWebContentsObserver(content::WebContents* web_contents) |
| 42 : content::WebContentsObserver(web_contents) {} | 41 : content::WebContentsObserver(web_contents) {} |
| 43 virtual ~MockWebContentsObserver() {} | 42 virtual ~MockWebContentsObserver() {} |
| 44 | 43 |
| 45 // A hook to verify that the OneClickSigninSyncObserver initiated a redirect | 44 // A hook to verify that the OneClickSigninSyncObserver initiated a redirect |
| 46 // to the continue URL. Navigations in unit_tests never complete, but a | 45 // to the continue URL. Navigations in unit_tests never complete, but a |
| 47 // navigation start is a sufficient signal for the purposes of this test. | 46 // navigation start is a sufficient signal for the purposes of this test. |
| 48 // Listening for this call also has the advantage of being synchronous. | 47 // Listening for this call also has the advantage of being synchronous. |
| 49 MOCK_METHOD1(DidStartNavigation, void(content::NavigationHandle*)); | 48 MOCK_METHOD1(DidStartNavigation, void(content::NavigationHandle*)); |
| 50 // TODO: remove this method when PlzNavigate is turned on by default. | 49 // TODO(jam): remove this method when PlzNavigate is turned on by default. |
| 51 MOCK_METHOD2(DidStartNavigationToPendingEntry, | 50 MOCK_METHOD2(DidStartNavigationToPendingEntry, |
| 52 void(const GURL&, content::ReloadType)); | 51 void(const GURL&, content::ReloadType)); |
| 53 }; | 52 }; |
| 54 | 53 |
| 55 class OneClickTestProfileSyncService | 54 class OneClickTestProfileSyncService |
| 56 : public browser_sync::TestProfileSyncService { | 55 : public browser_sync::TestProfileSyncService { |
| 57 public: | 56 public: |
| 58 ~OneClickTestProfileSyncService() override {} | 57 ~OneClickTestProfileSyncService() override {} |
| 59 | 58 |
| 60 // Helper routine to be used in conjunction with | 59 // Helper routine to be used in conjunction with |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 if (content::IsBrowserSideNavigationEnabled()) { | 281 if (content::IsBrowserSideNavigationEnabled()) { |
| 283 EXPECT_CALL(*web_contents_observer_, DidStartNavigation(_)).Times(0); | 282 EXPECT_CALL(*web_contents_observer_, DidStartNavigation(_)).Times(0); |
| 284 sync_service_->NotifyObservers(); | 283 sync_service_->NotifyObservers(); |
| 285 } else { | 284 } else { |
| 286 EXPECT_CALL(*web_contents_observer_, | 285 EXPECT_CALL(*web_contents_observer_, |
| 287 DidStartNavigationToPendingEntry(_, _)).Times(0); | 286 DidStartNavigationToPendingEntry(_, _)).Times(0); |
| 288 sync_service_->NotifyObservers(); | 287 sync_service_->NotifyObservers(); |
| 289 } | 288 } |
| 290 EXPECT_NE(GURL(kContinueUrl), web_contents()->GetVisibleURL()); | 289 EXPECT_NE(GURL(kContinueUrl), web_contents()->GetVisibleURL()); |
| 291 } | 290 } |
| OLD | NEW |