summaryrefslogtreecommitdiffstats
path: root/chrome
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
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')
-rw-r--r--chrome/browser/desktop_notification_handler.cc87
-rw-r--r--chrome/browser/desktop_notification_handler.h43
-rw-r--r--chrome/browser/extensions/extension_host.cc9
-rw-r--r--chrome/browser/extensions/extension_host.h4
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc41
-rw-r--r--chrome/browser/renderer_host/render_view_host.h5
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc4
-rw-r--r--chrome/browser/tab_contents/tab_contents.h5
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/common/render_messages_internal.h8
-rw-r--r--chrome/common/render_messages_params.cc6
-rw-r--r--chrome/common/render_messages_params.h3
-rw-r--r--chrome/renderer/notification_provider.cc7
13 files changed, 52 insertions, 172 deletions
diff --git a/chrome/browser/desktop_notification_handler.cc b/chrome/browser/desktop_notification_handler.cc
deleted file mode 100644
index b5973ef..0000000
--- a/chrome/browser/desktop_notification_handler.cc
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/desktop_notification_handler.h"
-
-#include "chrome/browser/browser_list.h"
-#include "chrome/browser/notifications/desktop_notification_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/renderer_host/render_process_host.h"
-#include "chrome/browser/tab_contents/tab_contents.h"
-#include "chrome/common/render_messages.h"
-#include "chrome/common/render_messages_params.h"
-
-DesktopNotificationHandler::DesktopNotificationHandler(
- TabContents* tab, RenderProcessHost* process)
- : tab_(tab),
- process_(process) {
-}
-
-bool DesktopNotificationHandler::OnMessageReceived(
- const IPC::Message& message) {
- bool handled = true;
-
- IPC_BEGIN_MESSAGE_MAP(DesktopNotificationHandler, message)
- IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDesktopNotification,
- OnShowDesktopNotification)
- IPC_MESSAGE_HANDLER(ViewHostMsg_CancelDesktopNotification,
- OnCancelDesktopNotification)
- IPC_MESSAGE_HANDLER(ViewHostMsg_RequestNotificationPermission,
- OnRequestNotificationPermission)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
-
- return handled;
-}
-
-void DesktopNotificationHandler::OnShowDesktopNotification(
- const ViewHostMsg_ShowNotification_Params& params) {
- RenderProcessHost* process = GetRenderProcessHost();
- DesktopNotificationService* service =
- process->profile()->GetDesktopNotificationService();
-
- service->ShowDesktopNotification(
- params,
- process->id(),
- params.routing_id,
- DesktopNotificationService::PageNotification);
-}
-
-void DesktopNotificationHandler::OnCancelDesktopNotification(
- int routing_id, int notification_id) {
- RenderProcessHost* process = GetRenderProcessHost();
- DesktopNotificationService* service =
- process_->profile()->GetDesktopNotificationService();
-
- service->CancelDesktopNotification(
- process_->id(),
- routing_id,
- notification_id);
-}
-
-void DesktopNotificationHandler::OnRequestNotificationPermission(
- int routing_id, const GURL& source_origin, int callback_context) {
- RenderProcessHost* process = GetRenderProcessHost();
- 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() : tab_;
- if (!tab)
- return;
-
- DesktopNotificationService* service =
- tab->profile()->GetDesktopNotificationService();
- service->RequestPermission(
- source_origin,
- process->id(),
- routing_id,
- callback_context,
- tab);
-}
-
-RenderProcessHost* DesktopNotificationHandler::GetRenderProcessHost() {
- return tab_ ? tab_->GetRenderProcessHost() : process_;
-}
-
diff --git a/chrome/browser/desktop_notification_handler.h b/chrome/browser/desktop_notification_handler.h
deleted file mode 100644
index 7fce602..0000000
--- a/chrome/browser/desktop_notification_handler.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_DESKTOP_NOTIFICATION_HANDLER_H_
-#define CHROME_BROWSER_DESKTOP_NOTIFICATION_HANDLER_H_
-#pragma once
-
-#include "chrome/browser/tab_contents/web_navigation_observer.h"
-
-struct ViewHostMsg_ShowNotification_Params;
-class RenderProcessHost;
-
-// Per-tab Desktop notification handler. Handles desktop notification IPCs
-// coming in from the renderer.
-class DesktopNotificationHandler : public WebNavigationObserver {
- public:
- explicit DesktopNotificationHandler(TabContents* tab_contents,
- RenderProcessHost* process);
- virtual ~DesktopNotificationHandler() {}
-
- // WebNavigationObserver implementation.
- virtual bool OnMessageReceived(const IPC::Message& message);
-
- RenderProcessHost* GetRenderProcessHost();
-
- private:
- // IPC handlers.
- void OnShowDesktopNotification(
- const ViewHostMsg_ShowNotification_Params& params);
- void OnCancelDesktopNotification(int routing_id, int notification_id);
- void OnRequestNotificationPermission(int routing_id, const GURL& origin,
- int callback_id);
-
- private:
- TabContents* tab_;
- RenderProcessHost* process_;
-
- DISALLOW_COPY_AND_ASSIGN(DesktopNotificationHandler);
-};
-
-#endif // CHROME_BROWSER_DESKTOP_NOTIFICATION_HANDLER_H_
-
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index dc26c1f..3c707b8 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -15,7 +15,6 @@
#include "chrome/browser/browser_window.h"
#include "chrome/browser/browsing_instance.h"
#include "chrome/browser/debugger/devtools_manager.h"
-#include "chrome/browser/desktop_notification_handler.h"
#include "chrome/browser/dom_ui/dom_ui_factory.h"
#include "chrome/browser/extensions/extension_message_service.h"
#include "chrome/browser/extensions/extension_tabs_module.h"
@@ -147,9 +146,6 @@ ExtensionHost::ExtensionHost(const Extension* extension,
// be the same extension that this points to.
registrar_.Add(this, NotificationType::EXTENSION_UNLOADED,
Source<Profile>(profile_));
-
- desktop_notification_handler_.reset(
- new DesktopNotificationHandler(NULL, render_process_host()));
}
ExtensionHost::~ExtensionHost() {
@@ -767,11 +763,6 @@ bool ExtensionHost::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
-
- if (!handled) {
- // Pass desktop notification IPCs to the DesktopNotificationHandler.
- handled = desktop_notification_handler_->OnMessageReceived(message);
- }
return handled;
}
diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h
index 3ace800..c9422ce 100644
--- a/chrome/browser/extensions/extension_host.h
+++ b/chrome/browser/extensions/extension_host.h
@@ -31,7 +31,6 @@ class RenderProcessHost;
class RenderWidgetHostView;
class TabContents;
struct WebPreferences;
-class DesktopNotificationHandler;
// This class is the browser component of an extension component's RenderView.
// It handles setting up the renderer process, if needed, with special
@@ -286,9 +285,6 @@ class ExtensionHost : public RenderViewHostDelegate,
// FileSelectHelper, lazily created.
scoped_ptr<FileSelectHelper> file_select_helper_;
- // Handles desktop notification IPCs.
- scoped_ptr<DesktopNotificationHandler> desktop_notification_handler_;
-
DISALLOW_COPY_AND_ASSIGN(ExtensionHost);
};
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()->
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index df00cb1..bb49437 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -46,6 +46,7 @@ struct ViewHostMsg_DidPrintPage_Params;
struct ViewHostMsg_DomMessage_Params;
struct ViewHostMsg_PageHasOSDD_Type;
struct ViewHostMsg_RunFileChooser_Params;
+struct ViewHostMsg_ShowNotification_Params;
struct ViewHostMsg_ShowPopup_Params;
struct ViewMsg_Navigate_Params;
struct WebApplicationInfo;
@@ -615,6 +616,10 @@ class RenderViewHost : public RenderWidgetHost {
void OnDevToolsRuntimePropertyChanged(const std::string& name,
const std::string& value);
void OnMsgShouldCloseACK(bool proceed);
+ void OnShowDesktopNotification(
+ const ViewHostMsg_ShowNotification_Params& params);
+ void OnCancelDesktopNotification(int notification_id);
+ void OnRequestNotificationPermission(const GURL& origin, int callback_id);
void OnExtensionRequest(const ViewHostMsg_DomMessage_Params& params);
void OnExtensionPostMessage(int port_id, const std::string& message);
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index a722215..2554daa 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -25,7 +25,6 @@
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/debugger/devtools_manager.h"
#include "chrome/browser/defaults.h"
-#include "chrome/browser/desktop_notification_handler.h"
#include "chrome/browser/dom_operation_notification_details.h"
#include "chrome/browser/dom_ui/dom_ui.h"
#include "chrome/browser/download/download_item_model.h"
@@ -596,9 +595,6 @@ TabContents::TabContents(Profile* profile,
AddNavigationObserver(prerender_plt_recorder_.get());
AddNavigationObserver(&fav_icon_helper_);
AddNavigationObserver(printing_.get());
- desktop_notification_handler_.reset(
- new DesktopNotificationHandler(this, GetRenderProcessHost()));
- AddNavigationObserver(desktop_notification_handler_.get());
}
TabContents::~TabContents() {
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index 880a390..b0af381 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -84,7 +84,6 @@ struct ViewHostMsg_DomMessage_Params;
struct ViewHostMsg_FrameNavigate_Params;
class WebNavigationObserver;
struct WebPreferences;
-class DesktopNotificationHandler;
// Describes what goes in the main content area of a tab. TabContents is
// the only type of TabContents, and these should be merged together.
@@ -1150,10 +1149,6 @@ class TabContents : public PageNavigator,
// RenderViewHost::ContentSettingsDelegate.
scoped_ptr<TabSpecificContentSettings> content_settings_delegate_;
- // Handles desktop notification IPCs.
- scoped_ptr<DesktopNotificationHandler> desktop_notification_handler_;
-
-
// Data for loading state ----------------------------------------------------
// Indicates whether we're currently loading a resource.
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 226ab60..6c76195 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -826,8 +826,6 @@
'browser/default_encoding_combo_model.h',
'browser/defaults.cc',
'browser/defaults.h',
- 'browser/desktop_notification_handler.cc',
- 'browser/desktop_notification_handler.h',
'browser/device_orientation/accelerometer_mac.cc',
'browser/device_orientation/accelerometer_mac.h',
'browser/device_orientation/data_fetcher.h',
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 0cc2db5..55e467a 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -2180,11 +2180,9 @@ IPC_MESSAGE_CONTROL1(ViewHostMsg_DocumentDetached,
// a desktop notification.
IPC_MESSAGE_ROUTED1(ViewHostMsg_ShowDesktopNotification,
ViewHostMsg_ShowNotification_Params)
-IPC_MESSAGE_ROUTED2(ViewHostMsg_CancelDesktopNotification,
- int /* routing_id */,
- int /* notification_id */)
-IPC_MESSAGE_ROUTED3(ViewHostMsg_RequestNotificationPermission,
- int /* routing_id */,
+IPC_MESSAGE_ROUTED1(ViewHostMsg_CancelDesktopNotification,
+ int /* notification_id */ )
+IPC_MESSAGE_ROUTED2(ViewHostMsg_RequestNotificationPermission,
GURL /* origin */,
int /* callback_context */)
IPC_SYNC_MESSAGE_ROUTED1_1(ViewHostMsg_CheckNotificationPermission,
diff --git a/chrome/common/render_messages_params.cc b/chrome/common/render_messages_params.cc
index 409776b..59a17bd 100644
--- a/chrome/common/render_messages_params.cc
+++ b/chrome/common/render_messages_params.cc
@@ -1311,7 +1311,6 @@ void ParamTraits<ViewHostMsg_ShowNotification_Params>::Write(
WriteParam(m, p.direction);
WriteParam(m, p.replace_id);
WriteParam(m, p.notification_id);
- WriteParam(m, p.routing_id);
}
bool ParamTraits<ViewHostMsg_ShowNotification_Params>::Read(
@@ -1327,8 +1326,7 @@ bool ParamTraits<ViewHostMsg_ShowNotification_Params>::Read(
ReadParam(m, iter, &p->body) &&
ReadParam(m, iter, &p->direction) &&
ReadParam(m, iter, &p->replace_id) &&
- ReadParam(m, iter, &p->notification_id) &&
- ReadParam(m, iter, &p->routing_id);
+ ReadParam(m, iter, &p->notification_id);
}
void ParamTraits<ViewHostMsg_ShowNotification_Params>::Log(
@@ -1352,8 +1350,6 @@ void ParamTraits<ViewHostMsg_ShowNotification_Params>::Log(
LogParam(p.replace_id, l);
l->append(",");
LogParam(p.notification_id, l);
- l->append(",");
- LogParam(p.routing_id, l);
l->append(")");
}
diff --git a/chrome/common/render_messages_params.h b/chrome/common/render_messages_params.h
index 88473c6c..ce4b18c 100644
--- a/chrome/common/render_messages_params.h
+++ b/chrome/common/render_messages_params.h
@@ -742,9 +742,6 @@ struct ViewHostMsg_ShowNotification_Params {
// Notification ID for sending events back for this notification.
int notification_id;
-
- // The routing id of the message.
- int routing_id;
};
// Creates a new view via a control message since the view doesn't yet exist.
diff --git a/chrome/renderer/notification_provider.cc b/chrome/renderer/notification_provider.cc
index 170db3a..8bdf244 100644
--- a/chrome/renderer/notification_provider.cc
+++ b/chrome/renderer/notification_provider.cc
@@ -46,8 +46,7 @@ void NotificationProvider::cancel(const WebNotification& notification) {
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(routing_id(), routing_id(),
- id));
+ Send(new ViewHostMsg_CancelDesktopNotification(routing_id(), id));
}
void NotificationProvider::objectDestroyed(
@@ -79,7 +78,6 @@ void NotificationProvider::requestPermission(
int id = manager_.RegisterPermissionRequest(callback);
Send(new ViewHostMsg_RequestNotificationPermission(routing_id(),
- routing_id(),
GURL(origin.toString()),
id));
}
@@ -121,7 +119,6 @@ bool NotificationProvider::ShowHTML(const WebNotification& notification,
params.contents_url = notification.url();
params.notification_id = id;
params.replace_id = notification.replaceId();
- params.routing_id = routing_id();
return Send(new ViewHostMsg_ShowDesktopNotification(routing_id(), params));
}
@@ -138,7 +135,7 @@ bool NotificationProvider::ShowText(const WebNotification& notification,
params.direction = notification.direction();
params.notification_id = id;
params.replace_id = notification.replaceId();
- params.routing_id = routing_id();
+
return Send(new ViewHostMsg_ShowDesktopNotification(routing_id(), params));
}