| 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 } | 270 } |
| 271 | 271 |
| 272 void NotifyCacheOnIO( | 272 void NotifyCacheOnIO( |
| 273 scoped_refptr<net::URLRequestContextGetter> request_context, | 273 scoped_refptr<net::URLRequestContextGetter> request_context, |
| 274 const GURL& url, | 274 const GURL& url, |
| 275 const std::string& http_method) { | 275 const std::string& http_method) { |
| 276 request_context->GetURLRequestContext()->http_transaction_factory()-> | 276 request_context->GetURLRequestContext()->http_transaction_factory()-> |
| 277 GetCache()->OnExternalCacheHit(url, http_method); | 277 GetCache()->OnExternalCacheHit(url, http_method); |
| 278 } | 278 } |
| 279 | 279 |
| 280 // Helper function for retrieving all the sites in a frame tree. |
| 281 bool CollectSites(BrowserContext* context, |
| 282 std::set<GURL>* sites, |
| 283 FrameTreeNode* node) { |
| 284 sites->insert(SiteInstance::GetSiteForURL(context, node->current_url())); |
| 285 return true; |
| 286 } |
| 287 |
| 280 } // namespace | 288 } // namespace |
| 281 | 289 |
| 282 WebContents* WebContents::Create(const WebContents::CreateParams& params) { | 290 WebContents* WebContents::Create(const WebContents::CreateParams& params) { |
| 283 return WebContentsImpl::CreateWithOpener( | 291 return WebContentsImpl::CreateWithOpener( |
| 284 params, static_cast<WebContentsImpl*>(params.opener)); | 292 params, static_cast<WebContentsImpl*>(params.opener)); |
| 285 } | 293 } |
| 286 | 294 |
| 287 WebContents* WebContents::CreateWithSessionStorage( | 295 WebContents* WebContents::CreateWithSessionStorage( |
| 288 const WebContents::CreateParams& params, | 296 const WebContents::CreateParams& params, |
| 289 const SessionStorageNamespaceMap& session_storage_namespace_map) { | 297 const SessionStorageNamespaceMap& session_storage_namespace_map) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 is_showing_before_unload_dialog_(false), | 376 is_showing_before_unload_dialog_(false), |
| 369 closed_by_user_gesture_(false), | 377 closed_by_user_gesture_(false), |
| 370 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), | 378 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), |
| 371 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), | 379 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), |
| 372 temporary_zoom_settings_(false), | 380 temporary_zoom_settings_(false), |
| 373 color_chooser_identifier_(0), | 381 color_chooser_identifier_(0), |
| 374 message_source_(NULL), | 382 message_source_(NULL), |
| 375 fullscreen_widget_routing_id_(MSG_ROUTING_NONE) { | 383 fullscreen_widget_routing_id_(MSG_ROUTING_NONE) { |
| 376 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) | 384 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) |
| 377 g_created_callbacks.Get().at(i).Run(this); | 385 g_created_callbacks.Get().at(i).Run(this); |
| 386 frame_tree_.SetFrameRemoveListener( |
| 387 base::Bind(&WebContentsImpl::OnFrameRemoved, |
| 388 base::Unretained(this))); |
| 378 } | 389 } |
| 379 | 390 |
| 380 WebContentsImpl::~WebContentsImpl() { | 391 WebContentsImpl::~WebContentsImpl() { |
| 381 is_being_destroyed_ = true; | 392 is_being_destroyed_ = true; |
| 382 | 393 |
| 383 ClearAllPowerSaveBlockers(); | 394 ClearAllPowerSaveBlockers(); |
| 384 | 395 |
| 385 for (std::set<RenderWidgetHostImpl*>::iterator iter = | 396 for (std::set<RenderWidgetHostImpl*>::iterator iter = |
| 386 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) { | 397 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) { |
| 387 (*iter)->DetachDelegate(); | 398 (*iter)->DetachDelegate(); |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, | 727 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, |
| 717 OnBrowserPluginMessage(message)) | 728 OnBrowserPluginMessage(message)) |
| 718 IPC_MESSAGE_HANDLER(ImageHostMsg_DidDownloadImage, OnDidDownloadImage) | 729 IPC_MESSAGE_HANDLER(ImageHostMsg_DidDownloadImage, OnDidDownloadImage) |
| 719 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) | 730 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) |
| 720 #if defined(OS_ANDROID) | 731 #if defined(OS_ANDROID) |
| 721 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, | 732 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, |
| 722 OnFindMatchRectsReply) | 733 OnFindMatchRectsReply) |
| 723 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog, | 734 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog, |
| 724 OnOpenDateTimeDialog) | 735 OnOpenDateTimeDialog) |
| 725 #endif | 736 #endif |
| 726 IPC_MESSAGE_HANDLER(ViewHostMsg_FrameAttached, OnFrameAttached) | |
| 727 IPC_MESSAGE_HANDLER(ViewHostMsg_FrameDetached, OnFrameDetached) | |
| 728 IPC_MESSAGE_HANDLER(ViewHostMsg_MediaNotification, OnMediaNotification) | 737 IPC_MESSAGE_HANDLER(ViewHostMsg_MediaNotification, OnMediaNotification) |
| 729 IPC_MESSAGE_UNHANDLED(handled = false) | 738 IPC_MESSAGE_UNHANDLED(handled = false) |
| 730 IPC_END_MESSAGE_MAP_EX() | 739 IPC_END_MESSAGE_MAP_EX() |
| 731 message_source_ = NULL; | 740 message_source_ = NULL; |
| 732 | 741 |
| 733 if (!message_is_ok) { | 742 if (!message_is_ok) { |
| 734 RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); | 743 RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); |
| 735 GetRenderProcessHost()->ReceivedBadMessage(); | 744 GetRenderProcessHost()->ReceivedBadMessage(); |
| 736 } | 745 } |
| 737 | 746 |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 | 1028 |
| 1020 uint64 WebContentsImpl::GetUploadSize() const { | 1029 uint64 WebContentsImpl::GetUploadSize() const { |
| 1021 return upload_size_; | 1030 return upload_size_; |
| 1022 } | 1031 } |
| 1023 | 1032 |
| 1024 uint64 WebContentsImpl::GetUploadPosition() const { | 1033 uint64 WebContentsImpl::GetUploadPosition() const { |
| 1025 return upload_position_; | 1034 return upload_position_; |
| 1026 } | 1035 } |
| 1027 | 1036 |
| 1028 std::set<GURL> WebContentsImpl::GetSitesInTab() const { | 1037 std::set<GURL> WebContentsImpl::GetSitesInTab() const { |
| 1029 BrowserContext* browser_context = GetBrowserContext(); | |
| 1030 std::set<GURL> sites; | 1038 std::set<GURL> sites; |
| 1031 if (!frame_tree_root_.get()) | 1039 frame_tree_.ForEach(Bind(&CollectSites, |
| 1032 return sites; | 1040 base::Unretained(GetBrowserContext()), |
| 1033 | 1041 base::Unretained(&sites))); |
| 1034 // Iterates over the FrameTreeNodes to find each unique site URL that is | |
| 1035 // currently committed. | |
| 1036 FrameTreeNode* node = NULL; | |
| 1037 std::queue<FrameTreeNode*> queue; | |
| 1038 queue.push(frame_tree_root_.get()); | |
| 1039 | |
| 1040 while (!queue.empty()) { | |
| 1041 node = queue.front(); | |
| 1042 queue.pop(); | |
| 1043 sites.insert(SiteInstance::GetSiteForURL(browser_context, | |
| 1044 node->current_url())); | |
| 1045 | |
| 1046 for (size_t i = 0; i < node->child_count(); ++i) | |
| 1047 queue.push(node->child_at(i)); | |
| 1048 } | |
| 1049 | |
| 1050 return sites; | 1042 return sites; |
| 1051 } | 1043 } |
| 1052 | 1044 |
| 1053 const std::string& WebContentsImpl::GetEncoding() const { | 1045 const std::string& WebContentsImpl::GetEncoding() const { |
| 1054 return encoding_; | 1046 return encoding_; |
| 1055 } | 1047 } |
| 1056 | 1048 |
| 1057 bool WebContentsImpl::DisplayedInsecureContent() const { | 1049 bool WebContentsImpl::DisplayedInsecureContent() const { |
| 1058 return displayed_insecure_content_; | 1050 return displayed_insecure_content_; |
| 1059 } | 1051 } |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1733 delegate_->RequestMediaAccessPermission(this, request, callback); | 1725 delegate_->RequestMediaAccessPermission(this, request, callback); |
| 1734 else | 1726 else |
| 1735 callback.Run(MediaStreamDevices(), scoped_ptr<MediaStreamUI>()); | 1727 callback.Run(MediaStreamDevices(), scoped_ptr<MediaStreamUI>()); |
| 1736 } | 1728 } |
| 1737 | 1729 |
| 1738 SessionStorageNamespace* WebContentsImpl::GetSessionStorageNamespace( | 1730 SessionStorageNamespace* WebContentsImpl::GetSessionStorageNamespace( |
| 1739 SiteInstance* instance) { | 1731 SiteInstance* instance) { |
| 1740 return controller_.GetSessionStorageNamespace(instance); | 1732 return controller_.GetSessionStorageNamespace(instance); |
| 1741 } | 1733 } |
| 1742 | 1734 |
| 1735 FrameTree* WebContentsImpl::GetFrameTree() { |
| 1736 return &frame_tree_; |
| 1737 } |
| 1738 |
| 1743 void WebContentsImpl::DidSendScreenRects(RenderWidgetHostImpl* rwh) { | 1739 void WebContentsImpl::DidSendScreenRects(RenderWidgetHostImpl* rwh) { |
| 1744 if (browser_plugin_embedder_) | 1740 if (browser_plugin_embedder_) |
| 1745 browser_plugin_embedder_->DidSendScreenRects(); | 1741 browser_plugin_embedder_->DidSendScreenRects(); |
| 1746 } | 1742 } |
| 1747 | 1743 |
| 1748 void WebContentsImpl::UpdatePreferredSize(const gfx::Size& pref_size) { | 1744 void WebContentsImpl::UpdatePreferredSize(const gfx::Size& pref_size) { |
| 1749 preferred_size_ = pref_size; | 1745 preferred_size_ = pref_size; |
| 1750 if (delegate_) | 1746 if (delegate_) |
| 1751 delegate_->UpdatePreferredSize(this, pref_size); | 1747 delegate_->UpdatePreferredSize(this, pref_size); |
| 1752 } | 1748 } |
| (...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2632 image_download_map_.erase(id); | 2628 image_download_map_.erase(id); |
| 2633 } | 2629 } |
| 2634 | 2630 |
| 2635 void WebContentsImpl::OnUpdateFaviconURL( | 2631 void WebContentsImpl::OnUpdateFaviconURL( |
| 2636 int32 page_id, | 2632 int32 page_id, |
| 2637 const std::vector<FaviconURL>& candidates) { | 2633 const std::vector<FaviconURL>& candidates) { |
| 2638 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2634 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2639 DidUpdateFaviconURL(page_id, candidates)); | 2635 DidUpdateFaviconURL(page_id, candidates)); |
| 2640 } | 2636 } |
| 2641 | 2637 |
| 2642 FrameTreeNode* WebContentsImpl::FindFrameTreeNodeByID(int64 frame_id) { | |
| 2643 // TODO(nasko): Remove this check once we move to creating the root node | |
| 2644 // through RenderFrameHost creation. | |
| 2645 if (!frame_tree_root_.get()) | |
| 2646 return NULL; | |
| 2647 | |
| 2648 FrameTreeNode* node = NULL; | |
| 2649 std::queue<FrameTreeNode*> queue; | |
| 2650 queue.push(frame_tree_root_.get()); | |
| 2651 | |
| 2652 while (!queue.empty()) { | |
| 2653 node = queue.front(); | |
| 2654 queue.pop(); | |
| 2655 if (node->frame_id() == frame_id) | |
| 2656 return node; | |
| 2657 | |
| 2658 for (size_t i = 0; i < node->child_count(); ++i) | |
| 2659 queue.push(node->child_at(i)); | |
| 2660 } | |
| 2661 | |
| 2662 return NULL; | |
| 2663 } | |
| 2664 | |
| 2665 void WebContentsImpl::OnFrameAttached( | |
| 2666 int64 parent_frame_id, | |
| 2667 int64 frame_id, | |
| 2668 const std::string& frame_name) { | |
| 2669 FrameTreeNode* parent = FindFrameTreeNodeByID(parent_frame_id); | |
| 2670 if (!parent) | |
| 2671 return; | |
| 2672 | |
| 2673 FrameTreeNode* node = new FrameTreeNode(frame_id, frame_name); | |
| 2674 parent->AddChild(node); | |
| 2675 } | |
| 2676 | |
| 2677 void WebContentsImpl::OnFrameDetached(int64 parent_frame_id, int64 frame_id) { | |
| 2678 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | |
| 2679 FrameDetached(message_source_, frame_id)); | |
| 2680 | |
| 2681 FrameTreeNode* parent = FindFrameTreeNodeByID(parent_frame_id); | |
| 2682 if (!parent) | |
| 2683 return; | |
| 2684 | |
| 2685 parent->RemoveChild(frame_id); | |
| 2686 } | |
| 2687 | |
| 2688 void WebContentsImpl::OnMediaNotification(int64 player_cookie, | 2638 void WebContentsImpl::OnMediaNotification(int64 player_cookie, |
| 2689 bool has_video, | 2639 bool has_video, |
| 2690 bool has_audio, | 2640 bool has_audio, |
| 2691 bool is_playing) { | 2641 bool is_playing) { |
| 2692 // Chrome OS does its own detection of audio and video. | 2642 // Chrome OS does its own detection of audio and video. |
| 2693 #if !defined(OS_CHROMEOS) | 2643 #if !defined(OS_CHROMEOS) |
| 2694 if (is_playing) { | 2644 if (is_playing) { |
| 2695 scoped_ptr<PowerSaveBlocker> blocker; | 2645 scoped_ptr<PowerSaveBlocker> blocker; |
| 2696 if (has_video) { | 2646 if (has_video) { |
| 2697 blocker = PowerSaveBlocker::Create( | 2647 blocker = PowerSaveBlocker::Create( |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3055 // TODO(avi): Remove. http://crbug.com/170921 | 3005 // TODO(avi): Remove. http://crbug.com/170921 |
| 3056 NotificationService::current()->Notify( | 3006 NotificationService::current()->Notify( |
| 3057 NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, | 3007 NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, |
| 3058 Source<WebContents>(this), | 3008 Source<WebContents>(this), |
| 3059 Details<const ResourceRedirectDetails>(&details)); | 3009 Details<const ResourceRedirectDetails>(&details)); |
| 3060 } | 3010 } |
| 3061 | 3011 |
| 3062 void WebContentsImpl::DidNavigate( | 3012 void WebContentsImpl::DidNavigate( |
| 3063 RenderViewHost* rvh, | 3013 RenderViewHost* rvh, |
| 3064 const ViewHostMsg_FrameNavigate_Params& params) { | 3014 const ViewHostMsg_FrameNavigate_Params& params) { |
| 3065 // If we don't have a frame tree root yet, this is the first navigation in | 3015 if (frame_tree_.IsFirstNavigationAfterSwap()) { |
| 3066 // using the current RenderViewHost, so we need to create it with the proper | 3016 // First navigation should be a main frame navigation. |
| 3067 // frame id. | |
| 3068 if (!frame_tree_root_.get()) { | |
| 3069 DCHECK(PageTransitionIsMainFrame(params.transition)); | 3017 DCHECK(PageTransitionIsMainFrame(params.transition)); |
| 3070 frame_tree_root_.reset(new FrameTreeNode(params.frame_id, std::string())); | 3018 frame_tree_.OnFirstNavigationAfterSwap(params.frame_id); |
| 3071 } | 3019 } |
| 3072 | 3020 |
| 3073 if (PageTransitionIsMainFrame(params.transition)) { | 3021 if (PageTransitionIsMainFrame(params.transition)) { |
| 3074 // When overscroll navigation gesture is enabled, a screenshot of the page | 3022 // When overscroll navigation gesture is enabled, a screenshot of the page |
| 3075 // in its current state is taken so that it can be used during the | 3023 // in its current state is taken so that it can be used during the |
| 3076 // nav-gesture. It is necessary to take the screenshot here, before calling | 3024 // nav-gesture. It is necessary to take the screenshot here, before calling |
| 3077 // RenderViewHostManager::DidNavigateMainFrame, because that can change | 3025 // RenderViewHostManager::DidNavigateMainFrame, because that can change |
| 3078 // WebContents::GetRenderViewHost to return the new host, instead of the one | 3026 // WebContents::GetRenderViewHost to return the new host, instead of the one |
| 3079 // that may have just been swapped out. | 3027 // that may have just been swapped out. |
| 3080 if (delegate_ && delegate_->CanOverscrollContent()) | 3028 if (delegate_ && delegate_->CanOverscrollContent()) |
| 3081 controller_.TakeScreenshot(); | 3029 controller_.TakeScreenshot(); |
| 3082 | 3030 |
| 3083 render_manager_.DidNavigateMainFrame(rvh); | 3031 render_manager_.DidNavigateMainFrame(rvh); |
| 3084 } | 3032 } |
| 3085 | 3033 |
| 3086 // We expect to have a valid frame tree root node at all times when | |
| 3087 // navigating. | |
| 3088 DCHECK(frame_tree_root_.get()); | |
| 3089 | |
| 3090 // Update the site of the SiteInstance if it doesn't have one yet, unless | 3034 // Update the site of the SiteInstance if it doesn't have one yet, unless |
| 3091 // assigning a site is not necessary for this URL. In that case, the | 3035 // assigning a site is not necessary for this URL. In that case, the |
| 3092 // SiteInstance can still be considered unused until a navigation to a real | 3036 // SiteInstance can still be considered unused until a navigation to a real |
| 3093 // page. | 3037 // page. |
| 3094 if (!static_cast<SiteInstanceImpl*>(GetSiteInstance())->HasSite() && | 3038 if (!static_cast<SiteInstanceImpl*>(GetSiteInstance())->HasSite() && |
| 3095 ShouldAssignSiteForURL(params.url)) { | 3039 ShouldAssignSiteForURL(params.url)) { |
| 3096 static_cast<SiteInstanceImpl*>(GetSiteInstance())->SetSite(params.url); | 3040 static_cast<SiteInstanceImpl*>(GetSiteInstance())->SetSite(params.url); |
| 3097 } | 3041 } |
| 3098 | 3042 |
| 3099 // Need to update MIME type here because it's referred to in | 3043 // Need to update MIME type here because it's referred to in |
| 3100 // UpdateNavigationCommands() called by RendererDidNavigate() to | 3044 // UpdateNavigationCommands() called by RendererDidNavigate() to |
| 3101 // determine whether or not to enable the encoding menu. | 3045 // determine whether or not to enable the encoding menu. |
| 3102 // It's updated only for the main frame. For a subframe, | 3046 // It's updated only for the main frame. For a subframe, |
| 3103 // RenderView::UpdateURL does not set params.contents_mime_type. | 3047 // RenderView::UpdateURL does not set params.contents_mime_type. |
| 3104 // (see http://code.google.com/p/chromium/issues/detail?id=2929 ) | 3048 // (see http://code.google.com/p/chromium/issues/detail?id=2929 ) |
| 3105 // TODO(jungshik): Add a test for the encoding menu to avoid | 3049 // TODO(jungshik): Add a test for the encoding menu to avoid |
| 3106 // regressing it again. | 3050 // regressing it again. |
| 3107 if (PageTransitionIsMainFrame(params.transition)) | 3051 if (PageTransitionIsMainFrame(params.transition)) |
| 3108 contents_mime_type_ = params.contents_mime_type; | 3052 contents_mime_type_ = params.contents_mime_type; |
| 3109 | 3053 |
| 3110 LoadCommittedDetails details; | 3054 LoadCommittedDetails details; |
| 3111 bool did_navigate = controller_.RendererDidNavigate(params, &details); | 3055 bool did_navigate = controller_.RendererDidNavigate(params, &details); |
| 3112 | 3056 |
| 3113 // For now, keep track of each frame's URL in its FrameTreeNode. This lets | 3057 // For now, keep track of each frame's URL in its FrameTreeNode. This lets |
| 3114 // us estimate our process count for implementing OOP iframes. | 3058 // us estimate our process count for implementing OOP iframes. |
| 3115 // TODO(creis): Remove this when we track which pages commit in each frame. | 3059 // TODO(creis): Remove this when we track which pages commit in each frame. |
| 3116 FrameTreeNode* node = FindFrameTreeNodeByID(params.frame_id); | 3060 frame_tree_.SetFrameUrl(params.frame_id, params.url); |
| 3117 if (node) | |
| 3118 node->set_current_url(params.url); | |
| 3119 | 3061 |
| 3120 // Send notification about committed provisional loads. This notification is | 3062 // Send notification about committed provisional loads. This notification is |
| 3121 // different from the NAV_ENTRY_COMMITTED notification which doesn't include | 3063 // different from the NAV_ENTRY_COMMITTED notification which doesn't include |
| 3122 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. | 3064 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. |
| 3123 if (details.type != NAVIGATION_TYPE_NAV_IGNORE) { | 3065 if (details.type != NAVIGATION_TYPE_NAV_IGNORE) { |
| 3124 // For AUTO_SUBFRAME navigations, an event for the main frame is generated | 3066 // For AUTO_SUBFRAME navigations, an event for the main frame is generated |
| 3125 // that is not recorded in the navigation history. For the purpose of | 3067 // that is not recorded in the navigation history. For the purpose of |
| 3126 // tracking navigation events, we treat this event as a sub frame navigation | 3068 // tracking navigation events, we treat this event as a sub frame navigation |
| 3127 // event. | 3069 // event. |
| 3128 bool is_main_frame = did_navigate ? details.is_main_frame : false; | 3070 bool is_main_frame = did_navigate ? details.is_main_frame : false; |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3694 | 3636 |
| 3695 void WebContentsImpl::NotifySwappedFromRenderManager(RenderViewHost* old_host, | 3637 void WebContentsImpl::NotifySwappedFromRenderManager(RenderViewHost* old_host, |
| 3696 RenderViewHost* new_host) { | 3638 RenderViewHost* new_host) { |
| 3697 NotifySwapped(old_host, new_host); | 3639 NotifySwapped(old_host, new_host); |
| 3698 | 3640 |
| 3699 // Make sure the visible RVH reflects the new delegate's preferences. | 3641 // Make sure the visible RVH reflects the new delegate's preferences. |
| 3700 if (delegate_) | 3642 if (delegate_) |
| 3701 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); | 3643 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); |
| 3702 | 3644 |
| 3703 view_->RenderViewSwappedIn(new_host); | 3645 view_->RenderViewSwappedIn(new_host); |
| 3704 | |
| 3705 FrameTreeNode* root = NULL; | |
| 3706 RenderViewHostImpl* new_rvh = static_cast<RenderViewHostImpl*>(new_host); | |
| 3707 | |
| 3708 // We are doing a cross-site navigation and swapping processes. Since frame | |
| 3709 // ids are unique to a process, we need to recreate the frame tree with the | |
| 3710 // proper main frame id. | |
| 3711 // Note that it is possible for this method to be called before the new RVH | |
| 3712 // has committed a navigation (if RenderViewHostManager short-circuits the | |
| 3713 // CommitPending call because the current RVH is dead). In that case, we | |
| 3714 // haven't heard a valid frame id to use to initialize the root node, so clear | |
| 3715 // out the root node and the first subsequent navigation message will set it | |
| 3716 // correctly. | |
| 3717 if (new_rvh->main_frame_id() != -1) | |
| 3718 root = new FrameTreeNode(new_rvh->main_frame_id(), std::string()); | |
| 3719 | |
| 3720 frame_tree_root_.reset(root); | |
| 3721 } | 3646 } |
| 3722 | 3647 |
| 3723 int WebContentsImpl::CreateOpenerRenderViewsForRenderManager( | 3648 int WebContentsImpl::CreateOpenerRenderViewsForRenderManager( |
| 3724 SiteInstance* instance) { | 3649 SiteInstance* instance) { |
| 3725 if (!opener_) | 3650 if (!opener_) |
| 3726 return MSG_ROUTING_NONE; | 3651 return MSG_ROUTING_NONE; |
| 3727 | 3652 |
| 3728 // Recursively create RenderViews for anything else in the opener chain. | 3653 // Recursively create RenderViews for anything else in the opener chain. |
| 3729 return opener_->CreateOpenerRenderViews(instance); | 3654 return opener_->CreateOpenerRenderViews(instance); |
| 3730 } | 3655 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3884 | 3809 |
| 3885 gfx::Size WebContentsImpl::GetSizeForNewRenderView() const { | 3810 gfx::Size WebContentsImpl::GetSizeForNewRenderView() const { |
| 3886 gfx::Size size; | 3811 gfx::Size size; |
| 3887 if (delegate_) | 3812 if (delegate_) |
| 3888 size = delegate_->GetSizeForNewRenderView(this); | 3813 size = delegate_->GetSizeForNewRenderView(this); |
| 3889 if (size.IsEmpty()) | 3814 if (size.IsEmpty()) |
| 3890 size = view_->GetContainerSize(); | 3815 size = view_->GetContainerSize(); |
| 3891 return size; | 3816 return size; |
| 3892 } | 3817 } |
| 3893 | 3818 |
| 3819 void WebContentsImpl::OnFrameRemoved( |
| 3820 RenderViewHostImpl* render_view_host, |
| 3821 int64 frame_id) { |
| 3822 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 3823 FrameDetached(render_view_host, frame_id)); |
| 3824 } |
| 3825 |
| 3894 } // namespace content | 3826 } // namespace content |
| OLD | NEW |