diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 19:41:22 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 19:41:22 +0000 |
commit | 9f1f1fcf77bf3e1a3073f35706efe8b739c0d5ae (patch) | |
tree | 0aa95d7bd1fba2c5e04ed5ff7a5b00de6072ae4f /chrome/browser/desktop_notification_handler.h | |
parent | ea12f6dda9e9e5b478200638089fe1513e37cd98 (diff) | |
download | chromium_src-9f1f1fcf77bf3e1a3073f35706efe8b739c0d5ae.zip chromium_src-9f1f1fcf77bf3e1a3073f35706efe8b739c0d5ae.tar.gz chromium_src-9f1f1fcf77bf3e1a3073f35706efe8b739c0d5ae.tar.bz2 |
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
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72861 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/desktop_notification_handler.h')
-rw-r--r-- | chrome/browser/desktop_notification_handler.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/chrome/browser/desktop_notification_handler.h b/chrome/browser/desktop_notification_handler.h new file mode 100644 index 0000000..7fce602 --- /dev/null +++ b/chrome/browser/desktop_notification_handler.h @@ -0,0 +1,43 @@ +// 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_ + |