Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_OBSERVER_H_ | 6 #define CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_OBSERVER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "chrome/browser/profiles/profile.h" | |
| 11 #include "chrome/browser/ui/browser.h" | |
| 10 #include "components/sync_driver/sync_service_observer.h" | 12 #include "components/sync_driver/sync_service_observer.h" |
| 11 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
| 12 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 13 | 15 |
| 14 class ProfileSyncService; | 16 class ProfileSyncService; |
| 15 | 17 |
| 16 namespace content { | 18 namespace content { |
| 17 class WebContents; | 19 class WebContents; |
| 18 } | 20 } |
| 19 | 21 |
| 20 class OneClickSigninSyncObserver : public content::WebContentsObserver, | 22 class OneClickSigninSyncObserver : public content::WebContentsObserver, |
| 21 public sync_driver::SyncServiceObserver { | 23 public sync_driver::SyncServiceObserver { |
| 22 public: | 24 public: |
| 23 // Waits for Sync to be initialized, then navigates the |web_contents| to the | 25 // Waits for Sync to be initialized, then navigates the |web_contents| to the |
| 24 // |continue_url|. Instances of this class delete themselves once the job is | 26 // |continue_url|. Instances of this class delete themselves once the job is |
| 25 // done. | 27 // done. |
|
Roger Tawa OOO till Jul 10th
2016/03/23 01:14:15
Can you add docs for the new args. In particular
Moe
2016/03/24 00:02:40
Done.
| |
| 26 OneClickSigninSyncObserver(content::WebContents* web_contents, | 28 OneClickSigninSyncObserver(content::WebContents* web_contents, |
| 29 Profile* profile, | |
| 30 Browser* browser, | |
| 31 const GURL& activity_controls_url, | |
| 27 const GURL& continue_url); | 32 const GURL& continue_url); |
| 28 | 33 |
| 29 protected: | 34 protected: |
| 30 // Exposed for testing. | 35 // Exposed for testing. |
| 31 ~OneClickSigninSyncObserver() override; | 36 ~OneClickSigninSyncObserver() override; |
| 32 | 37 |
| 33 private: | 38 private: |
| 34 // content::WebContentsObserver: | 39 // content::WebContentsObserver: |
| 35 void WebContentsDestroyed() override; | 40 void WebContentsDestroyed() override; |
| 36 | 41 |
| 37 // sync_driver::SyncServiceObserver: | 42 // sync_driver::SyncServiceObserver: |
| 38 void OnStateChanged() override; | 43 void OnStateChanged() override; |
| 39 | 44 |
| 40 // Loads the |continue_url_| in the |web_contents()|. | 45 // Loads the |continue_url_| in the |web_contents()|. |
| 41 void LoadContinueUrl(); | 46 void LoadContinueUrl(); |
| 42 | 47 |
| 43 // Returns the ProfileSyncService associated with the |web_contents|. | 48 // Returns the ProfileSyncService associated with the |web_contents|. |
| 44 // The returned value may be NULL. | 49 // The returned value may be NULL. |
| 45 ProfileSyncService* GetSyncService(content::WebContents* web_contents); | 50 ProfileSyncService* GetSyncService(content::WebContents* web_contents); |
| 46 | 51 |
| 47 // Deletes the |observer|. Intended to be used as a callback for base::Bind. | 52 // Deletes the |observer|. Intended to be used as a callback for base::Bind. |
| 48 static void DeleteObserver( | 53 static void DeleteObserver( |
| 49 base::WeakPtr<OneClickSigninSyncObserver> observer); | 54 base::WeakPtr<OneClickSigninSyncObserver> observer); |
| 50 | 55 |
| 56 Profile* profile_; | |
| 57 | |
| 58 Browser* browser_; | |
| 59 | |
| 60 // The URL of the 'Activity controls' section of the privacy settings page. | |
| 61 const GURL activity_controls_url_; | |
| 62 | |
| 51 // The URL to redirect to once Sync is initialized. | 63 // The URL to redirect to once Sync is initialized. |
| 52 const GURL continue_url_; | 64 const GURL continue_url_; |
| 53 | 65 |
| 54 base::WeakPtrFactory<OneClickSigninSyncObserver> weak_ptr_factory_; | 66 base::WeakPtrFactory<OneClickSigninSyncObserver> weak_ptr_factory_; |
| 55 | 67 |
| 56 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncObserver); | 68 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncObserver); |
| 57 }; | 69 }; |
| 58 | 70 |
| 59 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_OBSERVER_H_ | 71 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_OBSERVER_H_ |
| OLD | NEW |