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