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

Side by Side Diff: chrome/browser/notifications/desktop_notification_service.h

Issue 7810017: Revert 98938 - Migrate Obsolete NotificationsSettings and remove content_settings::NotificationsP... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 months 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ 6 #define CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/string16.h" 15 #include "base/string16.h"
16 #include "chrome/browser/content_settings/content_settings_notification_provider .h"
16 #include "chrome/browser/content_settings/content_settings_provider.h" 17 #include "chrome/browser/content_settings/content_settings_provider.h"
17 #include "chrome/browser/content_settings/host_content_settings_map.h" 18 #include "chrome/browser/prefs/pref_change_registrar.h"
18 #include "chrome/browser/profiles/profile_keyed_service.h" 19 #include "chrome/browser/profiles/profile_keyed_service.h"
19 #include "chrome/common/content_settings.h" 20 #include "chrome/common/content_settings.h"
20 #include "content/common/notification_observer.h" 21 #include "content/common/notification_observer.h"
21 #include "content/common/notification_registrar.h" 22 #include "content/common/notification_registrar.h"
22 #include "googleurl/src/gurl.h" 23 #include "googleurl/src/gurl.h"
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresen ter.h" 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresen ter.h"
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h"
25 26
26 class ContentSettingsPattern;
27 class Extension; 27 class Extension;
28 class Notification; 28 class Notification;
29 class NotificationDelegate; 29 class NotificationDelegate;
30 class NotificationUIManager; 30 class NotificationUIManager;
31 class NotificationsPrefsCache;
31 class PrefService; 32 class PrefService;
32 class Profile; 33 class Profile;
33 class TabContents; 34 class TabContents;
34 struct DesktopNotificationHostMsg_Show_Params; 35 struct DesktopNotificationHostMsg_Show_Params;
35 36
36 // The DesktopNotificationService is an object, owned by the Profile, 37 // The DesktopNotificationService is an object, owned by the Profile,
37 // which provides the creation of desktop "toasts" to web pages and workers. 38 // which provides the creation of desktop "toasts" to web pages and workers.
38 class DesktopNotificationService : public NotificationObserver, 39 class DesktopNotificationService : public NotificationObserver,
39 public ProfileKeyedService { 40 public ProfileKeyedService {
40 public: 41 public:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 76
76 // Methods to setup and modify permission preferences. 77 // Methods to setup and modify permission preferences.
77 void GrantPermission(const GURL& origin); 78 void GrantPermission(const GURL& origin);
78 void DenyPermission(const GURL& origin); 79 void DenyPermission(const GURL& origin);
79 80
80 // NotificationObserver implementation. 81 // NotificationObserver implementation.
81 virtual void Observe(int type, 82 virtual void Observe(int type,
82 const NotificationSource& source, 83 const NotificationSource& source,
83 const NotificationDetails& details); 84 const NotificationDetails& details);
84 85
86 NotificationsPrefsCache* prefs_cache() { return prefs_cache_; }
87
85 // Creates a data:xxxx URL which contains the full HTML for a notification 88 // Creates a data:xxxx URL which contains the full HTML for a notification
86 // using supplied icon, title, and text, run through a template which contains 89 // using supplied icon, title, and text, run through a template which contains
87 // the standard formatting for notifications. 90 // the standard formatting for notifications.
88 static string16 CreateDataUrl(const GURL& icon_url, 91 static string16 CreateDataUrl(const GURL& icon_url,
89 const string16& title, 92 const string16& title,
90 const string16& body, 93 const string16& body,
91 WebKit::WebTextDirection dir); 94 WebKit::WebTextDirection dir);
92 95
93 // Creates a data:xxxx URL which contains the full HTML for a notification 96 // Creates a data:xxxx URL which contains the full HTML for a notification
94 // using resource template which contains the standard formatting for 97 // using resource template which contains the standard formatting for
95 // notifications. 98 // notifications.
96 static string16 CreateDataUrl(int resource, 99 static string16 CreateDataUrl(int resource,
97 const std::vector<std::string>& subst); 100 const std::vector<std::string>& subst);
98 101
99 // The default content setting determines how to handle origins that haven't 102 // The default content setting determines how to handle origins that haven't
100 // been allowed or denied yet. 103 // been allowed or denied yet.
101 ContentSetting GetDefaultContentSetting(); 104 ContentSetting GetDefaultContentSetting();
102 void SetDefaultContentSetting(ContentSetting setting); 105 void SetDefaultContentSetting(ContentSetting setting);
103 bool IsDefaultContentSettingManaged() const; 106 bool IsDefaultContentSettingManaged() const;
104 107
105 // NOTE: This should only be called on the UI thread. 108 // NOTE: This should only be called on the UI thread.
106 void ResetToDefaultContentSetting(); 109 void ResetToDefaultContentSetting();
107 110
108 // Returns all notifications settings. |settings| is cleared before 111 // Returns all origins that explicitly have been allowed.
109 // notifications setting are passed to it. 112 std::vector<GURL> GetAllowedOrigins();
110 void GetNotificationsSettings(
111 HostContentSettingsMap::SettingsForOneType* settings);
112 113
113 // Clears the notifications setting for the given pattern. 114 // Returns all origins that explicitly have been denied.
114 void ClearSetting(const ContentSettingsPattern& pattern); 115 std::vector<GURL> GetBlockedOrigins();
116
117 // Removes an origin from the "explicitly allowed" set.
118 void ResetAllowedOrigin(const GURL& origin);
119
120 // Removes an origin from the "explicitly denied" set.
121 void ResetBlockedOrigin(const GURL& origin);
115 122
116 // Clears the sets of explicitly allowed and denied origins. 123 // Clears the sets of explicitly allowed and denied origins.
117 void ResetAllOrigins(); 124 void ResetAllOrigins();
118 125
126 static void RegisterUserPrefs(PrefService* user_prefs);
127
119 ContentSetting GetContentSetting(const GURL& origin); 128 ContentSetting GetContentSetting(const GURL& origin);
120 129
121 // Checks to see if a given origin has permission to create desktop 130 // Checks to see if a given origin has permission to create desktop
122 // notifications. 131 // notifications.
123 WebKit::WebNotificationPresenter::Permission 132 WebKit::WebNotificationPresenter::Permission
124 HasPermission(const GURL& origin); 133 HasPermission(const GURL& origin);
125 134
126 private: 135 private:
136 void InitPrefs();
127 void StartObserving(); 137 void StartObserving();
128 void StopObserving(); 138 void StopObserving();
129 139
140 void OnPrefsChanged(const std::string& pref_name);
141
130 // Takes a notification object and shows it in the UI. 142 // Takes a notification object and shows it in the UI.
131 void ShowNotification(const Notification& notification); 143 void ShowNotification(const Notification& notification);
132 144
133 // Returns a display name for an origin, to be used in permission infobar 145 // Returns a display name for an origin, to be used in permission infobar
134 // or on the frame of the notification toast. Different from the origin 146 // or on the frame of the notification toast. Different from the origin
135 // itself when dealing with extensions. 147 // itself when dealing with extensions.
136 string16 DisplayNameForOrigin(const GURL& origin); 148 string16 DisplayNameForOrigin(const GURL& origin);
137 149
138 // Notifies the observers when permissions settings change. 150 // Notifies the observers when permissions settings change.
139 void NotifySettingsChange(); 151 void NotifySettingsChange();
140 152
141 // The profile which owns this object. 153 // The profile which owns this object.
142 Profile* profile_; 154 Profile* profile_;
143 155
156 // A cache of preferences which is accessible only on the IO thread
157 // to service synchronous IPCs.
158 scoped_refptr<NotificationsPrefsCache> prefs_cache_;
159
144 // Non-owned pointer to the notification manager which manages the 160 // Non-owned pointer to the notification manager which manages the
145 // UI for desktop toasts. 161 // UI for desktop toasts.
146 NotificationUIManager* ui_manager_; 162 NotificationUIManager* ui_manager_;
147 163
164 scoped_ptr<content_settings::NotificationProvider> provider_;
165
166 PrefChangeRegistrar prefs_registrar_;
148 NotificationRegistrar notification_registrar_; 167 NotificationRegistrar notification_registrar_;
149 168
150 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService); 169 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService);
151 }; 170 };
152 171
153 #endif // CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ 172 #endif // CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698