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

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: sync 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
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/content_shell.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } 272 }
273 273
274 // Helper function for retrieving all the sites in a frame tree. 274 // Helper function for retrieving all the sites in a frame tree.
275 bool CollectSites(BrowserContext* context, 275 bool CollectSites(BrowserContext* context,
276 std::set<GURL>* sites, 276 std::set<GURL>* sites,
277 FrameTreeNode* node) { 277 FrameTreeNode* node) {
278 sites->insert(SiteInstance::GetSiteForURL(context, node->current_url())); 278 sites->insert(SiteInstance::GetSiteForURL(context, node->current_url()));
279 return true; 279 return true;
280 } 280 }
281 281
282 bool ForEachFrameInternal(
283 const base::Callback<void(RenderFrameHost*)>& on_frame,
284 FrameTreeNode* node) {
285 on_frame.Run(node->render_frame_host());
286 return true;
287 }
288
289 void SendToAllFramesInternal(IPC::Message* message, RenderFrameHost* rfh) {
290 IPC::Message* message_copy = new IPC::Message(*message);
291 message_copy->set_routing_id(rfh->GetRoutingID());
292 rfh->Send(message_copy);
293 }
294
282 } // namespace 295 } // namespace
283 296
284 WebContents* WebContents::Create(const WebContents::CreateParams& params) { 297 WebContents* WebContents::Create(const WebContents::CreateParams& params) {
285 return WebContentsImpl::CreateWithOpener( 298 return WebContentsImpl::CreateWithOpener(
286 params, static_cast<WebContentsImpl*>(params.opener)); 299 params, static_cast<WebContentsImpl*>(params.opener));
287 } 300 }
288 301
289 WebContents* WebContents::CreateWithSessionStorage( 302 WebContents* WebContents::CreateWithSessionStorage(
290 const WebContents::CreateParams& params, 303 const WebContents::CreateParams& params,
291 const SessionStorageNamespaceMap& session_storage_namespace_map) { 304 const SessionStorageNamespaceMap& session_storage_namespace_map) {
(...skipping 22 matching lines...) Expand all
314 g_created_callbacks.Get().erase(g_created_callbacks.Get().begin() + i); 327 g_created_callbacks.Get().erase(g_created_callbacks.Get().begin() + i);
315 return; 328 return;
316 } 329 }
317 } 330 }
318 } 331 }
319 332
320 WebContents* WebContents::FromRenderViewHost(const RenderViewHost* rvh) { 333 WebContents* WebContents::FromRenderViewHost(const RenderViewHost* rvh) {
321 return rvh->GetDelegate()->GetAsWebContents(); 334 return rvh->GetDelegate()->GetAsWebContents();
322 } 335 }
323 336
337 WebContents* WebContents::FromRenderFrameHost(RenderFrameHost* rfh) {
338 RenderFrameHostImpl* rfh_impl = static_cast<RenderFrameHostImpl*>(rfh);
339 if (!rfh_impl)
340 return NULL;
341 return rfh_impl->delegate()->GetAsWebContents();
342 }
343
324 // WebContentsImpl::DestructionObserver ---------------------------------------- 344 // WebContentsImpl::DestructionObserver ----------------------------------------
325 345
326 class WebContentsImpl::DestructionObserver : public WebContentsObserver { 346 class WebContentsImpl::DestructionObserver : public WebContentsObserver {
327 public: 347 public:
328 DestructionObserver(WebContentsImpl* owner, WebContents* watched_contents) 348 DestructionObserver(WebContentsImpl* owner, WebContents* watched_contents)
329 : WebContentsObserver(watched_contents), 349 : WebContentsObserver(watched_contents),
330 owner_(owner) { 350 owner_(owner) {
331 } 351 }
332 352
333 // WebContentsObserver: 353 // WebContentsObserver:
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 647
628 RenderProcessHost* WebContentsImpl::GetRenderProcessHost() const { 648 RenderProcessHost* WebContentsImpl::GetRenderProcessHost() const {
629 RenderViewHostImpl* host = GetRenderManager()->current_host(); 649 RenderViewHostImpl* host = GetRenderManager()->current_host();
630 return host ? host->GetProcess() : NULL; 650 return host ? host->GetProcess() : NULL;
631 } 651 }
632 652
633 RenderFrameHost* WebContentsImpl::GetMainFrame() { 653 RenderFrameHost* WebContentsImpl::GetMainFrame() {
634 return frame_tree_.root()->render_frame_host(); 654 return frame_tree_.root()->render_frame_host();
635 } 655 }
636 656
657 void WebContentsImpl::ForEachFrame(
658 const base::Callback<void(RenderFrameHost*)>& on_frame) {
659 frame_tree_.ForEach(base::Bind(&ForEachFrameInternal, on_frame));
660 }
661
662 void WebContentsImpl::SendToAllFrames(IPC::Message* message) {
663 ForEachFrame(base::Bind(&SendToAllFramesInternal, message));
664 delete message;
665 }
666
637 RenderViewHost* WebContentsImpl::GetRenderViewHost() const { 667 RenderViewHost* WebContentsImpl::GetRenderViewHost() const {
638 return GetRenderManager()->current_host(); 668 return GetRenderManager()->current_host();
639 } 669 }
640 670
641 void WebContentsImpl::GetRenderViewHostAtPosition( 671 void WebContentsImpl::GetRenderViewHostAtPosition(
642 int x, 672 int x,
643 int y, 673 int y,
644 const base::Callback<void(RenderViewHost*, int, int)>& callback) { 674 const base::Callback<void(RenderViewHost*, int, int)>& callback) {
645 BrowserPluginEmbedder* embedder = GetBrowserPluginEmbedder(); 675 BrowserPluginEmbedder* embedder = GetBrowserPluginEmbedder();
646 if (embedder) 676 if (embedder)
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 uint64 WebContentsImpl::GetUploadSize() const { 897 uint64 WebContentsImpl::GetUploadSize() const {
868 return upload_size_; 898 return upload_size_;
869 } 899 }
870 900
871 uint64 WebContentsImpl::GetUploadPosition() const { 901 uint64 WebContentsImpl::GetUploadPosition() const {
872 return upload_position_; 902 return upload_position_;
873 } 903 }
874 904
875 std::set<GURL> WebContentsImpl::GetSitesInTab() const { 905 std::set<GURL> WebContentsImpl::GetSitesInTab() const {
876 std::set<GURL> sites; 906 std::set<GURL> sites;
877 frame_tree_.ForEach(Bind(&CollectSites, 907 frame_tree_.ForEach(base::Bind(&CollectSites,
878 base::Unretained(GetBrowserContext()), 908 base::Unretained(GetBrowserContext()),
879 base::Unretained(&sites))); 909 base::Unretained(&sites)));
880 return sites; 910 return sites;
881 } 911 }
882 912
883 const std::string& WebContentsImpl::GetEncoding() const { 913 const std::string& WebContentsImpl::GetEncoding() const {
884 return encoding_; 914 return encoding_;
885 } 915 }
886 916
887 bool WebContentsImpl::DisplayedInsecureContent() const { 917 bool WebContentsImpl::DisplayedInsecureContent() const {
888 return displayed_insecure_content_; 918 return displayed_insecure_content_;
889 } 919 }
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 return GetRenderViewHost()->Send(message); 1691 return GetRenderViewHost()->Send(message);
1662 } 1692 }
1663 1693
1664 bool WebContentsImpl::NavigateToPendingEntry( 1694 bool WebContentsImpl::NavigateToPendingEntry(
1665 NavigationController::ReloadType reload_type) { 1695 NavigationController::ReloadType reload_type) {
1666 return NavigateToEntry( 1696 return NavigateToEntry(
1667 *NavigationEntryImpl::FromNavigationEntry(controller_.GetPendingEntry()), 1697 *NavigationEntryImpl::FromNavigationEntry(controller_.GetPendingEntry()),
1668 reload_type); 1698 reload_type);
1669 } 1699 }
1670 1700
1671 void WebContentsImpl::RenderViewForInterstitialPageCreated( 1701 void WebContentsImpl::RenderFrameForInterstitialPageCreated(
1672 RenderViewHost* render_view_host) { 1702 RenderFrameHost* render_frame_host) {
1673 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 1703 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
1674 RenderViewForInterstitialPageCreated(render_view_host)); 1704 RenderFrameForInterstitialPageCreated(render_frame_host));
1675 } 1705 }
1676 1706
1677 void WebContentsImpl::AttachInterstitialPage( 1707 void WebContentsImpl::AttachInterstitialPage(
1678 InterstitialPageImpl* interstitial_page) { 1708 InterstitialPageImpl* interstitial_page) {
1679 DCHECK(interstitial_page); 1709 DCHECK(interstitial_page);
1680 GetRenderManager()->set_interstitial_page(interstitial_page); 1710 GetRenderManager()->set_interstitial_page(interstitial_page);
1681 1711
1682 // Cancel any visible dialogs so that they don't interfere with the 1712 // Cancel any visible dialogs so that they don't interfere with the
1683 // interstitial. 1713 // interstitial.
1684 if (dialog_manager_) 1714 if (dialog_manager_)
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
2772 observers_, 2802 observers_,
2773 RenderFrameCreated(render_frame_host)); 2803 RenderFrameCreated(render_frame_host));
2774 } 2804 }
2775 2805
2776 void WebContentsImpl::RenderFrameDeleted(RenderFrameHost* render_frame_host) { 2806 void WebContentsImpl::RenderFrameDeleted(RenderFrameHost* render_frame_host) {
2777 FOR_EACH_OBSERVER(WebContentsObserver, 2807 FOR_EACH_OBSERVER(WebContentsObserver,
2778 observers_, 2808 observers_,
2779 RenderFrameDeleted(render_frame_host)); 2809 RenderFrameDeleted(render_frame_host));
2780 } 2810 }
2781 2811
2812 WebContents* WebContentsImpl::GetAsWebContents() {
2813 return this;
2814 }
2815
2782 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() { 2816 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() {
2783 return render_view_host_delegate_view_; 2817 return render_view_host_delegate_view_;
2784 } 2818 }
2785 2819
2786 RenderViewHostDelegate::RendererManagement* 2820 RenderViewHostDelegate::RendererManagement*
2787 WebContentsImpl::GetRendererManagementDelegate() { 2821 WebContentsImpl::GetRendererManagementDelegate() {
2788 return GetRenderManager(); 2822 return GetRenderManager();
2789 } 2823 }
2790 2824
2791 RendererPreferences WebContentsImpl::GetRendererPrefs( 2825 RendererPreferences WebContentsImpl::GetRendererPrefs(
2792 BrowserContext* browser_context) const { 2826 BrowserContext* browser_context) const {
2793 return renderer_preferences_; 2827 return renderer_preferences_;
2794 } 2828 }
2795 2829
2796 WebContents* WebContentsImpl::GetAsWebContents() {
2797 return this;
2798 }
2799
2800 gfx::Rect WebContentsImpl::GetRootWindowResizerRect() const { 2830 gfx::Rect WebContentsImpl::GetRootWindowResizerRect() const {
2801 if (delegate_) 2831 if (delegate_)
2802 return delegate_->GetRootWindowResizerRect(); 2832 return delegate_->GetRootWindowResizerRect();
2803 return gfx::Rect(); 2833 return gfx::Rect();
2804 } 2834 }
2805 2835
2806 void WebContentsImpl::RemoveBrowserPluginEmbedder() { 2836 void WebContentsImpl::RemoveBrowserPluginEmbedder() {
2807 if (browser_plugin_embedder_) 2837 if (browser_plugin_embedder_)
2808 browser_plugin_embedder_.reset(); 2838 browser_plugin_embedder_.reset();
2809 } 2839 }
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
3786 } 3816 }
3787 3817
3788 void WebContentsImpl::OnFrameRemoved( 3818 void WebContentsImpl::OnFrameRemoved(
3789 RenderViewHostImpl* render_view_host, 3819 RenderViewHostImpl* render_view_host,
3790 int64 frame_id) { 3820 int64 frame_id) {
3791 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3821 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3792 FrameDetached(render_view_host, frame_id)); 3822 FrameDetached(render_view_host, frame_id));
3793 } 3823 }
3794 3824
3795 } // namespace content 3825 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/content_shell.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698