Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_UI_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_UI_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "chrome/browser/sync/profile_sync_service_observer.h" | |
| 13 | |
| 14 class Browser; | |
| 15 class TabContentsWrapper; | |
| 16 | |
| 17 // An interface for prompting a user to sign in to sync so that we can create | |
| 18 // an app notification channel for one of their apps. | |
| 19 class AppNotifyChannelUI { | |
| 20 public: | |
| 21 class Delegate { | |
| 22 public: | |
| 23 // A callback for whether the user successfully set up sync or not. | |
| 24 virtual void OnSyncSetupResult(bool enabled) = 0; | |
| 25 }; | |
| 26 | |
| 27 // Shows a prompt for sync setup - |delegate| will be called back later when | |
| 28 // setup is complete or cancelled. This should only be called once per | |
| 29 // instance. | |
| 30 virtual void PromptSyncSetup(Delegate* delegate) = 0; | |
| 31 }; | |
| 32 | |
| 33 | |
| 34 class AppNotifyChannelUIImpl : public AppNotifyChannelUI, | |
| 35 public ProfileSyncServiceObserver { | |
| 36 public: | |
| 37 AppNotifyChannelUIImpl(Browser* browser, | |
| 38 TabContentsWrapper* wrapper, | |
| 39 const std::string& app_name); | |
| 40 virtual ~AppNotifyChannelUIImpl(); | |
| 41 | |
| 42 // AppNotifyChannelUI. | |
| 43 virtual void PromptSyncSetup(AppNotifyChannelUI::Delegate* delegate) OVERRIDE; | |
| 44 | |
| 45 protected: | |
| 46 // A private class we use to put up an infobar - it's lifetime is managed by | |
|
Mihai Parparita -not on Chrome
2011/10/27 22:21:05
Typo (it's -> its).
asargent_no_longer_on_chrome
2011/10/28 17:09:22
Done.
| |
| 47 // |wrapper_|, so we don't have one as an instance variable. | |
| 48 class InfoBar; | |
| 49 friend class AppNotifyChannelUIImpl::InfoBar; | |
| 50 | |
| 51 // Called by our InfoBar when it's accepted or cancelled/closed. | |
| 52 void OnInfoBarResult(bool accepted); | |
| 53 | |
| 54 // ProfileSyncServiceObserver. | |
| 55 virtual void OnStateChanged() OVERRIDE; | |
| 56 | |
| 57 private: | |
| 58 void StartObservingSync(); | |
| 59 void StopObservingSync(); | |
| 60 | |
| 61 Browser* browser_; | |
| 62 TabContentsWrapper* wrapper_; | |
| 63 std::string app_name_; | |
| 64 AppNotifyChannelUI::Delegate* delegate_; | |
| 65 | |
| 66 // Have we registered ourself as a ProfileSyncServiceObserver? | |
| 67 bool observing_sync_; | |
| 68 | |
| 69 // This is for working around a bug where the first ProfileSyncServiceObserver | |
| 70 // callback after starting the sync login process erroneously reports | |
| 71 // SetupInProgress as false. See crbug.com/101842. | |
| 72 bool got_first_sync_callback_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(AppNotifyChannelUIImpl); | |
| 75 }; | |
| 76 | |
| 77 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_UI_H_ | |
| OLD | NEW |