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

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 109653014: Allow RenderFrames to swap out for subframe navigations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix an error during merge. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 ShouldUseCompositedScrollingForFrames(device_scale_factor_)); 945 ShouldUseCompositedScrollingForFrames(device_scale_factor_));
946 946
947 ApplyWebPreferences(webkit_preferences_, webview()); 947 ApplyWebPreferences(webkit_preferences_, webview());
948 948
949 main_render_frame_.reset( 949 main_render_frame_.reset(
950 RenderFrameImpl::Create(this, params->main_frame_routing_id)); 950 RenderFrameImpl::Create(this, params->main_frame_routing_id));
951 // The main frame WebFrame object is closed by 951 // The main frame WebFrame object is closed by
952 // RenderViewImpl::frameDetached(). 952 // RenderViewImpl::frameDetached().
953 webview()->setMainFrame(WebFrame::create(main_render_frame_.get())); 953 webview()->setMainFrame(WebFrame::create(main_render_frame_.get()));
954 main_render_frame_->MainWebFrameCreated(webview()->mainFrame()); 954 main_render_frame_->MainWebFrameCreated(webview()->mainFrame());
955 main_render_frame_->SetWebFrame(webview()->mainFrame());
955 956
956 if (switches::IsTouchDragDropEnabled()) 957 if (switches::IsTouchDragDropEnabled())
957 webview()->settings()->setTouchDragDropEnabled(true); 958 webview()->settings()->setTouchDragDropEnabled(true);
958 959
959 if (switches::IsTouchEditingEnabled()) 960 if (switches::IsTouchEditingEnabled())
960 webview()->settings()->setTouchEditingEnabled(true); 961 webview()->settings()->setTouchEditingEnabled(true);
961 962
962 if (!params->frame_name.empty()) 963 if (!params->frame_name.empty())
963 webview()->mainFrame()->setName(params->frame_name); 964 webview()->mainFrame()->setName(params->frame_name);
964 965
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 // mark it as such. This test checks if this is the first time UpdateURL 2003 // mark it as such. This test checks if this is the first time UpdateURL
2003 // has been called since WillNavigateToURL was called to initiate the load. 2004 // has been called since WillNavigateToURL was called to initiate the load.
2004 if (page_id_ > last_page_id_sent_to_browser_) 2005 if (page_id_ > last_page_id_sent_to_browser_)
2005 params.transition = PAGE_TRANSITION_MANUAL_SUBFRAME; 2006 params.transition = PAGE_TRANSITION_MANUAL_SUBFRAME;
2006 else 2007 else
2007 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; 2008 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME;
2008 2009
2009 DCHECK(!navigation_state->history_list_was_cleared()); 2010 DCHECK(!navigation_state->history_list_was_cleared());
2010 params.history_list_was_cleared = false; 2011 params.history_list_was_cleared = false;
2011 2012
2012 Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); 2013 // Don't send this message while the subframe is swapped out.
2014 // TODO(creis): This whole method should move to RenderFrame.
2015 RenderFrameImpl* rf = RenderFrameImpl::FindByWebFrame(frame);
2016 if (!rf || !rf->is_swapped_out())
2017 Send(new ViewHostMsg_FrameNavigate(routing_id_, params));
2013 } 2018 }
2014 2019
2015 last_page_id_sent_to_browser_ = 2020 last_page_id_sent_to_browser_ =
2016 std::max(last_page_id_sent_to_browser_, page_id_); 2021 std::max(last_page_id_sent_to_browser_, page_id_);
2017 2022
2018 // If we end up reusing this WebRequest (for example, due to a #ref click), 2023 // If we end up reusing this WebRequest (for example, due to a #ref click),
2019 // we don't want the transition type to persist. Just clear it. 2024 // we don't want the transition type to persist. Just clear it.
2020 navigation_state->set_transition_type(PAGE_TRANSITION_LINK); 2025 navigation_state->set_transition_type(PAGE_TRANSITION_LINK);
2021 } 2026 }
2022 2027
(...skipping 1814 matching lines...) Expand 10 before | Expand all | Expand 10 after
3837 if (document_state->finish_load_time().is_null()) { 3842 if (document_state->finish_load_time().is_null()) {
3838 if (!frame->parent()) { 3843 if (!frame->parent()) {
3839 TRACE_EVENT_INSTANT0("WebCore", "LoadFinished", 3844 TRACE_EVENT_INSTANT0("WebCore", "LoadFinished",
3840 TRACE_EVENT_SCOPE_PROCESS); 3845 TRACE_EVENT_SCOPE_PROCESS);
3841 } 3846 }
3842 document_state->set_finish_load_time(Time::Now()); 3847 document_state->set_finish_load_time(Time::Now());
3843 } 3848 }
3844 3849
3845 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFinishLoad(frame)); 3850 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFinishLoad(frame));
3846 3851
3852 // Don't send this message while the subframe is swapped out.
3853 // TODO(creis): This whole method should move to RenderFrame.
3854 RenderFrameImpl* rf = RenderFrameImpl::FindByWebFrame(frame);
3855 if (rf && rf->is_swapped_out())
3856 return;
3857
3847 Send(new ViewHostMsg_DidFinishLoad(routing_id_, 3858 Send(new ViewHostMsg_DidFinishLoad(routing_id_,
3848 frame->identifier(), 3859 frame->identifier(),
3849 ds->request().url(), 3860 ds->request().url(),
3850 !frame->parent())); 3861 !frame->parent()));
3851 } 3862 }
3852 3863
3853 void RenderViewImpl::didNavigateWithinPage( 3864 void RenderViewImpl::didNavigateWithinPage(
3854 WebFrame* frame, bool is_new_navigation) { 3865 WebFrame* frame, bool is_new_navigation) {
3855 // If this was a reference fragment navigation that we initiated, then we 3866 // If this was a reference fragment navigation that we initiated, then we
3856 // could end up having a non-null pending navigation params. We just need to 3867 // could end up having a non-null pending navigation params. We just need to
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after
5289 suppress_dialogs_until_swap_out_ = false; 5300 suppress_dialogs_until_swap_out_ = false;
5290 5301
5291 Send(new ViewHostMsg_SwapOut_ACK(routing_id_)); 5302 Send(new ViewHostMsg_SwapOut_ACK(routing_id_));
5292 } 5303 }
5293 5304
5294 void RenderViewImpl::NavigateToSwappedOutURL(blink::WebFrame* frame) { 5305 void RenderViewImpl::NavigateToSwappedOutURL(blink::WebFrame* frame) {
5295 // We use loadRequest instead of loadHTMLString because the former commits 5306 // We use loadRequest instead of loadHTMLString because the former commits
5296 // synchronously. Otherwise a new navigation can interrupt the navigation 5307 // synchronously. Otherwise a new navigation can interrupt the navigation
5297 // to kSwappedOutURL. If that happens to be to the page we had been 5308 // to kSwappedOutURL. If that happens to be to the page we had been
5298 // showing, then WebKit will never send a commit and we'll be left spinning. 5309 // showing, then WebKit will never send a commit and we'll be left spinning.
5299 CHECK(is_swapped_out_); 5310 // TODO(creis): Until we move this to RenderFrame, we may call this from a
5311 // swapped out RenderFrame while our own is_swapped_out_ is false.
5312 RenderFrameImpl* rf = RenderFrameImpl::FindByWebFrame(frame);
5313 CHECK(is_swapped_out_ || rf->is_swapped_out());
5300 GURL swappedOutURL(kSwappedOutURL); 5314 GURL swappedOutURL(kSwappedOutURL);
5301 WebURLRequest request(swappedOutURL); 5315 WebURLRequest request(swappedOutURL);
5302 frame->loadRequest(request); 5316 frame->loadRequest(request);
5303 } 5317 }
5304 5318
5305 void RenderViewImpl::OnClosePage() { 5319 void RenderViewImpl::OnClosePage() {
5306 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage()); 5320 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage());
5307 // TODO(creis): We'd rather use webview()->Close() here, but that currently 5321 // TODO(creis): We'd rather use webview()->Close() here, but that currently
5308 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs 5322 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs
5309 // in the onunload handler from appearing. For now, we're bypassing that and 5323 // in the onunload handler from appearing. For now, we're bypassing that and
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after
6448 for (size_t i = 0; i < icon_urls.size(); i++) { 6462 for (size_t i = 0; i < icon_urls.size(); i++) {
6449 WebURL url = icon_urls[i].iconURL(); 6463 WebURL url = icon_urls[i].iconURL();
6450 if (!url.isEmpty()) 6464 if (!url.isEmpty())
6451 urls.push_back(FaviconURL(url, 6465 urls.push_back(FaviconURL(url,
6452 ToFaviconType(icon_urls[i].iconType()))); 6466 ToFaviconType(icon_urls[i].iconType())));
6453 } 6467 }
6454 SendUpdateFaviconURL(urls); 6468 SendUpdateFaviconURL(urls);
6455 } 6469 }
6456 6470
6457 } // namespace content 6471 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698