Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_EXTENSIONS_APP_NOTIFY_CHANNEL_UI_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_UI_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_UI_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_UI_H_ |
| 7 | 7 |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
|
Yoyo Zhou
2012/07/13 20:47:33
This doesn't seem to be used.
nilesh
2012/07/13 21:25:30
Removed.
| |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "chrome/browser/sync/profile_sync_service_observer.h" | |
| 13 | |
| 14 class Profile; | |
| 15 class TabContents; | |
| 16 | 9 |
| 17 // An interface for prompting a user to sign in to sync so that we can create | 10 // 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. | 11 // an app notification channel for one of their apps. |
| 19 class AppNotifyChannelUI { | 12 class AppNotifyChannelUI { |
| 20 public: | 13 public: |
| 21 virtual ~AppNotifyChannelUI() {} | 14 virtual ~AppNotifyChannelUI() {} |
| 22 | 15 |
| 23 // Used to customize the UI we show. | 16 // Used to customize the UI we show. |
| 24 enum UIType { | 17 enum UIType { |
| 25 // Do not prompt the user with an infobar. | 18 // Do not prompt the user with an infobar. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 37 protected: | 30 protected: |
| 38 virtual ~Delegate() {} | 31 virtual ~Delegate() {} |
| 39 }; | 32 }; |
| 40 | 33 |
| 41 // Shows a prompt for sync setup - |delegate| will be called back later when | 34 // Shows a prompt for sync setup - |delegate| will be called back later when |
| 42 // setup is complete or cancelled. This should only be called once per | 35 // setup is complete or cancelled. This should only be called once per |
| 43 // instance. | 36 // instance. |
| 44 virtual void PromptSyncSetup(Delegate* delegate) = 0; | 37 virtual void PromptSyncSetup(Delegate* delegate) = 0; |
| 45 }; | 38 }; |
| 46 | 39 |
| 47 | |
| 48 class AppNotifyChannelUIImpl : public AppNotifyChannelUI, | |
| 49 public ProfileSyncServiceObserver { | |
| 50 public: | |
| 51 AppNotifyChannelUIImpl(Profile* profile, | |
| 52 TabContents* tab_contents, | |
| 53 const std::string& app_name, | |
| 54 AppNotifyChannelUI::UIType ui_type); | |
| 55 virtual ~AppNotifyChannelUIImpl(); | |
| 56 | |
| 57 // AppNotifyChannelUI. | |
| 58 virtual void PromptSyncSetup(AppNotifyChannelUI::Delegate* delegate) OVERRIDE; | |
| 59 | |
| 60 protected: | |
| 61 // A private class we use to put up an infobar - its lifetime is managed by | |
| 62 // |tab_contents_|, so we don't have one as an instance variable. | |
| 63 class InfoBar; | |
| 64 friend class AppNotifyChannelUIImpl::InfoBar; | |
| 65 | |
| 66 // Called by our InfoBar when it's accepted or cancelled/closed. | |
| 67 void OnInfoBarResult(bool accepted); | |
| 68 | |
| 69 // ProfileSyncServiceObserver. | |
| 70 virtual void OnStateChanged() OVERRIDE; | |
| 71 | |
| 72 private: | |
| 73 void StartObservingSync(); | |
| 74 void StopObservingSync(); | |
| 75 | |
| 76 Profile* profile_; | |
| 77 TabContents* tab_contents_; | |
| 78 std::string app_name_; | |
| 79 AppNotifyChannelUI::UIType ui_type_; | |
| 80 AppNotifyChannelUI::Delegate* delegate_; | |
| 81 | |
| 82 // Have we registered ourself as a ProfileSyncServiceObserver? | |
| 83 bool observing_sync_; | |
| 84 | |
| 85 // This is for working around a bug that ProfileSyncService calls | |
| 86 // ProfileSyncServiceObserver::OnStateChanged callback many times | |
| 87 // after ShowLoginDialog is called and before the wizard is | |
| 88 // actually visible to the user. So we record if the wizard was | |
| 89 // shown to user and then wait for wizard to get dismissed. | |
| 90 // See crbug.com/101842. | |
| 91 bool wizard_shown_to_user_; | |
| 92 | |
| 93 DISALLOW_COPY_AND_ASSIGN(AppNotifyChannelUIImpl); | |
| 94 }; | |
| 95 | |
| 96 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_UI_H_ | 40 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_UI_H_ |
| OLD | NEW |