Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / notifications / welcome_notification.h
blob22af93a3d0377d551775e8235a53abdd3bb58f9a
1 // Copyright 2013 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.
5 #ifndef CHROME_BROWSER_NOTIFICATIONS_WELCOME_NOTIFICATION_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_WELCOME_NOTIFICATION_H_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/prefs/pref_member.h"
12 #include "chrome/browser/prefs/pref_service_syncable_observer.h"
13 #include "ui/message_center/notifier_settings.h"
15 namespace message_center {
16 class MessageCenter;
19 namespace user_prefs {
20 class PrefRegistrySyncable;
23 class Notification;
24 class Profile;
26 // WelcomeNotification is a part of DesktopNotificationService and manages
27 // showing and hiding a welcome notification for built-in components that
28 // show notifications. The Welcome Notification presumes network connectivity
29 // since it relies on synced preferences to work. This is generally fine since
30 // the current consumers on the welcome notification also presume network
31 // connectivity.
32 class WelcomeNotification
33 : public PrefServiceSyncableObserver {
34 public:
35 WelcomeNotification(
36 Profile* profile,
37 message_center::MessageCenter* message_center);
38 virtual ~WelcomeNotification();
40 // PrefServiceSyncableObserver
41 virtual void OnIsSyncingChanged() OVERRIDE;
43 // Adds in a the welcome notification if required for components built
44 // into Chrome that show notifications like Chrome Now.
45 void ShowWelcomeNotificationIfNecessary(
46 const Notification& notification);
48 // Handles Preference Registeration for the Welcome Notification.
49 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* prefs);
51 private:
53 enum PopUpRequest {
54 POP_UP_HIDDEN = 0,
55 POP_UP_SHOWN = 1,
58 // Unconditionally shows the welcome notification.
59 void ShowWelcomeNotification(
60 const message_center::NotifierId notifier_id,
61 const base::string16& display_source,
62 PopUpRequest pop_up_request);
64 // Hides the welcome notification.
65 void HideWelcomeNotification();
67 // Called when the Welcome Notification Dismissed pref has been changed.
68 void OnWelcomeNotificationDismissedChanged();
70 // Prefs listener for welcome_notification_dismissed.
71 BooleanPrefMember welcome_notification_dismissed_pref_;
73 // The profile which owns this object.
74 Profile* profile_;
76 // Notification ID of the Welcome Notification.
77 std::string welcome_notification_id_;
79 // If the preferences are still syncing, store the last notification here
80 // so we can replay ShowWelcomeNotificationIfNecessary once the sync finishes.
81 // Simplifying Assumption: The delayed notification has passed the
82 // extension ID check. This means we do not need to store all of the
83 // notifications that may also show a welcome notification.
84 scoped_ptr<Notification> delayed_notification_;
86 message_center::MessageCenter* message_center_; // Weak reference.
89 #endif // CHROME_BROWSER_NOTIFICATIONS_WELCOME_NOTIFICATION_H_