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

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

Issue 561813002: Move the logic for creating data: URLs out of DesktopNotificationService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
OLDNEW
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_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 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 // The DesktopNotificationService is an object, owned by the Profile, 59 // The DesktopNotificationService is an object, owned by the Profile,
60 // which provides the creation of desktop "toasts" to web pages and workers. 60 // which provides the creation of desktop "toasts" to web pages and workers.
61 class DesktopNotificationService 61 class DesktopNotificationService
62 : public PermissionContextBase, 62 : public PermissionContextBase,
63 public extensions::ExtensionRegistryObserver { 63 public extensions::ExtensionRegistryObserver {
64 public: 64 public:
65 // Register profile-specific prefs of notifications. 65 // Register profile-specific prefs of notifications.
66 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* prefs); 66 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* prefs);
67 67
68 DesktopNotificationService(Profile* profile, 68 // Add a desktop notification.
69 NotificationUIManager* ui_manager); 69 static std::string AddIconNotification(const GURL& origin_url,
70 const base::string16& title,
71 const base::string16& message,
72 const gfx::Image& icon,
73 const base::string16& replace_id,
74 NotificationDelegate* delegate,
75 Profile* profile);
76
77 explicit DesktopNotificationService(Profile* profile);
70 virtual ~DesktopNotificationService(); 78 virtual ~DesktopNotificationService();
71 79
72 // Requests Web Notification permission for |requesting_frame|. The |callback| 80 // Requests Web Notification permission for |requesting_frame|. The |callback|
73 // will be invoked after the user has made a decision. 81 // will be invoked after the user has made a decision.
74 void RequestNotificationPermission( 82 void RequestNotificationPermission(
75 content::WebContents* web_contents, 83 content::WebContents* web_contents,
76 const PermissionRequestID& request_id, 84 const PermissionRequestID& request_id,
77 const GURL& requesting_frame, 85 const GURL& requesting_frame,
78 bool user_gesture, 86 bool user_gesture,
79 const NotificationPermissionCallback& callback); 87 const NotificationPermissionCallback& callback);
80 88
81 // Show a desktop notification. If |cancel_callback| is non-null, it's set to 89 // Show a desktop notification. If |cancel_callback| is non-null, it's set to
82 // a callback which can be used to cancel the notification. 90 // a callback which can be used to cancel the notification.
83 void ShowDesktopNotification( 91 void ShowDesktopNotification(
84 const content::ShowDesktopNotificationHostMsgParams& params, 92 const content::ShowDesktopNotificationHostMsgParams& params,
85 content::RenderFrameHost* render_frame_host, 93 content::RenderFrameHost* render_frame_host,
86 scoped_ptr<content::DesktopNotificationDelegate> delegate, 94 scoped_ptr<content::DesktopNotificationDelegate> delegate,
87 base::Closure* cancel_callback); 95 base::Closure* cancel_callback);
88 96
89 // Creates a data:xxxx URL which contains the full HTML for a notification
90 // using supplied icon, title, and text, run through a template which contains
91 // the standard formatting for notifications.
92 static base::string16 CreateDataUrl(const GURL& icon_url,
93 const base::string16& title,
94 const base::string16& body,
95 blink::WebTextDirection dir);
96
97 // Creates a data:xxxx URL which contains the full HTML for a notification
98 // using resource template which contains the standard formatting for
99 // notifications.
100 static base::string16 CreateDataUrl(int resource,
101 const std::vector<std::string>& subst);
102
103 // Add a desktop notification.
104 static std::string AddIconNotification(const GURL& origin_url,
105 const base::string16& title,
106 const base::string16& message,
107 const gfx::Image& icon,
108 const base::string16& replace_id,
109 NotificationDelegate* delegate,
110 Profile* profile);
111
112 // Returns true if the notifier with |notifier_id| is allowed to send 97 // Returns true if the notifier with |notifier_id| is allowed to send
113 // notifications. 98 // notifications.
114 bool IsNotifierEnabled(const message_center::NotifierId& notifier_id); 99 bool IsNotifierEnabled(const message_center::NotifierId& notifier_id);
115 100
116 // Updates the availability of the notifier. 101 // Updates the availability of the notifier.
117 void SetNotifierEnabled(const message_center::NotifierId& notifier_id, 102 void SetNotifierEnabled(const message_center::NotifierId& notifier_id,
118 bool enabled); 103 bool enabled);
119 104
120 // Adds in a the welcome notification if required for components built 105 // Adds in a the welcome notification if required for components built
121 // into Chrome that show notifications like Chrome Now. 106 // into Chrome that show notifications like Chrome Now.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 163
179 // Welcome Notification 164 // Welcome Notification
180 scoped_ptr<ExtensionWelcomeNotification> chrome_now_welcome_notification_; 165 scoped_ptr<ExtensionWelcomeNotification> chrome_now_welcome_notification_;
181 166
182 base::WeakPtrFactory<DesktopNotificationService> weak_factory_; 167 base::WeakPtrFactory<DesktopNotificationService> weak_factory_;
183 168
184 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService); 169 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService);
185 }; 170 };
186 171
187 #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