| 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3041 // TODO(avi): Remove. http://crbug.com/170921 | 2991 // TODO(avi): Remove. http://crbug.com/170921 |
| 3042 NotificationService::current()->Notify( | 2992 NotificationService::current()->Notify( |
| 3043 NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, | 2993 NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, |
| 3044 Source<WebContents>(this), | 2994 Source<WebContents>(this), |
| 3045 Details<const ResourceRedirectDetails>(&details)); | 2995 Details<const ResourceRedirectDetails>(&details)); |
| 3046 } | 2996 } |
| 3047 | 2997 |
| 3048 void WebContentsImpl::DidNavigate( | 2998 void WebContentsImpl::DidNavigate( |
| 3049 RenderViewHost* rvh, | 2999 RenderViewHost* rvh, |
| 3050 const ViewHostMsg_FrameNavigate_Params& params) { | 3000 const ViewHostMsg_FrameNavigate_Params& params) { |
| 3051 // If we don't have a frame tree root yet, this is the first navigation in | 3001 if (frame_tree_.IsFirstNavigationAfterSwap()) { |
| 3052 // using the current RenderViewHost, so we need to create it with the proper | 3002 // First navigation should be a main frame navigation. |
| 3053 // frame id. | |
| 3054 if (!frame_tree_root_.get()) { | |
| 3055 DCHECK(PageTransitionIsMainFrame(params.transition)); | 3003 DCHECK(PageTransitionIsMainFrame(params.transition)); |
| 3056 frame_tree_root_.reset(new FrameTreeNode(params.frame_id, std::string())); | 3004 frame_tree_.OnFirstNavigationAfterSwap(params.frame_id); |
| 3057 } | 3005 } |
| 3058 | 3006 |
| 3059 if (PageTransitionIsMainFrame(params.transition)) { | 3007 if (PageTransitionIsMainFrame(params.transition)) { |
| 3060 // When overscroll navigation gesture is enabled, a screenshot of the page | 3008 // When overscroll navigation gesture is enabled, a screenshot of the page |
| 3061 // in its current state is taken so that it can be used during the | 3009 // in its current state is taken so that it can be used during the |
| 3062 // nav-gesture. It is necessary to take the screenshot here, before calling | 3010 // nav-gesture. It is necessary to take the screenshot here, before calling |
| 3063 // RenderViewHostManager::DidNavigateMainFrame, because that can change | 3011 // RenderViewHostManager::DidNavigateMainFrame, because that can change |
| 3064 // WebContents::GetRenderViewHost to return the new host, instead of the one | 3012 // WebContents::GetRenderViewHost to return the new host, instead of the one |
| 3065 // that may have just been swapped out. | 3013 // that may have just been swapped out. |
| 3066 if (delegate_ && delegate_->CanOverscrollContent()) | 3014 if (delegate_ && delegate_->CanOverscrollContent()) |
| 3067 controller_.TakeScreenshot(); | 3015 controller_.TakeScreenshot(); |
| 3068 | 3016 |
| 3069 render_manager_.DidNavigateMainFrame(rvh); | 3017 render_manager_.DidNavigateMainFrame(rvh); |
| 3070 } | 3018 } |
| 3071 | 3019 |
| 3072 // We expect to have a valid frame tree root node at all times when | |
| 3073 // navigating. | |
| 3074 DCHECK(frame_tree_root_.get()); | |
| 3075 | |
| 3076 // Update the site of the SiteInstance if it doesn't have one yet, unless | 3020 // Update the site of the SiteInstance if it doesn't have one yet, unless |
| 3077 // assigning a site is not necessary for this URL. In that case, the | 3021 // assigning a site is not necessary for this URL. In that case, the |
| 3078 // SiteInstance can still be considered unused until a navigation to a real | 3022 // SiteInstance can still be considered unused until a navigation to a real |
| 3079 // page. | 3023 // page. |
| 3080 if (!static_cast<SiteInstanceImpl*>(GetSiteInstance())->HasSite() && | 3024 if (!static_cast<SiteInstanceImpl*>(GetSiteInstance())->HasSite() && |
| 3081 ShouldAssignSiteForURL(params.url)) { | 3025 ShouldAssignSiteForURL(params.url)) { |
| 3082 static_cast<SiteInstanceImpl*>(GetSiteInstance())->SetSite(params.url); | 3026 static_cast<SiteInstanceImpl*>(GetSiteInstance())->SetSite(params.url); |
| 3083 } | 3027 } |
| 3084 | 3028 |
| 3085 // Need to update MIME type here because it's referred to in | 3029 // Need to update MIME type here because it's referred to in |
| 3086 // UpdateNavigationCommands() called by RendererDidNavigate() to | 3030 // UpdateNavigationCommands() called by RendererDidNavigate() to |
| 3087 // determine whether or not to enable the encoding menu. | 3031 // determine whether or not to enable the encoding menu. |
| 3088 // It's updated only for the main frame. For a subframe, | 3032 // It's updated only for the main frame. For a subframe, |
| 3089 // RenderView::UpdateURL does not set params.contents_mime_type. | 3033 // RenderView::UpdateURL does not set params.contents_mime_type. |
| 3090 // (see http://code.google.com/p/chromium/issues/detail?id=2929 ) | 3034 // (see http://code.google.com/p/chromium/issues/detail?id=2929 ) |
| 3091 // TODO(jungshik): Add a test for the encoding menu to avoid | 3035 // TODO(jungshik): Add a test for the encoding menu to avoid |
| 3092 // regressing it again. | 3036 // regressing it again. |
| 3093 if (PageTransitionIsMainFrame(params.transition)) | 3037 if (PageTransitionIsMainFrame(params.transition)) |
| 3094 contents_mime_type_ = params.contents_mime_type; | 3038 contents_mime_type_ = params.contents_mime_type; |
| 3095 | 3039 |
| 3096 LoadCommittedDetails details; | 3040 LoadCommittedDetails details; |
| 3097 bool did_navigate = controller_.RendererDidNavigate(params, &details); | 3041 bool did_navigate = controller_.RendererDidNavigate(params, &details); |
| 3098 | 3042 |
| 3099 // For now, keep track of each frame's URL in its FrameTreeNode. This lets | 3043 // For now, keep track of each frame's URL in its FrameTreeNode. This lets |
| 3100 // us estimate our process count for implementing OOP iframes. | 3044 // us estimate our process count for implementing OOP iframes. |
| 3101 // TODO(creis): Remove this when we track which pages commit in each frame. | 3045 // TODO(creis): Remove this when we track which pages commit in each frame. |
| 3102 FrameTreeNode* node = FindFrameTreeNodeByID(params.frame_id); | 3046 frame_tree_.SetFrameUrl(params.frame_id, params.url); |
| 3103 if (node) | |
| 3104 node->set_current_url(params.url); | |
| 3105 | 3047 |
| 3106 // Send notification about committed provisional loads. This notification is | 3048 // Send notification about committed provisional loads. This notification is |
| 3107 // different from the NAV_ENTRY_COMMITTED notification which doesn't include | 3049 // different from the NAV_ENTRY_COMMITTED notification which doesn't include |
| 3108 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. | 3050 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. |
| 3109 if (details.type != NAVIGATION_TYPE_NAV_IGNORE) { | 3051 if (details.type != NAVIGATION_TYPE_NAV_IGNORE) { |
| 3110 // For AUTO_SUBFRAME navigations, an event for the main frame is generated | 3052 // For AUTO_SUBFRAME navigations, an event for the main frame is generated |
| 3111 // that is not recorded in the navigation history. For the purpose of | 3053 // that is not recorded in the navigation history. For the purpose of |
| 3112 // tracking navigation events, we treat this event as a sub frame navigation | 3054 // tracking navigation events, we treat this event as a sub frame navigation |
| 3113 // event. | 3055 // event. |
| 3114 bool is_main_frame = did_navigate ? details.is_main_frame : false; | 3056 bool is_main_frame = did_navigate ? details.is_main_frame : false; |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3679 } | 3621 } |
| 3680 | 3622 |
| 3681 void WebContentsImpl::NotifySwappedFromRenderManager(RenderViewHost* rvh) { | 3623 void WebContentsImpl::NotifySwappedFromRenderManager(RenderViewHost* rvh) { |
| 3682 NotifySwapped(rvh); | 3624 NotifySwapped(rvh); |
| 3683 | 3625 |
| 3684 // Make sure the visible RVH reflects the new delegate's preferences. | 3626 // Make sure the visible RVH reflects the new delegate's preferences. |
| 3685 if (delegate_) | 3627 if (delegate_) |
| 3686 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); | 3628 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); |
| 3687 | 3629 |
| 3688 view_->RenderViewSwappedIn(render_manager_.current_host()); | 3630 view_->RenderViewSwappedIn(render_manager_.current_host()); |
| 3689 | |
| 3690 FrameTreeNode* root = NULL; | |
| 3691 RenderViewHostImpl* new_rvh = static_cast<RenderViewHostImpl*>( | |
| 3692 render_manager_.current_host()); | |
| 3693 | |
| 3694 // We are doing a cross-site navigation and swapping processes. Since frame | |
| 3695 // ids are unique to a process, we need to recreate the frame tree with the | |
| 3696 // proper main frame id. | |
| 3697 // Note that it is possible for this method to be called before the new RVH | |
| 3698 // has committed a navigation (if RenderViewHostManager short-circuits the | |
| 3699 // CommitPending call because the current RVH is dead). In that case, we | |
| 3700 // haven't heard a valid frame id to use to initialize the root node, so clear | |
| 3701 // out the root node and the first subsequent navigation message will set it | |
| 3702 // correctly. | |
| 3703 if (new_rvh->main_frame_id() != -1) | |
| 3704 root = new FrameTreeNode(new_rvh->main_frame_id(), std::string()); | |
| 3705 | |
| 3706 frame_tree_root_.reset(root); | |
| 3707 } | 3631 } |
| 3708 | 3632 |
| 3709 int WebContentsImpl::CreateOpenerRenderViewsForRenderManager( | 3633 int WebContentsImpl::CreateOpenerRenderViewsForRenderManager( |
| 3710 SiteInstance* instance) { | 3634 SiteInstance* instance) { |
| 3711 if (!opener_) | 3635 if (!opener_) |
| 3712 return MSG_ROUTING_NONE; | 3636 return MSG_ROUTING_NONE; |
| 3713 | 3637 |
| 3714 // Recursively create RenderViews for anything else in the opener chain. | 3638 // Recursively create RenderViews for anything else in the opener chain. |
| 3715 return opener_->CreateOpenerRenderViews(instance); | 3639 return opener_->CreateOpenerRenderViews(instance); |
| 3716 } | 3640 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3870 | 3794 |
| 3871 gfx::Size WebContentsImpl::GetSizeForNewRenderView() const { | 3795 gfx::Size WebContentsImpl::GetSizeForNewRenderView() const { |
| 3872 gfx::Size size; | 3796 gfx::Size size; |
| 3873 if (delegate_) | 3797 if (delegate_) |
| 3874 size = delegate_->GetSizeForNewRenderView(this); | 3798 size = delegate_->GetSizeForNewRenderView(this); |
| 3875 if (size.IsEmpty()) | 3799 if (size.IsEmpty()) |
| 3876 size = view_->GetContainerSize(); | 3800 size = view_->GetContainerSize(); |
| 3877 return size; | 3801 return size; |
| 3878 } | 3802 } |
| 3879 | 3803 |
| 3804 void WebContentsImpl::OnFrameRemoved( |
| 3805 RenderViewHost* render_view_host, |
| 3806 int64 frame_id) { |
| 3807 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 3808 FrameDetached(render_view_host, frame_id)); |
| 3809 } |
| 3810 |
| 3880 } // namespace content | 3811 } // namespace content |
| OLD | NEW |