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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 30323002: [DRAFT] Create RenderFrameHostManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 1 month 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); 214 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry);
215 params->current_history_list_offset = 215 params->current_history_list_offset =
216 controller.GetLastCommittedEntryIndex(); 216 controller.GetLastCommittedEntryIndex();
217 params->current_history_list_length = controller.GetEntryCount(); 217 params->current_history_list_length = controller.GetEntryCount();
218 } 218 }
219 params->url = entry.GetURL(); 219 params->url = entry.GetURL();
220 if (!entry.GetBaseURLForDataURL().is_empty()) { 220 if (!entry.GetBaseURLForDataURL().is_empty()) {
221 params->base_url_for_data_url = entry.GetBaseURLForDataURL(); 221 params->base_url_for_data_url = entry.GetBaseURLForDataURL();
222 params->history_url_for_data_url = entry.GetVirtualURL(); 222 params->history_url_for_data_url = entry.GetVirtualURL();
223 } 223 }
224
225 // TODO(creis): Store the renderer-specific frame ID on params. We'll
226 // eventually use the RenderFrameHost routing ID, but for now we may need to
227 // search the RenderViewHost's frame_id_map.
228 //int64 frame_id = -1;
229 //params->frame_id = frame_id;
230
224 params->referrer = entry.GetReferrer(); 231 params->referrer = entry.GetReferrer();
225 params->transition = entry.GetTransitionType(); 232 params->transition = entry.GetTransitionType();
226 params->page_state = entry.GetPageState(); 233 params->page_state = entry.GetPageState();
227 params->navigation_type = 234 params->navigation_type =
228 GetNavigationType(controller.GetBrowserContext(), entry, reload_type); 235 GetNavigationType(controller.GetBrowserContext(), entry, reload_type);
229 params->request_time = base::Time::Now(); 236 params->request_time = base::Time::Now();
230 params->extra_headers = entry.extra_headers(); 237 params->extra_headers = entry.extra_headers();
231 params->transferred_request_child_id = 238 params->transferred_request_child_id =
232 entry.transferred_global_request_id().child_id; 239 entry.transferred_global_request_id().child_id;
233 params->transferred_request_request_id = 240 params->transferred_request_request_id =
(...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 TRACE_EVENT0("browser", "WebContentsImpl::NavigateToEntry"); 1611 TRACE_EVENT0("browser", "WebContentsImpl::NavigateToEntry");
1605 1612
1606 // The renderer will reject IPC messages with URLs longer than 1613 // The renderer will reject IPC messages with URLs longer than
1607 // this limit, so don't attempt to navigate with a longer URL. 1614 // this limit, so don't attempt to navigate with a longer URL.
1608 if (entry.GetURL().spec().size() > kMaxURLChars) { 1615 if (entry.GetURL().spec().size() > kMaxURLChars) {
1609 LOG(WARNING) << "Refusing to load URL as it exceeds " << kMaxURLChars 1616 LOG(WARNING) << "Refusing to load URL as it exceeds " << kMaxURLChars
1610 << " characters."; 1617 << " characters.";
1611 return false; 1618 return false;
1612 } 1619 }
1613 1620
1621 // TODO(creis): We need to store the frame ID on entry and use that to find
1622 // the correct RenderManager.
1623 int64 frame_tree_node_id = frame_tree_.root()->frame_tree_node_id();
1624 if (entry.frame_tree_node_id() != -1)
1625 frame_tree_node_id = entry.frame_tree_node_id();
1626
1627 RenderViewHostManager* manager =
1628 frame_tree_.FindByID(frame_tree_node_id)->render_manager();
1614 RenderViewHostImpl* dest_render_view_host = 1629 RenderViewHostImpl* dest_render_view_host =
1615 static_cast<RenderViewHostImpl*>(GetRenderManager()->Navigate(entry)); 1630 static_cast<RenderViewHostImpl*>(manager->Navigate(entry));
1616 if (!dest_render_view_host) 1631 if (!dest_render_view_host)
1617 return false; // Unable to create the desired render view host. 1632 return false; // Unable to create the desired render view host.
1618 1633
1619 // For security, we should never send non-Web-UI URLs to a Web UI renderer. 1634 // For security, we should never send non-Web-UI URLs to a Web UI renderer.
1620 // Double check that here. 1635 // Double check that here.
1621 int enabled_bindings = dest_render_view_host->GetEnabledBindings(); 1636 int enabled_bindings = dest_render_view_host->GetEnabledBindings();
1622 bool data_urls_allowed = delegate_ && delegate_->CanLoadDataURLsInWebUI(); 1637 bool data_urls_allowed = delegate_ && delegate_->CanLoadDataURLsInWebUI();
1623 bool is_allowed_in_web_ui_renderer = 1638 bool is_allowed_in_web_ui_renderer =
1624 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( 1639 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI(
1625 GetBrowserContext(), entry.GetURL(), data_urls_allowed); 1640 GetBrowserContext(), entry.GetURL(), data_urls_allowed);
1626 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && 1641 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) &&
1627 !is_allowed_in_web_ui_renderer) { 1642 !is_allowed_in_web_ui_renderer) {
1628 // Log the URL to help us diagnose any future failures of this CHECK. 1643 // Log the URL to help us diagnose any future failures of this CHECK.
1629 GetContentClient()->SetActiveURL(entry.GetURL()); 1644 GetContentClient()->SetActiveURL(entry.GetURL());
1630 CHECK(0); 1645 CHECK(0);
1631 } 1646 }
1632 1647
1633 // Notify observers that we will navigate in this RV. 1648 // Notify observers that we will navigate in this RV.
1634 FOR_EACH_OBSERVER(WebContentsObserver, 1649 FOR_EACH_OBSERVER(WebContentsObserver,
1635 observers_, 1650 observers_,
1636 AboutToNavigateRenderView(dest_render_view_host)); 1651 AboutToNavigateRenderView(dest_render_view_host));
1637 1652
1638 // Used for page load time metrics. 1653 // Used for page load time metrics.
1639 current_load_start_ = base::TimeTicks::Now(); 1654 current_load_start_ = base::TimeTicks::Now();
1640 1655
1641 // Navigate in the desired RenderViewHost. 1656 // Navigate in the desired RenderViewHost.
1657 // TODO(creis): Put frame ID in ViewMsg_Navigate_Params so that we can tell
1658 // the renderer which frame to navigate. Problem: it has to be the frame ID
1659 // in the destination renderer process, not the frame ID in the open params.
1660 // Or... just handle named frames for now.
1642 ViewMsg_Navigate_Params navigate_params; 1661 ViewMsg_Navigate_Params navigate_params;
1643 MakeNavigateParams(entry, controller_, delegate_, reload_type, 1662 MakeNavigateParams(entry, controller_, delegate_, reload_type,
1644 &navigate_params); 1663 &navigate_params);
1645 dest_render_view_host->Navigate(navigate_params); 1664 dest_render_view_host->Navigate(navigate_params);
1646 1665
1647 if (entry.GetPageID() == -1) { 1666 if (entry.GetPageID() == -1) {
1648 // HACK!! This code suppresses javascript: URLs from being added to 1667 // HACK!! This code suppresses javascript: URLs from being added to
1649 // session history, which is what we want to do for javascript: URLs that 1668 // session history, which is what we want to do for javascript: URLs that
1650 // do not generate content. What we really need is a message from the 1669 // do not generate content. What we really need is a message from the
1651 // renderer telling us that a new page was not created. The same message 1670 // renderer telling us that a new page was not created. The same message
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 int64 parent_frame_id, 1988 int64 parent_frame_id,
1970 bool is_main_frame, 1989 bool is_main_frame,
1971 const GURL& url) { 1990 const GURL& url) {
1972 bool is_error_page = (url.spec() == kUnreachableWebDataURL); 1991 bool is_error_page = (url.spec() == kUnreachableWebDataURL);
1973 bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL); 1992 bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL);
1974 GURL validated_url(url); 1993 GURL validated_url(url);
1975 RenderProcessHost* render_process_host = 1994 RenderProcessHost* render_process_host =
1976 render_view_host->GetProcess(); 1995 render_view_host->GetProcess();
1977 RenderViewHost::FilterURL(render_process_host, false, &validated_url); 1996 RenderViewHost::FilterURL(render_process_host, false, &validated_url);
1978 1997
1998 // TODO(creis): This is a hack for now, until we mirror the frame tree and do
1999 // cross-process subframe navigations in actual subframes.
2000 NavigationEntryImpl* pending_entry =
2001 NavigationEntryImpl::FromNavigationEntry(controller_.GetPendingEntry());
2002 if (pending_entry && pending_entry->frame_tree_node_id() != -1)
2003 is_main_frame = false;
2004
1979 if (is_main_frame) { 2005 if (is_main_frame) {
1980 DidChangeLoadProgress(0); 2006 DidChangeLoadProgress(0);
1981 2007
1982 // If there is no browser-initiated pending entry for this navigation and it 2008 // If there is no browser-initiated pending entry for this navigation and it
1983 // is not for the error URL, create a pending entry using the current 2009 // is not for the error URL, create a pending entry using the current
1984 // SiteInstance, and ensure the address bar updates accordingly. We don't 2010 // SiteInstance, and ensure the address bar updates accordingly. We don't
1985 // know the referrer or extra headers at this point, but the referrer will 2011 // know the referrer or extra headers at this point, but the referrer will
1986 // be set properly upon commit. 2012 // be set properly upon commit.
1987 NavigationEntryImpl* pending_entry =
1988 NavigationEntryImpl::FromNavigationEntry(controller_.GetPendingEntry());
1989 bool has_browser_initiated_pending_entry = pending_entry && 2013 bool has_browser_initiated_pending_entry = pending_entry &&
1990 !pending_entry->is_renderer_initiated(); 2014 !pending_entry->is_renderer_initiated();
1991 if (!has_browser_initiated_pending_entry && !is_error_page) { 2015 if (!has_browser_initiated_pending_entry && !is_error_page) {
1992 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( 2016 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry(
1993 controller_.CreateNavigationEntry(validated_url, 2017 controller_.CreateNavigationEntry(validated_url,
1994 content::Referrer(), 2018 content::Referrer(),
1995 content::PAGE_TRANSITION_LINK, 2019 content::PAGE_TRANSITION_LINK,
1996 true /* is_renderer_initiated */, 2020 true /* is_renderer_initiated */,
1997 std::string(), 2021 std::string(),
1998 GetBrowserContext())); 2022 GetBrowserContext()));
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
2682 void WebContentsImpl::NotifyNavigationEntryCommitted( 2706 void WebContentsImpl::NotifyNavigationEntryCommitted(
2683 const LoadCommittedDetails& load_details) { 2707 const LoadCommittedDetails& load_details) {
2684 FOR_EACH_OBSERVER( 2708 FOR_EACH_OBSERVER(
2685 WebContentsObserver, observers_, NavigationEntryCommitted(load_details)); 2709 WebContentsObserver, observers_, NavigationEntryCommitted(load_details));
2686 } 2710 }
2687 2711
2688 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() { 2712 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() {
2689 return render_view_host_delegate_view_; 2713 return render_view_host_delegate_view_;
2690 } 2714 }
2691 2715
2692 RenderViewHostDelegate::RendererManagement* 2716 RenderViewHostManager* WebContentsImpl::GetRenderManager() const {
2693 WebContentsImpl::GetRendererManagementDelegate() { 2717 return frame_tree_.root()->render_manager();
2694 return GetRenderManager();
2695 } 2718 }
2696 2719
2697 RendererPreferences WebContentsImpl::GetRendererPrefs( 2720 RendererPreferences WebContentsImpl::GetRendererPrefs(
2698 BrowserContext* browser_context) const { 2721 BrowserContext* browser_context) const {
2699 return renderer_preferences_; 2722 return renderer_preferences_;
2700 } 2723 }
2701 2724
2702 WebContents* WebContentsImpl::GetAsWebContents() { 2725 WebContents* WebContentsImpl::GetAsWebContents() {
2703 return this; 2726 return this;
2704 } 2727 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2822 2845
2823 // TODO(avi): Remove. http://crbug.com/170921 2846 // TODO(avi): Remove. http://crbug.com/170921
2824 NotificationService::current()->Notify( 2847 NotificationService::current()->Notify(
2825 NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, 2848 NOTIFICATION_RESOURCE_RECEIVED_REDIRECT,
2826 Source<WebContents>(this), 2849 Source<WebContents>(this),
2827 Details<const ResourceRedirectDetails>(&details)); 2850 Details<const ResourceRedirectDetails>(&details));
2828 } 2851 }
2829 2852
2830 void WebContentsImpl::DidNavigate( 2853 void WebContentsImpl::DidNavigate(
2831 RenderViewHost* rvh, 2854 RenderViewHost* rvh,
2832 const ViewHostMsg_FrameNavigate_Params& params) { 2855 const ViewHostMsg_FrameNavigate_Params& orig_params) {
2833 if (frame_tree_.IsFirstNavigationAfterSwap()) { 2856 ViewHostMsg_FrameNavigate_Params params(orig_params);
2857 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh);
2858 if (!rvhi->HasFrameID(params.frame_id)) {
2834 // First navigation should be a main frame navigation. 2859 // First navigation should be a main frame navigation.
2835 DCHECK(PageTransitionIsMainFrame(params.transition)); 2860 // TODO(creis): This DCHECK is disabled for now because cross-process
2836 frame_tree_.OnFirstNavigationAfterSwap(params.frame_id); 2861 // subframe navigations currently have a main frame PageTransition.
2862 //DCHECK(PageTransitionIsMainFrame(params.transition));
2863 rvhi->RegisterFrameID(params.frame_id,
2864 frame_tree_.root()->frame_tree_node_id());
2865 }
2866
2867 // Look up the FrameTreeNode ID that the renderer-specific frame ID
2868 // corresponds to.
2869 int frame_tree_node_id = rvhi->GetFrameTreeNodeID(params.frame_id);
2870
2871 // TODO(creis): In the short term, cross-process subframe navigations are
2872 // happening in the pending RenderViewHost's top-level frame. (We need to
2873 // both mirror the frame tree and get the navigation to occur in the correct
2874 // subframe to fix this.) Until then, we should check whether we have a
2875 // pending NavigationEntry with a frame ID and if so, treat the cross-process
2876 // "main frame" navigation as a subframe navigation.
2877 NavigationEntryImpl* pending_entry = NavigationEntryImpl::FromNavigationEntry(
2878 controller_.GetPendingEntry());
2879 if (pending_entry && pending_entry->frame_tree_node_id() != -1) {
2880 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME;
2881 frame_tree_node_id = pending_entry->frame_tree_node_id();
2837 } 2882 }
2838 2883
2839 if (PageTransitionIsMainFrame(params.transition)) { 2884 if (PageTransitionIsMainFrame(params.transition)) {
2840 // When overscroll navigation gesture is enabled, a screenshot of the page 2885 // When overscroll navigation gesture is enabled, a screenshot of the page
2841 // in its current state is taken so that it can be used during the 2886 // in its current state is taken so that it can be used during the
2842 // nav-gesture. It is necessary to take the screenshot here, before calling 2887 // nav-gesture. It is necessary to take the screenshot here, before calling
2843 // RenderViewHostManager::DidNavigateMainFrame, because that can change 2888 // RenderViewHostManager::DidNavigateMainFrame, because that can change
2844 // WebContents::GetRenderViewHost to return the new host, instead of the one 2889 // WebContents::GetRenderViewHost to return the new host, instead of the one
2845 // that may have just been swapped out. 2890 // that may have just been swapped out.
2846 if (delegate_ && delegate_->CanOverscrollContent()) 2891 if (delegate_ && delegate_->CanOverscrollContent())
2847 controller_.TakeScreenshot(); 2892 controller_.TakeScreenshot();
2893 }
2848 2894
2849 GetRenderManager()->DidNavigateMainFrame(rvh); 2895 FrameTreeNode* frame = frame_tree_.FindByID(frame_tree_node_id);
2896 if (!frame) {
2897 // Just for debugging. We can't trust the renderer to lie about the ID.
2898 NOTREACHED();
2899 return;
2850 } 2900 }
2901 // TODO(creis): Rename to DidNavigateFrame.
2902 frame->render_manager()->DidNavigateMainFrame(rvh);
2851 2903
2852 // Update the site of the SiteInstance if it doesn't have one yet, unless 2904 // Update the site of the SiteInstance if it doesn't have one yet, unless
2853 // assigning a site is not necessary for this URL. In that case, the 2905 // assigning a site is not necessary for this URL. In that case, the
2854 // SiteInstance can still be considered unused until a navigation to a real 2906 // SiteInstance can still be considered unused until a navigation to a real
2855 // page. 2907 // page.
2856 if (!static_cast<SiteInstanceImpl*>(GetSiteInstance())->HasSite() && 2908 if (!static_cast<SiteInstanceImpl*>(GetSiteInstance())->HasSite() &&
2857 ShouldAssignSiteForURL(params.url)) { 2909 ShouldAssignSiteForURL(params.url)) {
2858 static_cast<SiteInstanceImpl*>(GetSiteInstance())->SetSite(params.url); 2910 static_cast<SiteInstanceImpl*>(GetSiteInstance())->SetSite(params.url);
2859 } 2911 }
2860 2912
2861 // Need to update MIME type here because it's referred to in 2913 // Need to update MIME type here because it's referred to in
2862 // UpdateNavigationCommands() called by RendererDidNavigate() to 2914 // UpdateNavigationCommands() called by RendererDidNavigate() to
2863 // determine whether or not to enable the encoding menu. 2915 // determine whether or not to enable the encoding menu.
2864 // It's updated only for the main frame. For a subframe, 2916 // It's updated only for the main frame. For a subframe,
2865 // RenderView::UpdateURL does not set params.contents_mime_type. 2917 // RenderView::UpdateURL does not set params.contents_mime_type.
2866 // (see http://code.google.com/p/chromium/issues/detail?id=2929 ) 2918 // (see http://code.google.com/p/chromium/issues/detail?id=2929 )
2867 // TODO(jungshik): Add a test for the encoding menu to avoid 2919 // TODO(jungshik): Add a test for the encoding menu to avoid
2868 // regressing it again. 2920 // regressing it again.
2869 if (PageTransitionIsMainFrame(params.transition)) 2921 if (PageTransitionIsMainFrame(params.transition))
2870 contents_mime_type_ = params.contents_mime_type; 2922 contents_mime_type_ = params.contents_mime_type;
2871 2923
2872 LoadCommittedDetails details; 2924 LoadCommittedDetails details;
2873 bool did_navigate = controller_.RendererDidNavigate(params, &details); 2925 bool did_navigate = controller_.RendererDidNavigate(params, &details);
2874 2926
2875 // For now, keep track of each frame's URL in its FrameTreeNode. This lets 2927 // For now, keep track of each frame's URL in its FrameTreeNode. This lets
2876 // us estimate our process count for implementing OOP iframes. 2928 // us estimate our process count for implementing OOP iframes.
2877 // TODO(creis): Remove this when we track which pages commit in each frame. 2929 // TODO(creis): Remove this when we track which pages commit in each frame.
2878 frame_tree_.SetFrameUrl(params.frame_id, params.url); 2930 frame_tree_.SetFrameUrl(frame_tree_node_id, params.url);
2879 2931
2880 // Send notification about committed provisional loads. This notification is 2932 // Send notification about committed provisional loads. This notification is
2881 // different from the NAV_ENTRY_COMMITTED notification which doesn't include 2933 // different from the NAV_ENTRY_COMMITTED notification which doesn't include
2882 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. 2934 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations.
2883 if (details.type != NAVIGATION_TYPE_NAV_IGNORE) { 2935 if (details.type != NAVIGATION_TYPE_NAV_IGNORE) {
2884 // For AUTO_SUBFRAME navigations, an event for the main frame is generated 2936 // For AUTO_SUBFRAME navigations, an event for the main frame is generated
2885 // that is not recorded in the navigation history. For the purpose of 2937 // that is not recorded in the navigation history. For the purpose of
2886 // tracking navigation events, we treat this event as a sub frame navigation 2938 // tracking navigation events, we treat this event as a sub frame navigation
2887 // event. 2939 // event.
2888 bool is_main_frame = did_navigate ? details.is_main_frame : false; 2940 bool is_main_frame = did_navigate ? details.is_main_frame : false;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2924 } 2976 }
2925 } 2977 }
2926 DidNavigateAnyFramePostCommit(rvh, details, params); 2978 DidNavigateAnyFramePostCommit(rvh, details, params);
2927 } 2979 }
2928 2980
2929 void WebContentsImpl::UpdateState(RenderViewHost* rvh, 2981 void WebContentsImpl::UpdateState(RenderViewHost* rvh,
2930 int32 page_id, 2982 int32 page_id,
2931 const PageState& page_state) { 2983 const PageState& page_state) {
2932 // Ensure that this state update comes from either the active RVH or one of 2984 // Ensure that this state update comes from either the active RVH or one of
2933 // the swapped out RVHs. We don't expect to hear from any other RVHs. 2985 // the swapped out RVHs. We don't expect to hear from any other RVHs.
2986 // TODO(creis): This should go through RenderFrameHost.
2934 DCHECK(rvh == GetRenderViewHost() || 2987 DCHECK(rvh == GetRenderViewHost() ||
2935 GetRenderManager()->IsOnSwappedOutList(rvh)); 2988 GetRenderManager()->IsRVHOnSwappedOutList(
2989 static_cast<RenderViewHostImpl*>(rvh)));
2936 2990
2937 // We must be prepared to handle state updates for any page, these occur 2991 // We must be prepared to handle state updates for any page, these occur
2938 // when the user is scrolling and entering form data, as well as when we're 2992 // when the user is scrolling and entering form data, as well as when we're
2939 // leaving a page, in which case our state may have already been moved to 2993 // leaving a page, in which case our state may have already been moved to
2940 // the next page. The navigation controller will look up the appropriate 2994 // the next page. The navigation controller will look up the appropriate
2941 // NavigationEntry and update it when it is notified via the delegate. 2995 // NavigationEntry and update it when it is notified via the delegate.
2942 2996
2943 int entry_index = controller_.GetEntryIndexWithPageID( 2997 int entry_index = controller_.GetEntryIndexWithPageID(
2944 rvh->GetSiteInstance(), page_id); 2998 rvh->GetSiteInstance(), page_id);
2945 if (entry_index < 0) 2999 if (entry_index < 0)
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
3133 int64 source_frame_id, 3187 int64 source_frame_id,
3134 const GlobalRequestID& old_request_id, 3188 const GlobalRequestID& old_request_id,
3135 bool should_replace_current_entry, 3189 bool should_replace_current_entry,
3136 bool user_gesture) { 3190 bool user_gesture) {
3137 WebContents* new_contents = NULL; 3191 WebContents* new_contents = NULL;
3138 GURL dest_url(url); 3192 GURL dest_url(url);
3139 if (!GetContentClient()->browser()->ShouldAllowOpenURL( 3193 if (!GetContentClient()->browser()->ShouldAllowOpenURL(
3140 GetSiteInstance(), url)) 3194 GetSiteInstance(), url))
3141 dest_url = GURL(kAboutBlankURL); 3195 dest_url = GURL(kAboutBlankURL);
3142 3196
3143 OpenURLParams params(dest_url, referrer, source_frame_id, disposition, 3197 int64 frame_tree_node_id = -1;
3198 if (source_frame_id != -1) {
3199 frame_tree_node_id = static_cast<RenderViewHostImpl*>(
3200 GetRenderViewHost())->GetFrameTreeNodeID(source_frame_id);
3201 }
3202 OpenURLParams params(dest_url, referrer, source_frame_id,
3203 frame_tree_node_id, disposition,
3144 page_transition, true /* is_renderer_initiated */); 3204 page_transition, true /* is_renderer_initiated */);
3145 if (redirect_chain.size() > 0) 3205 if (redirect_chain.size() > 0)
3146 params.redirect_chain = redirect_chain; 3206 params.redirect_chain = redirect_chain;
3147 params.transferred_global_request_id = old_request_id; 3207 params.transferred_global_request_id = old_request_id;
3148 params.should_replace_current_entry = should_replace_current_entry; 3208 params.should_replace_current_entry = should_replace_current_entry;
3149 params.user_gesture = user_gesture; 3209 params.user_gesture = user_gesture;
3150 3210
3151 if (GetRenderManager()->web_ui()) { 3211 if (GetRenderManager()->web_ui()) {
3152 // Web UI pages sometimes want to override the page transition type for 3212 // Web UI pages sometimes want to override the page transition type for
3153 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for 3213 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
3356 // TODO(nasko): Investigate how to remove the GetActiveEntry usage here, 3416 // TODO(nasko): Investigate how to remove the GetActiveEntry usage here,
3357 // as it is deprecated and can be out of sync with GetRenderViewHost(). 3417 // as it is deprecated and can be out of sync with GetRenderViewHost().
3358 GURL url = controller_.GetActiveEntry() 3418 GURL url = controller_.GetActiveEntry()
3359 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); 3419 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL();
3360 3420
3361 return GetRenderManager()->current_host()->GetWebkitPrefs(url); 3421 return GetRenderManager()->current_host()->GetWebkitPrefs(url);
3362 } 3422 }
3363 3423
3364 int WebContentsImpl::CreateSwappedOutRenderView( 3424 int WebContentsImpl::CreateSwappedOutRenderView(
3365 SiteInstance* instance) { 3425 SiteInstance* instance) {
3366 return GetRenderManager()->CreateRenderView(instance, MSG_ROUTING_NONE, 3426 return GetRenderManager()->CreateRenderFrame(instance, MSG_ROUTING_NONE,
3367 true, true); 3427 true, true);
3368 } 3428 }
3369 3429
3370 void WebContentsImpl::OnUserGesture() { 3430 void WebContentsImpl::OnUserGesture() {
3371 // Notify observers. 3431 // Notify observers.
3372 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); 3432 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture());
3373 3433
3374 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); 3434 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get();
3375 if (rdh) // NULL in unittests. 3435 if (rdh) // NULL in unittests.
3376 rdh->OnUserGesture(this); 3436 rdh->OnUserGesture(this);
3377 } 3437 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
3526 instance) 3586 instance)
3527 return GetRenderManager()->pending_render_view_host()->GetRoutingID(); 3587 return GetRenderManager()->pending_render_view_host()->GetRoutingID();
3528 3588
3529 RenderViewHostImpl* rvh = GetRenderManager()->GetSwappedOutRenderViewHost( 3589 RenderViewHostImpl* rvh = GetRenderManager()->GetSwappedOutRenderViewHost(
3530 instance); 3590 instance);
3531 if (rvh) 3591 if (rvh)
3532 return rvh->GetRoutingID(); 3592 return rvh->GetRoutingID();
3533 3593
3534 // Create a swapped out RenderView in the given SiteInstance if none exists, 3594 // Create a swapped out RenderView in the given SiteInstance if none exists,
3535 // setting its opener to the given route_id. Return the new view's route_id. 3595 // setting its opener to the given route_id. Return the new view's route_id.
3536 return GetRenderManager()->CreateRenderView(instance, opener_route_id, 3596 return GetRenderManager()->CreateRenderFrame(instance, opener_route_id,
3537 true, true); 3597 true, true);
3538 } 3598 }
3539 3599
3540 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { 3600 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() {
3541 return GetController(); 3601 return GetController();
3542 } 3602 }
3543 3603
3544 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { 3604 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) {
3545 return static_cast<WebUIImpl*>(CreateWebUI(url)); 3605 return static_cast<WebUIImpl*>(CreateWebUI(url));
3546 } 3606 }
3547 3607
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3618 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(rvh); 3678 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(rvh);
3619 // Can be NULL during tests. 3679 // Can be NULL during tests.
3620 if (rwh_view) 3680 if (rwh_view)
3621 rwh_view->SetSize(GetView()->GetContainerSize()); 3681 rwh_view->SetSize(GetView()->GetContainerSize());
3622 } 3682 }
3623 3683
3624 bool WebContentsImpl::IsHidden() { 3684 bool WebContentsImpl::IsHidden() {
3625 return capturer_count_ == 0 && !should_normally_be_visible_; 3685 return capturer_count_ == 0 && !should_normally_be_visible_;
3626 } 3686 }
3627 3687
3628 RenderViewHostManager* WebContentsImpl::GetRenderManager() const {
3629 return frame_tree_.root()->render_manager();
3630 }
3631
3632 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { 3688 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() {
3633 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); 3689 return static_cast<RenderViewHostImpl*>(GetRenderViewHost());
3634 } 3690 }
3635 3691
3636 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const { 3692 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const {
3637 return browser_plugin_guest_.get(); 3693 return browser_plugin_guest_.get();
3638 } 3694 }
3639 3695
3640 void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) { 3696 void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) {
3641 CHECK(!browser_plugin_guest_); 3697 CHECK(!browser_plugin_guest_);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3676 } 3732 }
3677 3733
3678 void WebContentsImpl::OnFrameRemoved( 3734 void WebContentsImpl::OnFrameRemoved(
3679 RenderViewHostImpl* render_view_host, 3735 RenderViewHostImpl* render_view_host,
3680 int64 frame_id) { 3736 int64 frame_id) {
3681 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3737 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3682 FrameDetached(render_view_host, frame_id)); 3738 FrameDetached(render_view_host, frame_id));
3683 } 3739 }
3684 3740
3685 } // namespace content 3741 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698