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

Side by Side Diff: chrome/browser/ui/sync/one_click_signin_sync_observer.h

Issue 1806353002: Enhanced Sync Confirmation modal (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment Created 4 years, 8 months 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 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 the Sync for the |profile| to be initialized, then navigates the
24 // |continue_url|. Instances of this class delete themselves once the job is 26 // |web_contents| to the |continue_url| or opens |activity_controls_url| in
25 // done. 27 // a new browser tab depending on which one is provided. Instances of
28 // this class delete themselves once the job is done. |web_contents| may be
29 // NULL if only |activity_controls_url| is provided. Similarly |browser| may
30 // be NULL if only |continue_url| is provided.
26 OneClickSigninSyncObserver(content::WebContents* web_contents, 31 OneClickSigninSyncObserver(content::WebContents* web_contents,
32 Profile* profile,
33 Browser* browser,
34 const GURL& activity_controls_url,
27 const GURL& continue_url); 35 const GURL& continue_url);
28 36
29 protected: 37 protected:
30 // Exposed for testing. 38 // Exposed for testing.
31 ~OneClickSigninSyncObserver() override; 39 ~OneClickSigninSyncObserver() override;
32 40
33 private: 41 private:
34 // content::WebContentsObserver: 42 // content::WebContentsObserver:
35 void WebContentsDestroyed() override; 43 void WebContentsDestroyed() override;
36 44
37 // sync_driver::SyncServiceObserver: 45 // sync_driver::SyncServiceObserver:
38 void OnStateChanged() override; 46 void OnStateChanged() override;
39 47
40 // Loads the |continue_url_| in the |web_contents()|. 48 // Loads the |continue_url_| in the |web_contents()|.
41 void LoadContinueUrl(); 49 void LoadContinueUrl();
42 50
43 // Returns the ProfileSyncService associated with the |web_contents|. 51 // Returns the ProfileSyncService associated with the profile.
44 // The returned value may be NULL. 52 // The returned value may be NULL.
45 ProfileSyncService* GetSyncService(content::WebContents* web_contents); 53 ProfileSyncService* GetSyncService();
46 54
47 // Deletes the |observer|. Intended to be used as a callback for base::Bind. 55 // Deletes the |observer|. Intended to be used as a callback for base::Bind.
48 static void DeleteObserver( 56 static void DeleteObserver(
49 base::WeakPtr<OneClickSigninSyncObserver> observer); 57 base::WeakPtr<OneClickSigninSyncObserver> observer);
50 58
59 Profile* profile_;
60
61 Browser* browser_;
Dan Beam 2016/04/04 23:48:38 nit: arguably define the ownership here (i.e. // W
Moe 2016/04/05 17:14:42 Done.
62
63 // The URL of the 'Activity controls' section of the privacy settings page.
64 const GURL activity_controls_url_;
65
51 // The URL to redirect to once Sync is initialized. 66 // The URL to redirect to once Sync is initialized.
52 const GURL continue_url_; 67 const GURL continue_url_;
53 68
54 base::WeakPtrFactory<OneClickSigninSyncObserver> weak_ptr_factory_; 69 base::WeakPtrFactory<OneClickSigninSyncObserver> weak_ptr_factory_;
55 70
56 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncObserver); 71 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncObserver);
57 }; 72 };
58 73
59 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_OBSERVER_H_ 74 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698