| Index: chrome/renderer/notification_provider.cc
|
| ===================================================================
|
| --- chrome/renderer/notification_provider.cc (revision 71253)
|
| +++ chrome/renderer/notification_provider.cc (working copy)
|
| @@ -10,7 +10,6 @@
|
| #include "chrome/common/render_messages_params.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "chrome/renderer/render_thread.h"
|
| -#include "chrome/renderer/render_view.h"
|
| #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h"
|
| #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
|
| #include "third_party/WebKit/WebKit/chromium/public/WebNotificationPermissionCallback.h"
|
| @@ -25,8 +24,8 @@
|
| using WebKit::WebString;
|
| using WebKit::WebURL;
|
|
|
| -NotificationProvider::NotificationProvider(RenderView* view)
|
| - : view_(view) {
|
| +NotificationProvider::NotificationProvider(RenderView* render_view)
|
| + : RenderView::Observer(render_view) {
|
| }
|
|
|
| NotificationProvider::~NotificationProvider() {
|
| @@ -46,7 +45,7 @@
|
| bool id_found = manager_.GetId(notification, id);
|
| // Won't be found if the notification has already been closed by the user.
|
| if (id_found)
|
| - Send(new ViewHostMsg_CancelDesktopNotification(view_->routing_id(), id));
|
| + Send(new ViewHostMsg_CancelDesktopNotification(routing_id(), id));
|
| }
|
|
|
| void NotificationProvider::objectDestroyed(
|
| @@ -62,7 +61,7 @@
|
| const WebURL& url) {
|
| int permission;
|
| Send(new ViewHostMsg_CheckNotificationPermission(
|
| - view_->routing_id(),
|
| + routing_id(),
|
| url,
|
| &permission));
|
| return static_cast<WebNotificationPresenter::Permission>(permission);
|
| @@ -72,12 +71,12 @@
|
| const WebSecurityOrigin& origin,
|
| WebNotificationPermissionCallback* callback) {
|
| // We only request permission in response to a user gesture.
|
| - if (!view_->webview()->mainFrame()->isProcessingUserGesture())
|
| + if (!render_view()->webview()->mainFrame()->isProcessingUserGesture())
|
| return;
|
|
|
| int id = manager_.RegisterPermissionRequest(callback);
|
|
|
| - Send(new ViewHostMsg_RequestNotificationPermission(view_->routing_id(),
|
| + Send(new ViewHostMsg_RequestNotificationPermission(routing_id(),
|
| GURL(origin.toString()),
|
| id));
|
| }
|
| @@ -93,13 +92,13 @@
|
| OnPermissionRequestComplete);
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| IPC_END_MESSAGE_MAP()
|
| +
|
| + if (message.type() == ViewMsg_Navigate::ID)
|
| + OnNavigate(); // Don't want to swallow the message.
|
| +
|
| return handled;
|
| }
|
|
|
| -void NotificationProvider::OnNavigate() {
|
| - manager_.Clear();
|
| -}
|
| -
|
| bool NotificationProvider::ShowHTML(const WebNotification& notification,
|
| int id) {
|
| // Disallow HTML notifications from unwanted schemes. javascript:
|
| @@ -113,13 +112,13 @@
|
|
|
| DCHECK(notification.isHTML());
|
| ViewHostMsg_ShowNotification_Params params;
|
| - params.origin = GURL(view_->webview()->mainFrame()->url()).GetOrigin();
|
| + params.origin =
|
| + GURL(render_view()->webview()->mainFrame()->url()).GetOrigin();
|
| params.is_html = true;
|
| params.contents_url = notification.url();
|
| params.notification_id = id;
|
| params.replace_id = notification.replaceId();
|
| - return Send(new ViewHostMsg_ShowDesktopNotification(view_->routing_id(),
|
| - params));
|
| + return Send(new ViewHostMsg_ShowDesktopNotification(routing_id(), params));
|
| }
|
|
|
| bool NotificationProvider::ShowText(const WebNotification& notification,
|
| @@ -127,7 +126,8 @@
|
| DCHECK(!notification.isHTML());
|
| ViewHostMsg_ShowNotification_Params params;
|
| params.is_html = false;
|
| - params.origin = GURL(view_->webview()->mainFrame()->url()).GetOrigin();
|
| + params.origin = GURL(
|
| + render_view()->webview()->mainFrame()->url()).GetOrigin();
|
| params.icon_url = notification.iconURL();
|
| params.title = notification.title();
|
| params.body = notification.body();
|
| @@ -135,8 +135,7 @@
|
| params.notification_id = id;
|
| params.replace_id = notification.replaceId();
|
|
|
| - return Send(new ViewHostMsg_ShowDesktopNotification(view_->routing_id(),
|
| - params));
|
| + return Send(new ViewHostMsg_ShowDesktopNotification(routing_id(), params));
|
| }
|
|
|
| void NotificationProvider::OnDisplay(int id) {
|
| @@ -184,6 +183,6 @@
|
| manager_.OnPermissionRequestComplete(id);
|
| }
|
|
|
| -bool NotificationProvider::Send(IPC::Message* message) {
|
| - return RenderThread::current()->Send(message);
|
| +void NotificationProvider::OnNavigate() {
|
| + manager_.Clear();
|
| }
|
|
|