summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host
diff options
context:
space:
mode:
authorjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-12 05:44:26 +0000
committerjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-12 05:44:26 +0000
commit4bb33630869981809c47c36c3c18813d6b005d34 (patch)
tree505252dfeac2de2d02a89d1f7e69ffcdf4affcf5 /chrome/browser/renderer_host
parenta93244407e205a8619d620ce91bafbdf88eab195 (diff)
downloadchromium_src-4bb33630869981809c47c36c3c18813d6b005d34.zip
chromium_src-4bb33630869981809c47c36c3c18813d6b005d34.tar.gz
chromium_src-4bb33630869981809c47c36c3c18813d6b005d34.tar.bz2
Browser side support (sans UI) for desktop notifications.
BUG=none TEST=none Review URL: http://codereview.chromium.org/194108 Review URL: http://codereview.chromium.org/271052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28696 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc33
-rw-r--r--chrome/browser/renderer_host/render_view_host.h8
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc11
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h8
4 files changed, 60 insertions, 0 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index af14f52..cd9eb26 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -20,6 +20,7 @@
#include "chrome/browser/dom_operation_notification_details.h"
#include "chrome/browser/extensions/extension_message_service.h"
#include "chrome/browser/metrics/user_metrics.h"
+#include "chrome/browser/notifications/desktop_notification_service.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/renderer_host/render_view_host_delegate.h"
@@ -833,6 +834,12 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
OnQueryFormFieldAutofill)
IPC_MESSAGE_HANDLER(ViewHostMsg_RemoveAutofillEntry,
OnRemoveAutofillEntry)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDesktopNotification,
+ OnShowDesktopNotification)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDesktopNotificationText,
+ OnShowDesktopNotificationText)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_RequestNotificationPermission,
+ OnRequestNotificationPermission)
IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionRequest, OnExtensionRequest)
IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnMsgSelectionChanged)
IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionPostMessage,
@@ -1644,6 +1651,32 @@ void RenderViewHost::ForwardMessageFromExternalHost(const std::string& message,
target));
}
+void RenderViewHost::OnShowDesktopNotification(const GURL& source_origin,
+ const GURL& url, int notification_id) {
+ DesktopNotificationService* service =
+ process()->profile()->GetDesktopNotificationService();
+ service->ShowDesktopNotification(source_origin, url, process()->id(),
+ routing_id(), DesktopNotificationService::PageNotification,
+ notification_id);
+}
+
+void RenderViewHost::OnShowDesktopNotificationText(const GURL& source_origin,
+ const GURL& icon, const string16& title, const string16& text,
+ int notification_id) {
+ DesktopNotificationService* service =
+ process()->profile()->GetDesktopNotificationService();
+ service->ShowDesktopNotificationText(source_origin, icon, title, text,
+ process()->id(), routing_id(),
+ DesktopNotificationService::PageNotification, notification_id);
+}
+
+void RenderViewHost::OnRequestNotificationPermission(
+ const GURL& source_origin, int callback_context) {
+ DesktopNotificationService* service =
+ process()->profile()->GetDesktopNotificationService();
+ service->RequestPermission(source_origin, callback_context);
+}
+
void RenderViewHost::OnExtensionRequest(const std::string& name,
const ListValue& args_holder,
int request_id,
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 76b7460..7f24d97 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -577,6 +577,14 @@ class RenderViewHost : public RenderWidgetHost,
void OnRemoveAutofillEntry(const std::wstring& field_name,
const std::wstring& value);
+ void OnShowDesktopNotification(const GURL& source_origin,
+ const GURL& url, int notification_id);
+ void OnShowDesktopNotificationText(const GURL& origin, const GURL& icon,
+ const string16& title,
+ const string16& text,
+ int notification_id);
+ void OnRequestNotificationPermission(const GURL& origin, int callback_id);
+
void OnExtensionRequest(const std::string& name, const ListValue& args,
int request_id, bool has_callback);
void OnExtensionPostMessage(int port_id, const std::string& message);
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index 5645ef6..8927ab0 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -19,6 +19,8 @@
#include "chrome/browser/nacl_process_host.h"
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/net/dns_global.h"
+#include "chrome/browser/notifications/desktop_notification_service.h"
+#include "chrome/browser/notifications/notifications_prefs_cache.h"
#include "chrome/browser/plugin_service.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/privacy_blacklist/blacklist.h"
@@ -167,6 +169,8 @@ ResourceMessageFilter::ResourceMessageFilter(
resource_dispatcher_host->webkit_thread()))),
ALLOW_THIS_IN_INITIALIZER_LIST(db_dispatcher_host_(
new DatabaseDispatcherHost(profile->GetPath(), this))),
+ notification_prefs_(
+ profile->GetDesktopNotificationService()->prefs_cache()),
off_the_record_(profile->IsOffTheRecord()),
next_route_id_callback_(NewCallbackWithReturnValue(
render_widget_helper, &RenderWidgetHelper::GetNextRoutingID)) {
@@ -335,6 +339,8 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(ViewHostMsg_ClipboardFindPboardWriteStringAsync,
OnClipboardFindPboardWriteString)
#endif
+ IPC_MESSAGE_HANDLER(ViewHostMsg_CheckNotificationPermission,
+ OnCheckNotificationPermission)
IPC_MESSAGE_HANDLER(ViewHostMsg_GetMimeTypeFromExtension,
OnGetMimeTypeFromExtension)
IPC_MESSAGE_HANDLER(ViewHostMsg_GetMimeTypeFromFile,
@@ -690,6 +696,11 @@ void ResourceMessageFilter::OnClipboardReadHTML(Clipboard::Buffer buffer,
#endif
+void ResourceMessageFilter::OnCheckNotificationPermission(
+ const GURL& source_origin, int* result) {
+ *result = notification_prefs_->HasPermission(source_origin);
+}
+
void ResourceMessageFilter::OnGetMimeTypeFromExtension(
const FilePath::StringType& ext, std::string* mime_type) {
net::GetMimeTypeFromExtension(ext, mime_type);
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index 8084e72..bcb5ece5 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -36,6 +36,7 @@ class AudioRendererHost;
class DatabaseDispatcherHost;
class DOMStorageDispatcherHost;
class ExtensionMessageService;
+class NotificationsPrefsCache;
class Profile;
class RenderWidgetHelper;
class SpellChecker;
@@ -191,6 +192,9 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
void OnClipboardFindPboardWriteString(const string16& text);
#endif
+ void OnCheckNotificationPermission(const GURL& origin,
+ int* permission_level);
+
#if !defined(OS_MACOSX)
// Not handled in the IO thread on Mac.
void OnGetWindowRect(gfx::NativeViewId window, IPC::Message* reply);
@@ -350,6 +354,10 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
// Handles HTML5 DB related messages
scoped_ptr<DatabaseDispatcherHost> db_dispatcher_host_;
+ // A cache of notifications preferences which is used to handle
+ // Desktop Notifications permission messages.
+ scoped_refptr<NotificationsPrefsCache> notification_prefs_;
+
// Whether this process is used for off the record tabs.
bool off_the_record_;