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 "components/sync/driver/sync_service_observer.h" | 10 #include "components/sync/driver/sync_service_observer.h" |
11 #include "content/public/browser/web_contents_observer.h" | 11 #include "content/public/browser/web_contents_observer.h" |
12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
13 | 13 |
14 namespace browser_sync { | 14 namespace browser_sync { |
15 class ProfileSyncService; | 15 class ProfileSyncService; |
16 } | 16 } |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 class WebContents; | 19 class WebContents; |
20 } | 20 } |
21 | 21 |
22 class OneClickSigninSyncObserver : public content::WebContentsObserver, | 22 class OneClickSigninSyncObserver : public content::WebContentsObserver, |
23 public sync_driver::SyncServiceObserver { | 23 public syncer::SyncServiceObserver { |
24 public: | 24 public: |
25 // 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 |
26 // |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 |
27 // done. | 27 // done. |
28 OneClickSigninSyncObserver(content::WebContents* web_contents, | 28 OneClickSigninSyncObserver(content::WebContents* web_contents, |
29 const GURL& continue_url); | 29 const GURL& continue_url); |
30 | 30 |
31 protected: | 31 protected: |
32 // Exposed for testing. | 32 // Exposed for testing. |
33 ~OneClickSigninSyncObserver() override; | 33 ~OneClickSigninSyncObserver() override; |
34 | 34 |
35 private: | 35 private: |
36 // content::WebContentsObserver: | 36 // content::WebContentsObserver: |
37 void WebContentsDestroyed() override; | 37 void WebContentsDestroyed() override; |
38 | 38 |
39 // sync_driver::SyncServiceObserver: | 39 // syncer::SyncServiceObserver: |
40 void OnStateChanged() override; | 40 void OnStateChanged() override; |
41 | 41 |
42 // Loads the |continue_url_| in the |web_contents()|. | 42 // Loads the |continue_url_| in the |web_contents()|. |
43 void LoadContinueUrl(); | 43 void LoadContinueUrl(); |
44 | 44 |
45 // Returns the ProfileSyncService associated with the |web_contents|. | 45 // Returns the ProfileSyncService associated with the |web_contents|. |
46 // The returned value may be NULL. | 46 // The returned value may be NULL. |
47 browser_sync::ProfileSyncService* GetSyncService( | 47 browser_sync::ProfileSyncService* GetSyncService( |
48 content::WebContents* web_contents); | 48 content::WebContents* web_contents); |
49 | 49 |
50 // Deletes the |observer|. Intended to be used as a callback for base::Bind. | 50 // Deletes the |observer|. Intended to be used as a callback for base::Bind. |
51 static void DeleteObserver( | 51 static void DeleteObserver( |
52 base::WeakPtr<OneClickSigninSyncObserver> observer); | 52 base::WeakPtr<OneClickSigninSyncObserver> observer); |
53 | 53 |
54 // The URL to redirect to once Sync is initialized. | 54 // The URL to redirect to once Sync is initialized. |
55 const GURL continue_url_; | 55 const GURL continue_url_; |
56 | 56 |
57 base::WeakPtrFactory<OneClickSigninSyncObserver> weak_ptr_factory_; | 57 base::WeakPtrFactory<OneClickSigninSyncObserver> weak_ptr_factory_; |
58 | 58 |
59 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncObserver); | 59 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncObserver); |
60 }; | 60 }; |
61 | 61 |
62 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_OBSERVER_H_ | 62 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_OBSERVER_H_ |
OLD | NEW |