diff options
| author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-08 17:38:14 +0000 |
|---|---|---|
| committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-08 17:38:14 +0000 |
| commit | ff1e913c6d63f3b5b12b4d0cb0b960bcb2e682af (patch) | |
| tree | d92f1e8949d181069e0defe685d8e4b65c42619e /content | |
| parent | afc4ce91f94bc0cb976884e1c1c785a9e75f127a (diff) | |
| download | chromium_src-ff1e913c6d63f3b5b12b4d0cb0b960bcb2e682af.zip chromium_src-ff1e913c6d63f3b5b12b4d0cb0b960bcb2e682af.tar.gz chromium_src-ff1e913c6d63f3b5b12b4d0cb0b960bcb2e682af.tar.bz2 | |
Revert 80938 - Add a new RenderViewHostObserver interface for filtering IPCs send to RenderViewHost. This is needed because with TabContentsObserver, an observer might not know which RenderViewHost a message came from duing a pending navigation. A side-benefit is that we only have to add these observers once, instead of remembering/knowing all the delegates that might want to filter these messages.BUG=78629Review URL: http://codereview.chromium.org/6812030
TBR=jam@chromium.org
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80956 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
| -rw-r--r-- | content/browser/content_browser_client.cc | 9 | ||||
| -rw-r--r-- | content/browser/content_browser_client.h | 5 | ||||
| -rw-r--r-- | content/browser/renderer_host/render_view_host.cc | 21 | ||||
| -rw-r--r-- | content/browser/renderer_host/render_view_host.h | 12 | ||||
| -rw-r--r-- | content/browser/renderer_host/render_view_host_delegate.cc | 5 | ||||
| -rw-r--r-- | content/browser/renderer_host/render_view_host_delegate.h | 6 | ||||
| -rw-r--r-- | content/browser/renderer_host/render_view_host_observer.cc | 41 | ||||
| -rw-r--r-- | content/browser/renderer_host/render_view_host_observer.h | 51 | ||||
| -rw-r--r-- | content/browser/tab_contents/tab_contents.cc | 13 | ||||
| -rw-r--r-- | content/browser/tab_contents/tab_contents.h | 6 | ||||
| -rw-r--r-- | content/content_browser.gypi | 2 |
11 files changed, 8 insertions, 163 deletions
diff --git a/content/browser/content_browser_client.cc b/content/browser/content_browser_client.cc index 57392a1..5b763c2b 100644 --- a/content/browser/content_browser_client.cc +++ b/content/browser/content_browser_client.cc @@ -10,15 +10,6 @@ namespace content { -void ContentBrowserClient::RenderViewHostCreated( - RenderViewHost* render_view_host) { -} - -void ContentBrowserClient::PreCreateRenderView(RenderViewHost* render_view_host, - Profile* profile, - const GURL& url) { -} - WebUIFactory* ContentBrowserClient::GetWebUIFactory() { // Return an empty factory so callsites don't have to check for NULL. return EmptyWebUIFactory::Get(); diff --git a/content/browser/content_browser_client.h b/content/browser/content_browser_client.h index 1f3c7ca..e8350e6 100644 --- a/content/browser/content_browser_client.h +++ b/content/browser/content_browser_client.h @@ -19,13 +19,10 @@ class WebUIFactory; // Embedder API for participating in browser logic. class ContentBrowserClient { public: - // Notifies that a new RenderHostView has been created. - virtual void RenderViewHostCreated(RenderViewHost* render_view_host); - // Initialize a RenderViewHost before its CreateRenderView method is called. virtual void PreCreateRenderView(RenderViewHost* render_view_host, Profile* profile, - const GURL& url); + const GURL& url) {} // Gets the WebUIFactory which will be responsible for generating WebUIs. virtual WebUIFactory* GetWebUIFactory(); diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc index 17c5338..3e6ef59 100644 --- a/content/browser/renderer_host/render_view_host.cc +++ b/content/browser/renderer_host/render_view_host.cc @@ -30,12 +30,10 @@ #include "chrome/common/translate_errors.h" #include "chrome/common/url_constants.h" #include "content/browser/child_process_security_policy.h" -#include "content/browser/content_browser_client.h" #include "content/browser/cross_site_request_manager.h" #include "content/browser/in_process_webkit/session_storage_namespace.h" #include "content/browser/renderer_host/render_process_host.h" #include "content/browser/renderer_host/render_view_host_delegate.h" -#include "content/browser/renderer_host/render_view_host_observer.h" #include "content/browser/renderer_host/render_widget_host.h" #include "content/browser/renderer_host/render_widget_host_view.h" #include "content/browser/site_instance.h" @@ -117,14 +115,9 @@ RenderViewHost::RenderViewHost(SiteInstance* instance, DCHECK(instance_); DCHECK(delegate_); - - content::GetContentClient()->browser()->RenderViewHostCreated(this); } RenderViewHost::~RenderViewHost() { - FOR_EACH_OBSERVER( - RenderViewHostObserver, observers_, RenderViewHostDestruction()); - NotificationService::current()->Notify( NotificationType::RENDER_VIEW_HOST_DELETED, Source<RenderViewHost>(this), @@ -719,12 +712,6 @@ bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) { } #endif - ObserverListBase<RenderViewHostObserver>::Iterator it(observers_); - RenderViewHostObserver* observer; - while ((observer = it.GetNext()) != NULL) - if (observer->OnMessageReceived(msg)) - return true; - if (delegate_->OnMessageReceived(msg)) return true; @@ -1238,14 +1225,6 @@ void RenderViewHost::OnAddMessageToConsole(const std::wstring& message, << "\", source: " << source_id << " (" << line_no << ")"; } -void RenderViewHost::AddObserver(RenderViewHostObserver* observer) { - observers_.AddObserver(observer); -} - -void RenderViewHost::RemoveObserver(RenderViewHostObserver* observer) { - observers_.RemoveObserver(observer); -} - bool RenderViewHost::PreHandleKeyboardEvent( const NativeWebKeyboardEvent& event, bool* is_keyboard_shortcut) { RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); diff --git a/content/browser/renderer_host/render_view_host.h b/content/browser/renderer_host/render_view_host.h index 88dac2a..0304ec9 100644 --- a/content/browser/renderer_host/render_view_host.h +++ b/content/browser/renderer_host/render_view_host.h @@ -10,7 +10,6 @@ #include <vector> #include "base/memory/scoped_ptr.h" -#include "base/observer_list.h" #include "base/process_util.h" #include "chrome/browser/ui/find_bar/find_bar_controller.h" #include "chrome/common/content_settings_types.h" @@ -33,7 +32,6 @@ class FilePath; class GURL; class ListValue; class RenderViewHostDelegate; -class RenderViewHostObserver; class SessionStorageNamespace; class SiteInstance; class SkBitmap; @@ -501,13 +499,6 @@ class RenderViewHost : public RenderWidgetHost { GURL* url); protected: - friend class RenderViewHostObserver; - - // Add and remove observers for filtering IPC messages. Clients must be sure - // to remove the observer before they go away. - void AddObserver(RenderViewHostObserver* observer); - void RemoveObserver(RenderViewHostObserver* observer); - // RenderWidgetHost protected overrides. virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, bool* is_keyboard_shortcut); @@ -691,9 +682,6 @@ class RenderViewHost : public RenderWidgetHost { // The enabled/disabled states of various commands. std::map<RenderViewCommand, CommandState> command_states_; - // A list of observers that filter messages. Weak references. - ObserverList<RenderViewHostObserver> observers_; - DISALLOW_COPY_AND_ASSIGN(RenderViewHost); }; diff --git a/content/browser/renderer_host/render_view_host_delegate.cc b/content/browser/renderer_host/render_view_host_delegate.cc index bd1f5bd..2d56531 100644 --- a/content/browser/renderer_host/render_view_host_delegate.cc +++ b/content/browser/renderer_host/render_view_host_delegate.cc @@ -71,8 +71,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 f4f0783..3fcc384 100644 --- a/content/browser/renderer_host/render_view_host_delegate.h +++ b/content/browser/renderer_host/render_view_host_delegate.h @@ -567,12 +567,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() {} }; diff --git a/content/browser/renderer_host/render_view_host_observer.cc b/content/browser/renderer_host/render_view_host_observer.cc deleted file mode 100644 index e60e2bb..0000000 --- a/content/browser/renderer_host/render_view_host_observer.cc +++ /dev/null @@ -1,41 +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 "content/browser/renderer_host/render_view_host_observer.h" - -#include "content/browser/renderer_host/render_view_host.h" - -RenderViewHostObserver::RenderViewHostObserver(RenderViewHost* render_view_host) - : render_view_host_(render_view_host), - routing_id_(render_view_host->routing_id()) { - render_view_host_->AddObserver(this); -} - -RenderViewHostObserver::~RenderViewHostObserver() { - if (render_view_host_) - render_view_host_->RemoveObserver(this); -} - -void RenderViewHostObserver::RenderViewHostDestroyed() { - delete this; -} - -bool RenderViewHostObserver::OnMessageReceived(const IPC::Message& message) { - return false; -} - -bool RenderViewHostObserver::Send(IPC::Message* message) { - if (!render_view_host_) { - delete message; - return false; - } - - return render_view_host_->Send(message); -} - -void RenderViewHostObserver::RenderViewHostDestruction() { - render_view_host_->RemoveObserver(this); - RenderViewHostDestroyed(); - render_view_host_ = NULL; -} diff --git a/content/browser/renderer_host/render_view_host_observer.h b/content/browser/renderer_host/render_view_host_observer.h deleted file mode 100644 index 2f63935..0000000 --- a/content/browser/renderer_host/render_view_host_observer.h +++ /dev/null @@ -1,51 +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 CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_OBSERVER_H_ -#define CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_OBSERVER_H_ - -#include "ipc/ipc_channel.h" - -class RenderViewHost; - -// An observer API implemented by classes which want to filter IPC messages from -// RenderViewHost. -class RenderViewHostObserver : public IPC::Channel::Listener, - public IPC::Message::Sender { - public: - - protected: - explicit RenderViewHostObserver(RenderViewHost* render_view_host); - - virtual ~RenderViewHostObserver(); - - // Invoked when the RenderViewHost is being destroyed. Gives subclasses a - // chance to cleanup. The base implementation will delete the object. - virtual void RenderViewHostDestroyed(); - - // IPC::Channel::Listener implementation. - virtual bool OnMessageReceived(const IPC::Message& message); - - // IPC::Message::Sender implementation. - virtual bool Send(IPC::Message* message); - - RenderViewHost* render_view_host() const { return render_view_host_; } - int routing_id() { return routing_id_; } - - private: - friend class RenderViewHost; - - // Invoked from RenderViewHost. Invokes RenderViewHostDestroyed and NULL out - // |render_view_host_|. - void RenderViewHostDestruction(); - - RenderViewHost* render_view_host_; - - // The routing ID of the associated RenderViewHost. - int routing_id_; - - DISALLOW_COPY_AND_ASSIGN(RenderViewHostObserver); -}; - -#endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_OBSERVER_H_ diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 1842c02..ebee41c 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -22,6 +22,7 @@ #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/download/download_item_model.h" #include "chrome/browser/download/download_manager.h" @@ -35,7 +36,6 @@ #include "chrome/browser/load_notification_details.h" #include "chrome/browser/metrics/metric_event_duration_details.h" #include "chrome/browser/metrics/user_metrics.h" -#include "chrome/browser/notifications/desktop_notification_service.h" #include "chrome/browser/omnibox_search_hint.h" #include "chrome/browser/pdf_unsupported_feature.h" #include "chrome/browser/platform_util.h" @@ -372,6 +372,8 @@ TabContents::~TabContents() { void TabContents::AddObservers() { favicon_helper_.reset(new FaviconHelper(this)); + desktop_notification_handler_.reset( + new DesktopNotificationHandlerForTC(this, GetRenderProcessHost())); plugin_observer_.reset(new PluginObserver(this)); safebrowsing_detection_host_.reset(new safe_browsing::ClientSideDetectionHost( this)); @@ -2424,15 +2426,6 @@ void TabContents::WorkerCrashed() { delegate()->WorkerCrashed(); } -void TabContents::RequestDesktopNotificationPermission( - const GURL& source_origin, int callback_context) { - DesktopNotificationService* service = - profile()->GetDesktopNotificationService(); - service->RequestPermission( - source_origin, GetRenderProcessHost()->id(), - render_view_host()->routing_id(), callback_context, this); -} - void TabContents::BeforeUnloadFiredFromRenderManager( bool proceed, bool* proceed_to_fire_unload) { diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index e55f49d..b458293 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -60,6 +60,7 @@ class ClientSideDetectionHost; class BlockedContentContainer; class WebUI; +class DesktopNotificationHandlerForTC; class DownloadItem; class Extension; class InfoBarDelegate; @@ -893,8 +894,6 @@ class TabContents : public PageNavigator, int maximum_percent, bool remember); virtual void WorkerCrashed(); - virtual void RequestDesktopNotificationPermission(const GURL& source_origin, - int callback_context); // RenderViewHostManager::Delegate ------------------------------------------- @@ -981,6 +980,9 @@ class TabContents : public PageNavigator, // RenderViewHost::ContentSettingsDelegate. scoped_ptr<TabSpecificContentSettings> content_settings_delegate_; + // Handles desktop notification IPCs. + scoped_ptr<DesktopNotificationHandlerForTC> desktop_notification_handler_; + // Handles IPCs related to SafeBrowsing client-side phishing detection. scoped_ptr<safe_browsing::ClientSideDetectionHost> safebrowsing_detection_host_; diff --git a/content/content_browser.gypi b/content/content_browser.gypi index f1df8aa..de3cf83 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -234,8 +234,6 @@ 'browser/renderer_host/render_view_host_factory.cc', 'browser/renderer_host/render_view_host_factory.h', 'browser/renderer_host/render_view_host_notification_task.h', - 'browser/renderer_host/render_view_host_observer.cc', - 'browser/renderer_host/render_view_host_observer.h', 'browser/renderer_host/render_widget_fullscreen_host.cc', 'browser/renderer_host/render_widget_fullscreen_host.h', 'browser/renderer_host/render_widget_helper.cc', |
