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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } 271 }
272 272
273 // Helper function for retrieving all the sites in a frame tree. 273 // Helper function for retrieving all the sites in a frame tree.
274 bool CollectSites(BrowserContext* context, 274 bool CollectSites(BrowserContext* context,
275 std::set<GURL>* sites, 275 std::set<GURL>* sites,
276 FrameTreeNode* node) { 276 FrameTreeNode* node) {
277 sites->insert(SiteInstance::GetSiteForURL(context, node->current_url())); 277 sites->insert(SiteInstance::GetSiteForURL(context, node->current_url()));
278 return true; 278 return true;
279 } 279 }
280 280
281 bool ForEachFrameInternal(
282 const base::Callback<void(RenderFrameHost*)>& on_frame,
283 FrameTreeNode* node) {
284 on_frame.Run(node->render_frame_host());
285 return true;
286 }
287
288 void SendToAllFramesInternal(IPC::Message* message, RenderFrameHost* rfh) {
289 IPC::Message* message_copy = new IPC::Message(*message);
290 message_copy->set_routing_id(rfh->GetRoutingID());
291 rfh->Send(message_copy);
292 }
293
281 } // namespace 294 } // namespace
282 295
283 WebContents* WebContents::Create(const WebContents::CreateParams& params) { 296 WebContents* WebContents::Create(const WebContents::CreateParams& params) {
284 return WebContentsImpl::CreateWithOpener( 297 return WebContentsImpl::CreateWithOpener(
285 params, static_cast<WebContentsImpl*>(params.opener)); 298 params, static_cast<WebContentsImpl*>(params.opener));
286 } 299 }
287 300
288 WebContents* WebContents::CreateWithSessionStorage( 301 WebContents* WebContents::CreateWithSessionStorage(
289 const WebContents::CreateParams& params, 302 const WebContents::CreateParams& params,
290 const SessionStorageNamespaceMap& session_storage_namespace_map) { 303 const SessionStorageNamespaceMap& session_storage_namespace_map) {
(...skipping 22 matching lines...) Expand all
313 g_created_callbacks.Get().erase(g_created_callbacks.Get().begin() + i); 326 g_created_callbacks.Get().erase(g_created_callbacks.Get().begin() + i);
314 return; 327 return;
315 } 328 }
316 } 329 }
317 } 330 }
318 331
319 WebContents* WebContents::FromRenderViewHost(const RenderViewHost* rvh) { 332 WebContents* WebContents::FromRenderViewHost(const RenderViewHost* rvh) {
320 return rvh->GetDelegate()->GetAsWebContents(); 333 return rvh->GetDelegate()->GetAsWebContents();
321 } 334 }
322 335
336 WebContents* WebContents::FromRenderFrameHost(RenderFrameHost* rfh) {
337 RenderFrameHostImpl* rfh_impl = static_cast<RenderFrameHostImpl*>(rfh);
338 if (!rfh_impl)
339 return NULL;
340 return rfh_impl->delegate()->GetAsWebContents();
341 }
342
323 // WebContentsImpl::DestructionObserver ---------------------------------------- 343 // WebContentsImpl::DestructionObserver ----------------------------------------
324 344
325 class WebContentsImpl::DestructionObserver : public WebContentsObserver { 345 class WebContentsImpl::DestructionObserver : public WebContentsObserver {
326 public: 346 public:
327 DestructionObserver(WebContentsImpl* owner, WebContents* watched_contents) 347 DestructionObserver(WebContentsImpl* owner, WebContents* watched_contents)
328 : WebContentsObserver(watched_contents), 348 : WebContentsObserver(watched_contents),
329 owner_(owner) { 349 owner_(owner) {
330 } 350 }
331 351
332 // WebContentsObserver: 352 // WebContentsObserver:
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 640
621 RenderProcessHost* WebContentsImpl::GetRenderProcessHost() const { 641 RenderProcessHost* WebContentsImpl::GetRenderProcessHost() const {
622 RenderViewHostImpl* host = GetRenderManager()->current_host(); 642 RenderViewHostImpl* host = GetRenderManager()->current_host();
623 return host ? host->GetProcess() : NULL; 643 return host ? host->GetProcess() : NULL;
624 } 644 }
625 645
626 RenderFrameHost* WebContentsImpl::GetMainFrame() { 646 RenderFrameHost* WebContentsImpl::GetMainFrame() {
627 return frame_tree_.root()->render_frame_host(); 647 return frame_tree_.root()->render_frame_host();
628 } 648 }
629 649
650 void WebContentsImpl::ForEachFrame(
651 const base::Callback<void(RenderFrameHost*)>& on_frame) {
652 frame_tree_.ForEach(base::Bind(&ForEachFrameInternal, on_frame));
653 }
654
655 void WebContentsImpl::SendToAllFrames(IPC::Message* message) {
656 ForEachFrame(base::Bind(&SendToAllFramesInternal, message));
657 delete message;
658 }
659
630 RenderViewHost* WebContentsImpl::GetRenderViewHost() const { 660 RenderViewHost* WebContentsImpl::GetRenderViewHost() const {
631 return GetRenderManager()->current_host(); 661 return GetRenderManager()->current_host();
632 } 662 }
633 663
634 void WebContentsImpl::GetRenderViewHostAtPosition( 664 void WebContentsImpl::GetRenderViewHostAtPosition(
635 int x, 665 int x,
636 int y, 666 int y,
637 const base::Callback<void(RenderViewHost*, int, int)>& callback) { 667 const base::Callback<void(RenderViewHost*, int, int)>& callback) {
638 BrowserPluginEmbedder* embedder = GetBrowserPluginEmbedder(); 668 BrowserPluginEmbedder* embedder = GetBrowserPluginEmbedder();
639 if (embedder) 669 if (embedder)
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 uint64 WebContentsImpl::GetUploadSize() const { 890 uint64 WebContentsImpl::GetUploadSize() const {
861 return upload_size_; 891 return upload_size_;
862 } 892 }
863 893
864 uint64 WebContentsImpl::GetUploadPosition() const { 894 uint64 WebContentsImpl::GetUploadPosition() const {
865 return upload_position_; 895 return upload_position_;
866 } 896 }
867 897
868 std::set<GURL> WebContentsImpl::GetSitesInTab() const { 898 std::set<GURL> WebContentsImpl::GetSitesInTab() const {
869 std::set<GURL> sites; 899 std::set<GURL> sites;
870 frame_tree_.ForEach(Bind(&CollectSites, 900 frame_tree_.ForEach(base::Bind(&CollectSites,
871 base::Unretained(GetBrowserContext()), 901 base::Unretained(GetBrowserContext()),
872 base::Unretained(&sites))); 902 base::Unretained(&sites)));
873 return sites; 903 return sites;
874 } 904 }
875 905
876 const std::string& WebContentsImpl::GetEncoding() const { 906 const std::string& WebContentsImpl::GetEncoding() const {
877 return encoding_; 907 return encoding_;
878 } 908 }
879 909
880 bool WebContentsImpl::DisplayedInsecureContent() const { 910 bool WebContentsImpl::DisplayedInsecureContent() const {
881 return displayed_insecure_content_; 911 return displayed_insecure_content_;
882 } 912 }
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 return GetRenderViewHost()->Send(message); 1664 return GetRenderViewHost()->Send(message);
1635 } 1665 }
1636 1666
1637 bool WebContentsImpl::NavigateToPendingEntry( 1667 bool WebContentsImpl::NavigateToPendingEntry(
1638 NavigationController::ReloadType reload_type) { 1668 NavigationController::ReloadType reload_type) {
1639 return NavigateToEntry( 1669 return NavigateToEntry(
1640 *NavigationEntryImpl::FromNavigationEntry(controller_.GetPendingEntry()), 1670 *NavigationEntryImpl::FromNavigationEntry(controller_.GetPendingEntry()),
1641 reload_type); 1671 reload_type);
1642 } 1672 }
1643 1673
1644 void WebContentsImpl::RenderViewForInterstitialPageCreated( 1674 void WebContentsImpl::RenderFrameForInterstitialPageCreated(
1645 RenderViewHost* render_view_host) { 1675 RenderFrameHost* render_frame_host) {
1646 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 1676 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
1647 RenderViewForInterstitialPageCreated(render_view_host)); 1677 RenderFrameForInterstitialPageCreated(render_frame_host));
1648 } 1678 }
1649 1679
1650 void WebContentsImpl::AttachInterstitialPage( 1680 void WebContentsImpl::AttachInterstitialPage(
1651 InterstitialPageImpl* interstitial_page) { 1681 InterstitialPageImpl* interstitial_page) {
1652 DCHECK(interstitial_page); 1682 DCHECK(interstitial_page);
1653 GetRenderManager()->set_interstitial_page(interstitial_page); 1683 GetRenderManager()->set_interstitial_page(interstitial_page);
1654 1684
1655 // Cancel any visible dialogs so that they don't interfere with the 1685 // Cancel any visible dialogs so that they don't interfere with the
1656 // interstitial. 1686 // interstitial.
1657 if (dialog_manager_) 1687 if (dialog_manager_)
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
2745 observers_, 2775 observers_,
2746 RenderFrameCreated(render_frame_host)); 2776 RenderFrameCreated(render_frame_host));
2747 } 2777 }
2748 2778
2749 void WebContentsImpl::RenderFrameDeleted(RenderFrameHost* render_frame_host) { 2779 void WebContentsImpl::RenderFrameDeleted(RenderFrameHost* render_frame_host) {
2750 FOR_EACH_OBSERVER(WebContentsObserver, 2780 FOR_EACH_OBSERVER(WebContentsObserver,
2751 observers_, 2781 observers_,
2752 RenderFrameDeleted(render_frame_host)); 2782 RenderFrameDeleted(render_frame_host));
2753 } 2783 }
2754 2784
2785 WebContents* WebContentsImpl::GetAsWebContents() {
2786 return this;
2787 }
2788
2755 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() { 2789 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() {
2756 return render_view_host_delegate_view_; 2790 return render_view_host_delegate_view_;
2757 } 2791 }
2758 2792
2759 RenderViewHostDelegate::RendererManagement* 2793 RenderViewHostDelegate::RendererManagement*
2760 WebContentsImpl::GetRendererManagementDelegate() { 2794 WebContentsImpl::GetRendererManagementDelegate() {
2761 return GetRenderManager(); 2795 return GetRenderManager();
2762 } 2796 }
2763 2797
2764 RendererPreferences WebContentsImpl::GetRendererPrefs( 2798 RendererPreferences WebContentsImpl::GetRendererPrefs(
2765 BrowserContext* browser_context) const { 2799 BrowserContext* browser_context) const {
2766 return renderer_preferences_; 2800 return renderer_preferences_;
2767 } 2801 }
2768 2802
2769 WebContents* WebContentsImpl::GetAsWebContents() {
2770 return this;
2771 }
2772
2773 gfx::Rect WebContentsImpl::GetRootWindowResizerRect() const { 2803 gfx::Rect WebContentsImpl::GetRootWindowResizerRect() const {
2774 if (delegate_) 2804 if (delegate_)
2775 return delegate_->GetRootWindowResizerRect(); 2805 return delegate_->GetRootWindowResizerRect();
2776 return gfx::Rect(); 2806 return gfx::Rect();
2777 } 2807 }
2778 2808
2779 void WebContentsImpl::RemoveBrowserPluginEmbedder() { 2809 void WebContentsImpl::RemoveBrowserPluginEmbedder() {
2780 if (browser_plugin_embedder_) 2810 if (browser_plugin_embedder_)
2781 browser_plugin_embedder_.reset(); 2811 browser_plugin_embedder_.reset();
2782 } 2812 }
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
3759 } 3789 }
3760 3790
3761 void WebContentsImpl::OnFrameRemoved( 3791 void WebContentsImpl::OnFrameRemoved(
3762 RenderViewHostImpl* render_view_host, 3792 RenderViewHostImpl* render_view_host,
3763 int64 frame_id) { 3793 int64 frame_id) {
3764 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3794 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3765 FrameDetached(render_view_host, frame_id)); 3795 FrameDetached(render_view_host, frame_id));
3766 } 3796 }
3767 3797
3768 } // namespace content 3798 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698