OLD | NEW |
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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 } | 261 } |
262 | 262 |
263 void NotifyCacheOnIO( | 263 void NotifyCacheOnIO( |
264 scoped_refptr<net::URLRequestContextGetter> request_context, | 264 scoped_refptr<net::URLRequestContextGetter> request_context, |
265 const GURL& url, | 265 const GURL& url, |
266 const std::string& http_method) { | 266 const std::string& http_method) { |
267 request_context->GetURLRequestContext()->http_transaction_factory()-> | 267 request_context->GetURLRequestContext()->http_transaction_factory()-> |
268 GetCache()->OnExternalCacheHit(url, http_method); | 268 GetCache()->OnExternalCacheHit(url, http_method); |
269 } | 269 } |
270 | 270 |
| 271 // Helper function for retrieving all the sites in a frame tree. |
| 272 bool CollectSites(BrowserContext* context, |
| 273 std::set<GURL>* sites, |
| 274 FrameTreeNode* node) { |
| 275 sites->insert(SiteInstance::GetSiteForURL(context, node->current_url())); |
| 276 return true; |
| 277 } |
| 278 |
271 } // namespace | 279 } // namespace |
272 | 280 |
273 WebContents* WebContents::Create(const WebContents::CreateParams& params) { | 281 WebContents* WebContents::Create(const WebContents::CreateParams& params) { |
274 return WebContentsImpl::CreateWithOpener( | 282 return WebContentsImpl::CreateWithOpener( |
275 params, static_cast<WebContentsImpl*>(params.opener)); | 283 params, static_cast<WebContentsImpl*>(params.opener)); |
276 } | 284 } |
277 | 285 |
278 WebContents* WebContents::CreateWithSessionStorage( | 286 WebContents* WebContents::CreateWithSessionStorage( |
279 const WebContents::CreateParams& params, | 287 const WebContents::CreateParams& params, |
280 const SessionStorageNamespaceMap& session_storage_namespace_map) { | 288 const SessionStorageNamespaceMap& session_storage_namespace_map) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 is_showing_before_unload_dialog_(false), | 367 is_showing_before_unload_dialog_(false), |
360 closed_by_user_gesture_(false), | 368 closed_by_user_gesture_(false), |
361 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), | 369 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), |
362 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), | 370 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), |
363 temporary_zoom_settings_(false), | 371 temporary_zoom_settings_(false), |
364 color_chooser_identifier_(0), | 372 color_chooser_identifier_(0), |
365 message_source_(NULL), | 373 message_source_(NULL), |
366 fullscreen_widget_routing_id_(MSG_ROUTING_NONE) { | 374 fullscreen_widget_routing_id_(MSG_ROUTING_NONE) { |
367 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) | 375 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) |
368 g_created_callbacks.Get().at(i).Run(this); | 376 g_created_callbacks.Get().at(i).Run(this); |
| 377 frame_tree_.SetFrameRemoveListener( |
| 378 base::Bind(&WebContentsImpl::OnFrameRemoved, |
| 379 base::Unretained(this))); |
369 } | 380 } |
370 | 381 |
371 WebContentsImpl::~WebContentsImpl() { | 382 WebContentsImpl::~WebContentsImpl() { |
372 is_being_destroyed_ = true; | 383 is_being_destroyed_ = true; |
373 | 384 |
374 ClearAllPowerSaveBlockers(); | 385 ClearAllPowerSaveBlockers(); |
375 | 386 |
376 for (std::set<RenderWidgetHostImpl*>::iterator iter = | 387 for (std::set<RenderWidgetHostImpl*>::iterator iter = |
377 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) { | 388 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) { |
378 (*iter)->DetachDelegate(); | 389 (*iter)->DetachDelegate(); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, | 716 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, |
706 OnBrowserPluginMessage(message)) | 717 OnBrowserPluginMessage(message)) |
707 IPC_MESSAGE_HANDLER(ImageHostMsg_DidDownloadImage, OnDidDownloadImage) | 718 IPC_MESSAGE_HANDLER(ImageHostMsg_DidDownloadImage, OnDidDownloadImage) |
708 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) | 719 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) |
709 #if defined(OS_ANDROID) | 720 #if defined(OS_ANDROID) |
710 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, | 721 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, |
711 OnFindMatchRectsReply) | 722 OnFindMatchRectsReply) |
712 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog, | 723 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog, |
713 OnOpenDateTimeDialog) | 724 OnOpenDateTimeDialog) |
714 #endif | 725 #endif |
715 IPC_MESSAGE_HANDLER(ViewHostMsg_FrameAttached, OnFrameAttached) | |
716 IPC_MESSAGE_HANDLER(ViewHostMsg_FrameDetached, OnFrameDetached) | |
717 IPC_MESSAGE_HANDLER(ViewHostMsg_MediaNotification, OnMediaNotification) | 726 IPC_MESSAGE_HANDLER(ViewHostMsg_MediaNotification, OnMediaNotification) |
718 IPC_MESSAGE_UNHANDLED(handled = false) | 727 IPC_MESSAGE_UNHANDLED(handled = false) |
719 IPC_END_MESSAGE_MAP_EX() | 728 IPC_END_MESSAGE_MAP_EX() |
720 message_source_ = NULL; | 729 message_source_ = NULL; |
721 | 730 |
722 if (!message_is_ok) { | 731 if (!message_is_ok) { |
723 RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); | 732 RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); |
724 GetRenderProcessHost()->ReceivedBadMessage(); | 733 GetRenderProcessHost()->ReceivedBadMessage(); |
725 } | 734 } |
726 | 735 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 | 1017 |
1009 uint64 WebContentsImpl::GetUploadSize() const { | 1018 uint64 WebContentsImpl::GetUploadSize() const { |
1010 return upload_size_; | 1019 return upload_size_; |
1011 } | 1020 } |
1012 | 1021 |
1013 uint64 WebContentsImpl::GetUploadPosition() const { | 1022 uint64 WebContentsImpl::GetUploadPosition() const { |
1014 return upload_position_; | 1023 return upload_position_; |
1015 } | 1024 } |
1016 | 1025 |
1017 std::set<GURL> WebContentsImpl::GetSitesInTab() const { | 1026 std::set<GURL> WebContentsImpl::GetSitesInTab() const { |
1018 BrowserContext* browser_context = GetBrowserContext(); | |
1019 std::set<GURL> sites; | 1027 std::set<GURL> sites; |
1020 if (!frame_tree_root_.get()) | 1028 frame_tree_.ForEach(Bind(&CollectSites, |
1021 return sites; | 1029 base::Unretained(GetBrowserContext()), |
1022 | 1030 base::Unretained(&sites))); |
1023 // Iterates over the FrameTreeNodes to find each unique site URL that is | |
1024 // currently committed. | |
1025 FrameTreeNode* node = NULL; | |
1026 std::queue<FrameTreeNode*> queue; | |
1027 queue.push(frame_tree_root_.get()); | |
1028 | |
1029 while (!queue.empty()) { | |
1030 node = queue.front(); | |
1031 queue.pop(); | |
1032 sites.insert(SiteInstance::GetSiteForURL(browser_context, | |
1033 node->current_url())); | |
1034 | |
1035 for (size_t i = 0; i < node->child_count(); ++i) | |
1036 queue.push(node->child_at(i)); | |
1037 } | |
1038 | |
1039 return sites; | 1031 return sites; |
1040 } | 1032 } |
1041 | 1033 |
1042 const std::string& WebContentsImpl::GetEncoding() const { | 1034 const std::string& WebContentsImpl::GetEncoding() const { |
1043 return encoding_; | 1035 return encoding_; |
1044 } | 1036 } |
1045 | 1037 |
1046 bool WebContentsImpl::DisplayedInsecureContent() const { | 1038 bool WebContentsImpl::DisplayedInsecureContent() const { |
1047 return displayed_insecure_content_; | 1039 return displayed_insecure_content_; |
1048 } | 1040 } |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1722 delegate_->RequestMediaAccessPermission(this, request, callback); | 1714 delegate_->RequestMediaAccessPermission(this, request, callback); |
1723 else | 1715 else |
1724 callback.Run(MediaStreamDevices(), scoped_ptr<MediaStreamUI>()); | 1716 callback.Run(MediaStreamDevices(), scoped_ptr<MediaStreamUI>()); |
1725 } | 1717 } |
1726 | 1718 |
1727 SessionStorageNamespace* WebContentsImpl::GetSessionStorageNamespace( | 1719 SessionStorageNamespace* WebContentsImpl::GetSessionStorageNamespace( |
1728 SiteInstance* instance) { | 1720 SiteInstance* instance) { |
1729 return controller_.GetSessionStorageNamespace(instance); | 1721 return controller_.GetSessionStorageNamespace(instance); |
1730 } | 1722 } |
1731 | 1723 |
| 1724 FrameTree* WebContentsImpl::GetFrameTree() { |
| 1725 return &frame_tree_; |
| 1726 } |
| 1727 |
1732 void WebContentsImpl::DidSendScreenRects(RenderWidgetHostImpl* rwh) { | 1728 void WebContentsImpl::DidSendScreenRects(RenderWidgetHostImpl* rwh) { |
1733 if (browser_plugin_embedder_) | 1729 if (browser_plugin_embedder_) |
1734 browser_plugin_embedder_->DidSendScreenRects(); | 1730 browser_plugin_embedder_->DidSendScreenRects(); |
1735 } | 1731 } |
1736 | 1732 |
1737 void WebContentsImpl::UpdatePreferredSize(const gfx::Size& pref_size) { | 1733 void WebContentsImpl::UpdatePreferredSize(const gfx::Size& pref_size) { |
1738 preferred_size_ = pref_size; | 1734 preferred_size_ = pref_size; |
1739 if (delegate_) | 1735 if (delegate_) |
1740 delegate_->UpdatePreferredSize(this, pref_size); | 1736 delegate_->UpdatePreferredSize(this, pref_size); |
1741 } | 1737 } |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2621 image_download_map_.erase(id); | 2617 image_download_map_.erase(id); |
2622 } | 2618 } |
2623 | 2619 |
2624 void WebContentsImpl::OnUpdateFaviconURL( | 2620 void WebContentsImpl::OnUpdateFaviconURL( |
2625 int32 page_id, | 2621 int32 page_id, |
2626 const std::vector<FaviconURL>& candidates) { | 2622 const std::vector<FaviconURL>& candidates) { |
2627 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2623 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
2628 DidUpdateFaviconURL(page_id, candidates)); | 2624 DidUpdateFaviconURL(page_id, candidates)); |
2629 } | 2625 } |
2630 | 2626 |
2631 FrameTreeNode* WebContentsImpl::FindFrameTreeNodeByID(int64 frame_id) { | |
2632 // TODO(nasko): Remove this check once we move to creating the root node | |
2633 // through RenderFrameHost creation. | |
2634 if (!frame_tree_root_.get()) | |
2635 return NULL; | |
2636 | |
2637 FrameTreeNode* node = NULL; | |
2638 std::queue<FrameTreeNode*> queue; | |
2639 queue.push(frame_tree_root_.get()); | |
2640 | |
2641 while (!queue.empty()) { | |
2642 node = queue.front(); | |
2643 queue.pop(); | |
2644 if (node->frame_id() == frame_id) | |
2645 return node; | |
2646 | |
2647 for (size_t i = 0; i < node->child_count(); ++i) | |
2648 queue.push(node->child_at(i)); | |
2649 } | |
2650 | |
2651 return NULL; | |
2652 } | |
2653 | |
2654 void WebContentsImpl::OnFrameAttached( | |
2655 int64 parent_frame_id, | |
2656 int64 frame_id, | |
2657 const std::string& frame_name) { | |
2658 FrameTreeNode* parent = FindFrameTreeNodeByID(parent_frame_id); | |
2659 if (!parent) | |
2660 return; | |
2661 | |
2662 FrameTreeNode* node = new FrameTreeNode(frame_id, frame_name); | |
2663 parent->AddChild(node); | |
2664 } | |
2665 | |
2666 void WebContentsImpl::OnFrameDetached(int64 parent_frame_id, int64 frame_id) { | |
2667 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | |
2668 FrameDetached(message_source_, frame_id)); | |
2669 | |
2670 FrameTreeNode* parent = FindFrameTreeNodeByID(parent_frame_id); | |
2671 if (!parent) | |
2672 return; | |
2673 | |
2674 parent->RemoveChild(frame_id); | |
2675 } | |
2676 | |
2677 void WebContentsImpl::OnMediaNotification(int64 player_cookie, | 2627 void WebContentsImpl::OnMediaNotification(int64 player_cookie, |
2678 bool has_video, | 2628 bool has_video, |
2679 bool has_audio, | 2629 bool has_audio, |
2680 bool is_playing) { | 2630 bool is_playing) { |
2681 // Chrome OS does its own detection of audio and video. | 2631 // Chrome OS does its own detection of audio and video. |
2682 #if !defined(OS_CHROMEOS) | 2632 #if !defined(OS_CHROMEOS) |
2683 if (is_playing) { | 2633 if (is_playing) { |
2684 scoped_ptr<PowerSaveBlocker> blocker; | 2634 scoped_ptr<PowerSaveBlocker> blocker; |
2685 if (has_video) { | 2635 if (has_video) { |
2686 blocker = PowerSaveBlocker::Create( | 2636 blocker = PowerSaveBlocker::Create( |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3036 // TODO(avi): Remove. http://crbug.com/170921 | 2986 // TODO(avi): Remove. http://crbug.com/170921 |
3037 NotificationService::current()->Notify( | 2987 NotificationService::current()->Notify( |
3038 NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, | 2988 NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, |
3039 Source<WebContents>(this), | 2989 Source<WebContents>(this), |
3040 Details<const ResourceRedirectDetails>(&details)); | 2990 Details<const ResourceRedirectDetails>(&details)); |
3041 } | 2991 } |
3042 | 2992 |
3043 void WebContentsImpl::DidNavigate( | 2993 void WebContentsImpl::DidNavigate( |
3044 RenderViewHost* rvh, | 2994 RenderViewHost* rvh, |
3045 const ViewHostMsg_FrameNavigate_Params& params) { | 2995 const ViewHostMsg_FrameNavigate_Params& params) { |
3046 // If we don't have a frame tree root yet, this is the first navigation in | 2996 if (frame_tree_.IsFirstNavigationAfterSwap()) { |
3047 // using the current RenderViewHost, so we need to create it with the proper | 2997 // First navigation should be a main frame navigation. |
3048 // frame id. | |
3049 if (!frame_tree_root_.get()) { | |
3050 DCHECK(PageTransitionIsMainFrame(params.transition)); | 2998 DCHECK(PageTransitionIsMainFrame(params.transition)); |
3051 frame_tree_root_.reset(new FrameTreeNode(params.frame_id, std::string())); | 2999 frame_tree_.OnFirstNavigationAfterSwap(params.frame_id); |
3052 } | 3000 } |
3053 | 3001 |
3054 if (PageTransitionIsMainFrame(params.transition)) { | 3002 if (PageTransitionIsMainFrame(params.transition)) { |
3055 // When overscroll navigation gesture is enabled, a screenshot of the page | 3003 // When overscroll navigation gesture is enabled, a screenshot of the page |
3056 // in its current state is taken so that it can be used during the | 3004 // in its current state is taken so that it can be used during the |
3057 // nav-gesture. It is necessary to take the screenshot here, before calling | 3005 // nav-gesture. It is necessary to take the screenshot here, before calling |
3058 // RenderViewHostManager::DidNavigateMainFrame, because that can change | 3006 // RenderViewHostManager::DidNavigateMainFrame, because that can change |
3059 // WebContents::GetRenderViewHost to return the new host, instead of the one | 3007 // WebContents::GetRenderViewHost to return the new host, instead of the one |
3060 // that may have just been swapped out. | 3008 // that may have just been swapped out. |
3061 if (delegate_ && delegate_->CanOverscrollContent()) | 3009 if (delegate_ && delegate_->CanOverscrollContent()) |
3062 controller_.TakeScreenshot(); | 3010 controller_.TakeScreenshot(); |
3063 | 3011 |
3064 render_manager_.DidNavigateMainFrame(rvh); | 3012 render_manager_.DidNavigateMainFrame(rvh); |
3065 } | 3013 } |
3066 | 3014 |
3067 // We expect to have a valid frame tree root node at all times when | |
3068 // navigating. | |
3069 DCHECK(frame_tree_root_.get()); | |
3070 | |
3071 // Update the site of the SiteInstance if it doesn't have one yet, unless | 3015 // Update the site of the SiteInstance if it doesn't have one yet, unless |
3072 // assigning a site is not necessary for this URL. In that case, the | 3016 // assigning a site is not necessary for this URL. In that case, the |
3073 // SiteInstance can still be considered unused until a navigation to a real | 3017 // SiteInstance can still be considered unused until a navigation to a real |
3074 // page. | 3018 // page. |
3075 if (!static_cast<SiteInstanceImpl*>(GetSiteInstance())->HasSite() && | 3019 if (!static_cast<SiteInstanceImpl*>(GetSiteInstance())->HasSite() && |
3076 ShouldAssignSiteForURL(params.url)) { | 3020 ShouldAssignSiteForURL(params.url)) { |
3077 static_cast<SiteInstanceImpl*>(GetSiteInstance())->SetSite(params.url); | 3021 static_cast<SiteInstanceImpl*>(GetSiteInstance())->SetSite(params.url); |
3078 } | 3022 } |
3079 | 3023 |
3080 // Need to update MIME type here because it's referred to in | 3024 // Need to update MIME type here because it's referred to in |
3081 // UpdateNavigationCommands() called by RendererDidNavigate() to | 3025 // UpdateNavigationCommands() called by RendererDidNavigate() to |
3082 // determine whether or not to enable the encoding menu. | 3026 // determine whether or not to enable the encoding menu. |
3083 // It's updated only for the main frame. For a subframe, | 3027 // It's updated only for the main frame. For a subframe, |
3084 // RenderView::UpdateURL does not set params.contents_mime_type. | 3028 // RenderView::UpdateURL does not set params.contents_mime_type. |
3085 // (see http://code.google.com/p/chromium/issues/detail?id=2929 ) | 3029 // (see http://code.google.com/p/chromium/issues/detail?id=2929 ) |
3086 // TODO(jungshik): Add a test for the encoding menu to avoid | 3030 // TODO(jungshik): Add a test for the encoding menu to avoid |
3087 // regressing it again. | 3031 // regressing it again. |
3088 if (PageTransitionIsMainFrame(params.transition)) | 3032 if (PageTransitionIsMainFrame(params.transition)) |
3089 contents_mime_type_ = params.contents_mime_type; | 3033 contents_mime_type_ = params.contents_mime_type; |
3090 | 3034 |
3091 LoadCommittedDetails details; | 3035 LoadCommittedDetails details; |
3092 bool did_navigate = controller_.RendererDidNavigate(params, &details); | 3036 bool did_navigate = controller_.RendererDidNavigate(params, &details); |
3093 | 3037 |
3094 // For now, keep track of each frame's URL in its FrameTreeNode. This lets | 3038 // For now, keep track of each frame's URL in its FrameTreeNode. This lets |
3095 // us estimate our process count for implementing OOP iframes. | 3039 // us estimate our process count for implementing OOP iframes. |
3096 // TODO(creis): Remove this when we track which pages commit in each frame. | 3040 // TODO(creis): Remove this when we track which pages commit in each frame. |
3097 FrameTreeNode* node = FindFrameTreeNodeByID(params.frame_id); | 3041 frame_tree_.SetFrameUrl(params.frame_id, params.url); |
3098 if (node) | |
3099 node->set_current_url(params.url); | |
3100 | 3042 |
3101 // Send notification about committed provisional loads. This notification is | 3043 // Send notification about committed provisional loads. This notification is |
3102 // different from the NAV_ENTRY_COMMITTED notification which doesn't include | 3044 // different from the NAV_ENTRY_COMMITTED notification which doesn't include |
3103 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. | 3045 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. |
3104 if (details.type != NAVIGATION_TYPE_NAV_IGNORE) { | 3046 if (details.type != NAVIGATION_TYPE_NAV_IGNORE) { |
3105 // For AUTO_SUBFRAME navigations, an event for the main frame is generated | 3047 // For AUTO_SUBFRAME navigations, an event for the main frame is generated |
3106 // that is not recorded in the navigation history. For the purpose of | 3048 // that is not recorded in the navigation history. For the purpose of |
3107 // tracking navigation events, we treat this event as a sub frame navigation | 3049 // tracking navigation events, we treat this event as a sub frame navigation |
3108 // event. | 3050 // event. |
3109 bool is_main_frame = did_navigate ? details.is_main_frame : false; | 3051 bool is_main_frame = did_navigate ? details.is_main_frame : false; |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3667 } | 3609 } |
3668 | 3610 |
3669 void WebContentsImpl::NotifySwappedFromRenderManager(RenderViewHost* rvh) { | 3611 void WebContentsImpl::NotifySwappedFromRenderManager(RenderViewHost* rvh) { |
3670 NotifySwapped(rvh); | 3612 NotifySwapped(rvh); |
3671 | 3613 |
3672 // Make sure the visible RVH reflects the new delegate's preferences. | 3614 // Make sure the visible RVH reflects the new delegate's preferences. |
3673 if (delegate_) | 3615 if (delegate_) |
3674 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); | 3616 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); |
3675 | 3617 |
3676 view_->RenderViewSwappedIn(render_manager_.current_host()); | 3618 view_->RenderViewSwappedIn(render_manager_.current_host()); |
3677 | |
3678 FrameTreeNode* root = NULL; | |
3679 RenderViewHostImpl* new_rvh = static_cast<RenderViewHostImpl*>( | |
3680 render_manager_.current_host()); | |
3681 | |
3682 // We are doing a cross-site navigation and swapping processes. Since frame | |
3683 // ids are unique to a process, we need to recreate the frame tree with the | |
3684 // proper main frame id. | |
3685 // Note that it is possible for this method to be called before the new RVH | |
3686 // has committed a navigation (if RenderViewHostManager short-circuits the | |
3687 // CommitPending call because the current RVH is dead). In that case, we | |
3688 // haven't heard a valid frame id to use to initialize the root node, so clear | |
3689 // out the root node and the first subsequent navigation message will set it | |
3690 // correctly. | |
3691 if (new_rvh->main_frame_id() != -1) | |
3692 root = new FrameTreeNode(new_rvh->main_frame_id(), std::string()); | |
3693 | |
3694 frame_tree_root_.reset(root); | |
3695 } | 3619 } |
3696 | 3620 |
3697 int WebContentsImpl::CreateOpenerRenderViewsForRenderManager( | 3621 int WebContentsImpl::CreateOpenerRenderViewsForRenderManager( |
3698 SiteInstance* instance) { | 3622 SiteInstance* instance) { |
3699 if (!opener_) | 3623 if (!opener_) |
3700 return MSG_ROUTING_NONE; | 3624 return MSG_ROUTING_NONE; |
3701 | 3625 |
3702 // Recursively create RenderViews for anything else in the opener chain. | 3626 // Recursively create RenderViews for anything else in the opener chain. |
3703 return opener_->CreateOpenerRenderViews(instance); | 3627 return opener_->CreateOpenerRenderViews(instance); |
3704 } | 3628 } |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3858 | 3782 |
3859 gfx::Size WebContentsImpl::GetSizeForNewRenderView() const { | 3783 gfx::Size WebContentsImpl::GetSizeForNewRenderView() const { |
3860 gfx::Size size; | 3784 gfx::Size size; |
3861 if (delegate_) | 3785 if (delegate_) |
3862 size = delegate_->GetSizeForNewRenderView(this); | 3786 size = delegate_->GetSizeForNewRenderView(this); |
3863 if (size.IsEmpty()) | 3787 if (size.IsEmpty()) |
3864 size = view_->GetContainerSize(); | 3788 size = view_->GetContainerSize(); |
3865 return size; | 3789 return size; |
3866 } | 3790 } |
3867 | 3791 |
| 3792 void WebContentsImpl::OnFrameRemoved(int64 frame_id) { |
| 3793 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 3794 FrameDetached(message_source_, frame_id)); |
| 3795 } |
| 3796 |
3868 } // namespace content | 3797 } // namespace content |
OLD | NEW |