| 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_IMPL_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_UI_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_UI_IMPL_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/extensions/app_notify_channel_ui.h" |
| 12 #include "chrome/browser/sync/profile_sync_service_observer.h" | 13 #include "chrome/browser/sync/profile_sync_service_observer.h" |
| 13 | 14 |
| 14 class Profile; | 15 class Profile; |
| 15 class TabContents; | 16 class TabContents; |
| 16 | 17 |
| 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 virtual ~AppNotifyChannelUI() {} | |
| 22 | |
| 23 // Used to customize the UI we show. | |
| 24 enum UIType { | |
| 25 // Do not prompt the user with an infobar. | |
| 26 NO_INFOBAR, | |
| 27 | |
| 28 // Ask if the app can show notifications. | |
| 29 NOTIFICATION_INFOBAR, | |
| 30 }; | |
| 31 | |
| 32 class Delegate { | |
| 33 public: | |
| 34 // A callback for whether the user successfully set up sync or not. | |
| 35 virtual void OnSyncSetupResult(bool enabled) = 0; | |
| 36 | |
| 37 protected: | |
| 38 virtual ~Delegate() {} | |
| 39 }; | |
| 40 | |
| 41 // 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 | |
| 43 // instance. | |
| 44 virtual void PromptSyncSetup(Delegate* delegate) = 0; | |
| 45 }; | |
| 46 | |
| 47 | |
| 48 class AppNotifyChannelUIImpl : public AppNotifyChannelUI, | 18 class AppNotifyChannelUIImpl : public AppNotifyChannelUI, |
| 49 public ProfileSyncServiceObserver { | 19 public ProfileSyncServiceObserver { |
| 50 public: | 20 public: |
| 51 AppNotifyChannelUIImpl(Profile* profile, | 21 AppNotifyChannelUIImpl(Profile* profile, |
| 52 TabContents* tab_contents, | 22 TabContents* tab_contents, |
| 53 const std::string& app_name, | 23 const std::string& app_name, |
| 54 AppNotifyChannelUI::UIType ui_type); | 24 AppNotifyChannelUI::UIType ui_type); |
| 55 virtual ~AppNotifyChannelUIImpl(); | 25 virtual ~AppNotifyChannelUIImpl(); |
| 56 | 26 |
| 57 // AppNotifyChannelUI. | 27 // AppNotifyChannelUI. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 86 // ProfileSyncServiceObserver::OnStateChanged callback many times | 56 // ProfileSyncServiceObserver::OnStateChanged callback many times |
| 87 // after ShowLoginDialog is called and before the wizard is | 57 // after ShowLoginDialog is called and before the wizard is |
| 88 // actually visible to the user. So we record if the wizard was | 58 // actually visible to the user. So we record if the wizard was |
| 89 // shown to user and then wait for wizard to get dismissed. | 59 // shown to user and then wait for wizard to get dismissed. |
| 90 // See crbug.com/101842. | 60 // See crbug.com/101842. |
| 91 bool wizard_shown_to_user_; | 61 bool wizard_shown_to_user_; |
| 92 | 62 |
| 93 DISALLOW_COPY_AND_ASSIGN(AppNotifyChannelUIImpl); | 63 DISALLOW_COPY_AND_ASSIGN(AppNotifyChannelUIImpl); |
| 94 }; | 64 }; |
| 95 | 65 |
| 96 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_UI_H_ | 66 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_UI_IMPL_H_ |
| OLD | NEW |