summaryrefslogtreecommitdiffstats
path: root/content/browser/renderer_host
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-07 23:06:04 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-07 23:06:04 +0000
commit941623e10404335546871d8b023b072e754a6c45 (patch)
tree1e13b8837fc5fb301a294abd083593d375829ab9 /content/browser/renderer_host
parent100b16873638b6e634eab434248f6adde05eef07 (diff)
downloadchromium_src-941623e10404335546871d8b023b072e754a6c45.zip
chromium_src-941623e10404335546871d8b023b072e754a6c45.tar.gz
chromium_src-941623e10404335546871d8b023b072e754a6c45.tar.bz2
Get rid of Chrome notifications dependency, and instead go through ContentBrowserClient to show UI. Also the Chrome notifications code now calls methods in RenderViewHost instead of directly sending the content layer IPCs.
BUG=76697 Review URL: http://codereview.chromium.org/7125006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88234 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/renderer_host')
-rw-r--r--content/browser/renderer_host/render_message_filter.cc21
-rw-r--r--content/browser/renderer_host/render_message_filter.h3
-rw-r--r--content/browser/renderer_host/render_view_host.cc61
-rw-r--r--content/browser/renderer_host/render_view_host.h15
-rw-r--r--content/browser/renderer_host/render_view_host_delegate.cc5
-rw-r--r--content/browser/renderer_host/render_view_host_delegate.h6
6 files changed, 77 insertions, 34 deletions
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index 83385fc..42806c0e 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -16,8 +16,6 @@
#include "chrome/browser/download/download_types.h"
#include "chrome/browser/download/download_util.h"
#include "chrome/browser/extensions/extension_info_map.h"
-#include "chrome/browser/notifications/desktop_notification_service.h"
-#include "chrome/browser/notifications/desktop_notification_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
@@ -284,8 +282,6 @@ RenderMessageFilter::RenderMessageFilter(
resource_context_(profile->GetResourceContext()),
extensions_request_context_(profile->GetRequestContextForExtensions()),
render_widget_helper_(render_widget_helper),
- notification_service_(
- DesktopNotificationServiceFactory::GetForProfile(profile)),
incognito_(profile->IsOffTheRecord()),
webkit_context_(profile->GetWebKitContext()),
render_process_id_(render_process_id) {
@@ -614,21 +610,8 @@ void RenderMessageFilter::OnDownloadUrl(const IPC::Message& message,
void RenderMessageFilter::OnCheckNotificationPermission(
const GURL& source_url, int* result) {
- *result = WebKit::WebNotificationPresenter::PermissionNotAllowed;
-
- const Extension* extension =
- extension_info_map_->extensions().GetByURL(source_url);
- if (extension &&
- extension->HasApiPermission(Extension::kNotificationPermission)) {
- *result = WebKit::WebNotificationPresenter::PermissionAllowed;
- return;
- }
-
- // Fall back to the regular notification preferences, which works on an
- // origin basis.
- *result = notification_service_ ?
- notification_service_->HasPermission(source_url.GetOrigin()) :
- WebKit::WebNotificationPresenter::PermissionNotAllowed;
+ *result = content::GetContentClient()->browser()->
+ CheckDesktopNotificationPermission(source_url, resource_context_);
}
void RenderMessageFilter::OnAllocateSharedMemoryBuffer(
diff --git a/content/browser/renderer_host/render_message_filter.h b/content/browser/renderer_host/render_message_filter.h
index 6207ba7..77b9d51 100644
--- a/content/browser/renderer_host/render_message_filter.h
+++ b/content/browser/renderer_host/render_message_filter.h
@@ -26,7 +26,6 @@
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/surface/transport_dib.h"
-class DesktopNotificationService;
struct FontDescriptor;
class ExtensionInfoMap;
class HostContentSettingsMap;
@@ -238,8 +237,6 @@ class RenderMessageFilter : public BrowserMessageFilter {
scoped_refptr<RenderWidgetHelper> render_widget_helper_;
- DesktopNotificationService* notification_service_;
-
// Whether this process is used for incognito tabs.
bool incognito_;
diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc
index 417328a..f5aa764 100644
--- a/content/browser/renderer_host/render_view_host.cc
+++ b/content/browser/renderer_host/render_view_host.cc
@@ -31,6 +31,7 @@
#include "content/browser/user_metrics.h"
#include "content/common/bindings_policy.h"
#include "content/common/content_constants.h"
+#include "content/common/desktop_notification_messages.h"
#include "content/common/drag_messages.h"
#include "content/common/native_web_keyboard_event.h"
#include "content/common/notification_details.h"
@@ -421,6 +422,32 @@ void RenderViewHost::DragTargetDrop(
Send(new DragMsg_TargetDrop(routing_id(), client_pt, screen_pt));
}
+void RenderViewHost::DesktopNotificationPermissionRequestDone(
+ int callback_context) {
+ Send(new DesktopNotificationMsg_PermissionRequestDone(
+ routing_id(), callback_context));
+}
+
+void RenderViewHost::DesktopNotificationPostDisplay(int callback_context) {
+ Send(new DesktopNotificationMsg_PostDisplay(routing_id(), callback_context));
+}
+
+void RenderViewHost::DesktopNotificationPostError(int notification_id,
+ const string16& message) {
+ Send(new DesktopNotificationMsg_PostError(
+ routing_id(), notification_id, message));
+}
+
+void RenderViewHost::DesktopNotificationPostClose(int notification_id,
+ bool by_user) {
+ Send(new DesktopNotificationMsg_PostClose(
+ routing_id(), notification_id, by_user));
+}
+
+void RenderViewHost::DesktopNotificationPostClick(int notification_id) {
+ Send(new DesktopNotificationMsg_PostClick(routing_id(), notification_id));
+}
+
void RenderViewHost::ExecuteJavascriptInWebFrame(
const string16& frame_xpath,
const string16& jscript) {
@@ -662,6 +689,12 @@ bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
OnAccessibilityNotifications)
IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse)
IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL)
+ IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission,
+ OnRequestDesktopNotificationPermission)
+ IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show,
+ OnShowDesktopNotification)
+ IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel,
+ OnCancelDesktopNotification)
#if defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup)
#endif
@@ -1244,6 +1277,34 @@ void RenderViewHost::OnDidZoomURL(double zoom_level,
}
}
+void RenderViewHost::OnRequestDesktopNotificationPermission(
+ const GURL& source_origin, int callback_context) {
+ content::GetContentClient()->browser()->RequestDesktopNotificationPermission(
+ source_origin, callback_context, process()->id(), routing_id());
+}
+
+void RenderViewHost::OnShowDesktopNotification(
+ const DesktopNotificationHostMsg_Show_Params& params) {
+ // Disallow HTML notifications from unwanted schemes. javascript:
+ // in particular allows unwanted cross-domain access.
+ GURL url = params.contents_url;
+ if (params.is_html &&
+ !url.SchemeIs(chrome::kHttpScheme) &&
+ !url.SchemeIs(chrome::kHttpsScheme) &&
+ !url.SchemeIs(chrome::kExtensionScheme) &&
+ !url.SchemeIs(chrome::kDataScheme)) {
+ return;
+ }
+
+ content::GetContentClient()->browser()->ShowDesktopNotification(
+ params, process()->id(), routing_id(), false);
+}
+
+void RenderViewHost::OnCancelDesktopNotification(int notification_id) {
+ content::GetContentClient()->browser()->CancelDesktopNotification(
+ process()->id(), routing_id(), notification_id);
+}
+
#if defined(OS_MACOSX)
void RenderViewHost::OnMsgShowPopup(
const ViewHostMsg_ShowPopup_Params& params) {
diff --git a/content/browser/renderer_host/render_view_host.h b/content/browser/renderer_host/render_view_host.h
index 34aa17e..3420536 100644
--- a/content/browser/renderer_host/render_view_host.h
+++ b/content/browser/renderer_host/render_view_host.h
@@ -24,6 +24,7 @@
#include "webkit/glue/window_open_disposition.h"
class ChildProcessSecurityPolicy;
+struct DesktopNotificationHostMsg_Show_Params;
class FilePath;
class GURL;
class ListValue;
@@ -231,6 +232,14 @@ class RenderViewHost : public RenderWidgetHost {
void DragTargetDrop(const gfx::Point& client_pt,
const gfx::Point& screen_pt);
+ // Notifies the renderer about the result of a desktop notification.
+ void DesktopNotificationPermissionRequestDone(int callback_context);
+ void DesktopNotificationPostDisplay(int callback_context);
+ void DesktopNotificationPostError(int notification_id,
+ const string16& message);
+ void DesktopNotificationPostClose(int notification_id, bool by_user);
+ void DesktopNotificationPostClick(int notification_id);
+
// Runs some javascript within the context of a frame in the page.
void ExecuteJavascriptInWebFrame(const string16& frame_xpath,
const string16& jscript);
@@ -438,11 +447,15 @@ class RenderViewHost : public RenderWidgetHost {
const std::string& value);
void OnMsgShouldCloseACK(bool proceed);
void OnMsgClosePageACK();
-
void OnAccessibilityNotifications(
const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params);
void OnScriptEvalResponse(int id, const ListValue& result);
void OnDidZoomURL(double zoom_level, bool remember, const GURL& url);
+ void OnRequestDesktopNotificationPermission(const GURL& origin,
+ int callback_id);
+ void OnShowDesktopNotification(
+ const DesktopNotificationHostMsg_Show_Params& params);
+ void OnCancelDesktopNotification(int notification_id);
#if defined(OS_MACOSX)
void OnMsgShowPopup(const ViewHostMsg_ShowPopup_Params& params);
diff --git a/content/browser/renderer_host/render_view_host_delegate.cc b/content/browser/renderer_host/render_view_host_delegate.cc
index d520a2c4..2d6a165 100644
--- a/content/browser/renderer_host/render_view_host_delegate.cc
+++ b/content/browser/renderer_host/render_view_host_delegate.cc
@@ -47,8 +47,3 @@ WebPreferences RenderViewHostDelegate::GetWebkitPrefs() {
bool RenderViewHostDelegate::IsExternalTabContainer() const {
return false;
}
-
-bool RenderViewHostDelegate::RequestDesktopNotificationPermission(
- const GURL& source_origin, int callback_context) {
- return false;
-}
diff --git a/content/browser/renderer_host/render_view_host_delegate.h b/content/browser/renderer_host/render_view_host_delegate.h
index b7508fe..3bbfb48 100644
--- a/content/browser/renderer_host/render_view_host_delegate.h
+++ b/content/browser/renderer_host/render_view_host_delegate.h
@@ -413,12 +413,6 @@ class RenderViewHostDelegate : public IPC::Channel::Listener {
// Notification that a worker process has crashed.
void WorkerCrashed() {}
- // Ask the user if they want to allow the view to show desktop notifications.
- // Returns true if the delegate will take care of asking the user, otherwise
- // the caller will do the default behavior.
- bool RequestDesktopNotificationPermission(const GURL& source_origin,
- int callback_context);
-
protected:
virtual ~RenderViewHostDelegate() {}
};