Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: chrome/browser/extensions/app_notify_channel_ui.h

Issue 8400027: Add code to prompt for browser login during app notification setup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add virtual destructor to interface class Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 virtual ~AppNotifyChannelUI() {}
22
23 class Delegate {
24 public:
25 // A callback for whether the user successfully set up sync or not.
26 virtual void OnSyncSetupResult(bool enabled) = 0;
27 };
28
29 // Shows a prompt for sync setup - |delegate| will be called back later when
30 // setup is complete or cancelled. This should only be called once per
31 // instance.
32 virtual void PromptSyncSetup(Delegate* delegate) = 0;
33 };
34
35
36 class AppNotifyChannelUIImpl : public AppNotifyChannelUI,
37 public ProfileSyncServiceObserver {
38 public:
39 AppNotifyChannelUIImpl(Browser* browser,
40 TabContentsWrapper* wrapper,
41 const std::string& app_name);
42 virtual ~AppNotifyChannelUIImpl();
43
44 // AppNotifyChannelUI.
45 virtual void PromptSyncSetup(AppNotifyChannelUI::Delegate* delegate) OVERRIDE;
46
47 protected:
48 // A private class we use to put up an infobar - its lifetime is managed by
49 // |wrapper_|, so we don't have one as an instance variable.
50 class InfoBar;
51 friend class AppNotifyChannelUIImpl::InfoBar;
52
53 // Called by our InfoBar when it's accepted or cancelled/closed.
54 void OnInfoBarResult(bool accepted);
55
56 // ProfileSyncServiceObserver.
57 virtual void OnStateChanged() OVERRIDE;
58
59 private:
60 void StartObservingSync();
61 void StopObservingSync();
62
63 Browser* browser_;
64 TabContentsWrapper* wrapper_;
65 std::string app_name_;
66 AppNotifyChannelUI::Delegate* delegate_;
67
68 // Have we registered ourself as a ProfileSyncServiceObserver?
69 bool observing_sync_;
70
71 // This is for working around a bug where the first ProfileSyncServiceObserver
72 // callback after starting the sync login process erroneously reports
73 // SetupInProgress as false. See crbug.com/101842.
74 bool got_first_sync_callback_;
75
76 DISALLOW_COPY_AND_ASSIGN(AppNotifyChannelUIImpl);
77 };
78
79 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_UI_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/app_notify_channel_setup_unittest.cc ('k') | chrome/browser/extensions/app_notify_channel_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698