summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host/render_view_host.cc
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-27 19:49:22 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-27 19:49:22 +0000
commitc4afa29dae12fcb41be1b260da8c1cb537dae99c (patch)
tree8c6102c514417b1f2dda4612d35ca22724e29986 /chrome/browser/renderer_host/render_view_host.cc
parent9f1f1fcf77bf3e1a3073f35706efe8b739c0d5ae (diff)
downloadchromium_src-c4afa29dae12fcb41be1b260da8c1cb537dae99c.zip
chromium_src-c4afa29dae12fcb41be1b260da8c1cb537dae99c.tar.gz
chromium_src-c4afa29dae12fcb41be1b260da8c1cb537dae99c.tar.bz2
Revert 72861 (chrome/browser/desktop_notification_handler.cc:53:warning: unused variable 'process')- Move the handling of Desktop notification IPCs coming in from the renderer into a helper
object DesktopNotificationHandler whose lifetype is dependent on the TabContents which instantiates it. This object implements the WebNavigationObserver interface which enables it to handle IPCs on the UI thread. The DeskopNotificationHandler object is also instantiated by the ExtensionHost object as it expects the desktop notification IPC's to be handled. I also changed the desktop notification IPCs to carry the routing id as an additional parameter as the notification handling in the browser needs the routing id. BUG=70690 TEST=no change in functionality. Review URL: http://codereview.chromium.org/6340017 TBR=ananta@chromium.org Review URL: http://codereview.chromium.org/6354027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72863 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host/render_view_host.cc')
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 7378720..e6178d8 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -15,6 +15,7 @@
#include "base/time.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
+#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_thread.h"
#include "chrome/browser/child_process_security_policy.h"
@@ -25,6 +26,7 @@
#include "chrome/browser/in_process_webkit/session_storage_namespace.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/net/predictor_api.h"
+#include "chrome/browser/notifications/desktop_notification_service.h"
#include "chrome/browser/printing/printer_query.h"
#include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/printing/print_preview_tab_controller.h"
@@ -786,6 +788,12 @@ bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_FORWARD(ViewHostMsg_JSOutOfMemory, delegate_,
RenderViewHostDelegate::OnJSOutOfMemory)
IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDesktopNotification,
+ OnShowDesktopNotification)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_CancelDesktopNotification,
+ OnCancelDesktopNotification)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_RequestNotificationPermission,
+ OnRequestNotificationPermission)
IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionRequest, OnExtensionRequest)
IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnMsgSelectionChanged)
IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionPostMessage,
@@ -1471,6 +1479,39 @@ void RenderViewHost::ForwardMessageFromExternalHost(const std::string& message,
target));
}
+void RenderViewHost::OnShowDesktopNotification(
+ const ViewHostMsg_ShowNotification_Params& params) {
+ DesktopNotificationService* service =
+ process()->profile()->GetDesktopNotificationService();
+
+ service->ShowDesktopNotification(
+ params, process()->id(), routing_id(),
+ DesktopNotificationService::PageNotification);
+}
+
+void RenderViewHost::OnCancelDesktopNotification(int notification_id) {
+ DesktopNotificationService* service=
+ process()->profile()->GetDesktopNotificationService();
+ service->CancelDesktopNotification(
+ process()->id(), routing_id(), notification_id);
+}
+
+void RenderViewHost::OnRequestNotificationPermission(
+ const GURL& source_origin, int callback_context) {
+ Browser* browser = BrowserList::GetLastActive();
+ // We may not have a BrowserList if the chrome browser process is launched as
+ // a ChromeFrame process in which case we attempt to use the TabContents
+ // provided by the RenderViewHostDelegate.
+ TabContents* tab = browser ? browser->GetSelectedTabContents() :
+ (delegate_ ? delegate_->GetAsTabContents() : NULL);
+ if (tab) {
+ DesktopNotificationService* service =
+ process()->profile()->GetDesktopNotificationService();
+ service->RequestPermission(
+ source_origin, process()->id(), routing_id(), callback_context, tab);
+ }
+}
+
void RenderViewHost::OnExtensionRequest(
const ViewHostMsg_DomMessage_Params& params) {
if (!ChildProcessSecurityPolicy::GetInstance()->