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