Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / sync / one_click_signin_sync_observer.h
blob28b6b9d013e0fc9008d6ef876778e340ed8eda4a
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_OBSERVER_H_
6 #define CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_OBSERVER_H_
8 #include "base/memory/weak_ptr.h"
9 #include "chrome/browser/sync/profile_sync_service_observer.h"
10 #include "content/public/browser/web_contents_observer.h"
11 #include "url/gurl.h"
13 class ProfileSyncService;
15 namespace content {
16 class WebContents;
19 class OneClickSigninSyncObserver : public content::WebContentsObserver,
20 public ProfileSyncServiceObserver {
21 public:
22 // Waits for Sync to be initialized, then navigates the |web_contents| to the
23 // |continue_url|. Instances of this class delete themselves once the job is
24 // done.
25 OneClickSigninSyncObserver(content::WebContents* web_contents,
26 const GURL& continue_url);
28 protected:
29 // Exposed for testing.
30 ~OneClickSigninSyncObserver() override;
32 private:
33 // content::WebContentsObserver:
34 void WebContentsDestroyed() override;
36 // ProfileSyncServiceObserver:
37 void OnStateChanged() override;
39 // Loads the |continue_url_| in the |web_contents()|.
40 void LoadContinueUrl();
42 // Returns the ProfileSyncService associated with the |web_contents|.
43 // The returned value may be NULL.
44 ProfileSyncService* GetSyncService(content::WebContents* web_contents);
46 // Deletes the |observer|. Intended to be used as a callback for base::Bind.
47 static void DeleteObserver(
48 base::WeakPtr<OneClickSigninSyncObserver> observer);
50 // The URL to redirect to once Sync is initialized.
51 const GURL continue_url_;
53 base::WeakPtrFactory<OneClickSigninSyncObserver> weak_ptr_factory_;
55 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncObserver);
58 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_OBSERVER_H_