Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 104833006: Switch ContentSettingsObserver to be a RenderFrameObserver instead of a RenderViewObserver (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/web_contents/web_contents_impl.cc
===================================================================
--- content/browser/web_contents/web_contents_impl.cc (revision 240912)
+++ content/browser/web_contents/web_contents_impl.cc (working copy)
@@ -278,6 +278,19 @@
return true;
}
+bool ForEachFrameInternal(
+ const base::Callback<void(RenderFrameHost*)>& on_frame,
+ FrameTreeNode* node) {
+ on_frame.Run(node->render_frame_host());
+ return true;
+}
+
+void SendToAllFramesInternal(IPC::Message* message, RenderFrameHost* rfh) {
+ IPC::Message* message_copy = new IPC::Message(*message);
+ message_copy->set_routing_id(rfh->GetRoutingID());
+ rfh->Send(message_copy);
nasko 2013/12/16 19:47:37 Wouldn't this leak the message_copy? We allocate c
jam 2013/12/16 20:26:48 An IPC is owned by the Send call. the original IPC
+}
+
} // namespace
WebContents* WebContents::Create(const WebContents::CreateParams& params) {
@@ -320,6 +333,13 @@
return rvh->GetDelegate()->GetAsWebContents();
}
+WebContents* WebContents::FromRenderFrameHost(RenderFrameHost* rfh) {
nasko 2013/12/16 19:47:37 nit: Add // static prior to the method.
jam 2013/12/16 20:26:48 That's a personal preference that some people like
+ RenderFrameHostImpl* rfh_impl = static_cast<RenderFrameHostImpl*>(rfh);
+ if (!rfh_impl)
+ return NULL;
+ return rfh_impl->delegate()->GetAsWebContents();
+}
+
// WebContentsImpl::DestructionObserver ----------------------------------------
class WebContentsImpl::DestructionObserver : public WebContentsObserver {
@@ -633,6 +653,16 @@
return frame_tree_.root()->render_frame_host();
}
+void WebContentsImpl::ForEachFrame(
+ const base::Callback<void(RenderFrameHost*)>& on_frame) {
+ frame_tree_.ForEach(base::Bind(&ForEachFrameInternal, on_frame));
+}
+
+void WebContentsImpl::SendToAllFrames(IPC::Message* message) {
+ ForEachFrame(base::Bind(&SendToAllFramesInternal, message));
+ delete message;
nasko 2013/12/16 19:47:37 nit: It will be useful to document in the header t
jam 2013/12/16 20:26:48 that is the convention for all methods that send a
+}
+
RenderViewHost* WebContentsImpl::GetRenderViewHost() const {
return GetRenderManager()->current_host();
}
@@ -873,9 +903,9 @@
std::set<GURL> WebContentsImpl::GetSitesInTab() const {
std::set<GURL> sites;
- frame_tree_.ForEach(Bind(&CollectSites,
- base::Unretained(GetBrowserContext()),
- base::Unretained(&sites)));
+ frame_tree_.ForEach(base::Bind(&CollectSites,
+ base::Unretained(GetBrowserContext()),
+ base::Unretained(&sites)));
return sites;
}
@@ -1667,10 +1697,10 @@
reload_type);
}
-void WebContentsImpl::RenderViewForInterstitialPageCreated(
- RenderViewHost* render_view_host) {
+void WebContentsImpl::RenderFrameForInterstitialPageCreated(
+ RenderFrameHost* render_frame_host) {
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
- RenderViewForInterstitialPageCreated(render_view_host));
+ RenderFrameForInterstitialPageCreated(render_frame_host));
}
void WebContentsImpl::AttachInterstitialPage(
@@ -2778,6 +2808,10 @@
RenderFrameDeleted(render_frame_host));
}
+WebContents* WebContentsImpl::GetAsWebContents() {
+ return this;
+}
+
RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() {
return render_view_host_delegate_view_;
}
@@ -2792,10 +2826,6 @@
return renderer_preferences_;
}
-WebContents* WebContentsImpl::GetAsWebContents() {
- return this;
-}
-
gfx::Rect WebContentsImpl::GetRootWindowResizerRect() const {
if (delegate_)
return delegate_->GetRootWindowResizerRect();

Powered by Google App Engine
This is Rietveld 408576698