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

Side by Side Diff: content/renderer/notification_provider.cc

Issue 11232014: Move a bunch of code in content\renderer to the content namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 8 years, 2 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
« no previous file with comments | « content/renderer/notification_provider.h ('k') | content/renderer/p2p/socket_dispatcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/renderer/notification_provider.h" 5 #include "content/renderer/notification_provider.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "content/common/desktop_notification_messages.h" 8 #include "content/common/desktop_notification_messages.h"
9 #include "content/common/view_messages.h" 9 #include "content/common/view_messages.h"
10 #include "content/renderer/render_view_impl.h" 10 #include "content/renderer/render_view_impl.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPermis sionCallback.h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPermis sionCallback.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
16 16
17 using WebKit::WebDocument; 17 using WebKit::WebDocument;
18 using WebKit::WebNotification; 18 using WebKit::WebNotification;
19 using WebKit::WebNotificationPresenter; 19 using WebKit::WebNotificationPresenter;
20 using WebKit::WebNotificationPermissionCallback; 20 using WebKit::WebNotificationPermissionCallback;
21 using WebKit::WebSecurityOrigin; 21 using WebKit::WebSecurityOrigin;
22 using WebKit::WebString; 22 using WebKit::WebString;
23 using WebKit::WebURL; 23 using WebKit::WebURL;
24 24
25 namespace content {
26
27
25 NotificationProvider::NotificationProvider(RenderViewImpl* render_view) 28 NotificationProvider::NotificationProvider(RenderViewImpl* render_view)
26 : content::RenderViewObserver(render_view) { 29 : RenderViewObserver(render_view) {
27 } 30 }
28 31
29 NotificationProvider::~NotificationProvider() { 32 NotificationProvider::~NotificationProvider() {
30 manager_.DetachAll(); 33 manager_.DetachAll();
31 } 34 }
32 35
33 bool NotificationProvider::show(const WebNotification& notification) { 36 bool NotificationProvider::show(const WebNotification& notification) {
34 int notification_id = manager_.RegisterNotification(notification); 37 int notification_id = manager_.RegisterNotification(notification);
35 if (notification.isHTML()) 38 if (notification.isHTML())
36 return ShowHTML(notification, notification_id); 39 return ShowHTML(notification, notification_id);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 95
93 if (message.type() == ViewMsg_Navigate::ID) 96 if (message.type() == ViewMsg_Navigate::ID)
94 OnNavigate(); // Don't want to swallow the message. 97 OnNavigate(); // Don't want to swallow the message.
95 98
96 return handled; 99 return handled;
97 } 100 }
98 101
99 bool NotificationProvider::ShowHTML(const WebNotification& notification, 102 bool NotificationProvider::ShowHTML(const WebNotification& notification,
100 int id) { 103 int id) {
101 DCHECK(notification.isHTML()); 104 DCHECK(notification.isHTML());
102 content::ShowDesktopNotificationHostMsgParams params; 105 ShowDesktopNotificationHostMsgParams params;
103 WebDocument document = render_view()->GetWebView()->mainFrame()->document(); 106 WebDocument document = render_view()->GetWebView()->mainFrame()->document();
104 params.origin = GURL(document.securityOrigin().toString()); 107 params.origin = GURL(document.securityOrigin().toString());
105 params.is_html = true; 108 params.is_html = true;
106 params.contents_url = notification.url(); 109 params.contents_url = notification.url();
107 params.notification_id = id; 110 params.notification_id = id;
108 params.replace_id = notification.replaceId(); 111 params.replace_id = notification.replaceId();
109 return Send(new DesktopNotificationHostMsg_Show(routing_id(), params)); 112 return Send(new DesktopNotificationHostMsg_Show(routing_id(), params));
110 } 113 }
111 114
112 bool NotificationProvider::ShowText(const WebNotification& notification, 115 bool NotificationProvider::ShowText(const WebNotification& notification,
113 int id) { 116 int id) {
114 DCHECK(!notification.isHTML()); 117 DCHECK(!notification.isHTML());
115 content::ShowDesktopNotificationHostMsgParams params; 118 ShowDesktopNotificationHostMsgParams params;
116 params.is_html = false; 119 params.is_html = false;
117 WebDocument document = render_view()->GetWebView()->mainFrame()->document(); 120 WebDocument document = render_view()->GetWebView()->mainFrame()->document();
118 params.origin = GURL(document.securityOrigin().toString()); 121 params.origin = GURL(document.securityOrigin().toString());
119 params.icon_url = notification.iconURL(); 122 params.icon_url = notification.iconURL();
120 params.title = notification.title(); 123 params.title = notification.title();
121 params.body = notification.body(); 124 params.body = notification.body();
122 params.direction = notification.direction(); 125 params.direction = notification.direction();
123 params.notification_id = id; 126 params.notification_id = id;
124 params.replace_id = notification.replaceId(); 127 params.replace_id = notification.replaceId();
125 return Send(new DesktopNotificationHostMsg_Show(routing_id(), params)); 128 return Send(new DesktopNotificationHostMsg_Show(routing_id(), params));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 void NotificationProvider::OnPermissionRequestComplete(int id) { 169 void NotificationProvider::OnPermissionRequestComplete(int id) {
167 WebNotificationPermissionCallback* callback = manager_.GetCallback(id); 170 WebNotificationPermissionCallback* callback = manager_.GetCallback(id);
168 DCHECK(callback); 171 DCHECK(callback);
169 callback->permissionRequestComplete(); 172 callback->permissionRequestComplete();
170 manager_.OnPermissionRequestComplete(id); 173 manager_.OnPermissionRequestComplete(id);
171 } 174 }
172 175
173 void NotificationProvider::OnNavigate() { 176 void NotificationProvider::OnNavigate() {
174 manager_.Clear(); 177 manager_.Clear();
175 } 178 }
179
180 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/notification_provider.h ('k') | content/renderer/p2p/socket_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698