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

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: Minor cleanup. Created 7 years 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
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 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 ShouldUseCompositedScrollingForFrames(device_scale_factor_)); 947 ShouldUseCompositedScrollingForFrames(device_scale_factor_));
948 948
949 ApplyWebPreferences(webkit_preferences_, webview()); 949 ApplyWebPreferences(webkit_preferences_, webview());
950 950
951 main_render_frame_.reset( 951 main_render_frame_.reset(
952 RenderFrameImpl::Create(this, params->main_frame_routing_id)); 952 RenderFrameImpl::Create(this, params->main_frame_routing_id));
953 // The main frame WebFrame object is closed by 953 // The main frame WebFrame object is closed by
954 // RenderViewImpl::frameDetached(). 954 // RenderViewImpl::frameDetached().
955 webview()->setMainFrame(WebFrame::create(main_render_frame_.get())); 955 webview()->setMainFrame(WebFrame::create(main_render_frame_.get()));
956 main_render_frame_->MainWebFrameCreated(webview()->mainFrame()); 956 main_render_frame_->MainWebFrameCreated(webview()->mainFrame());
957 main_render_frame_->SetWebFrame(webview()->mainFrame());
957 958
958 if (switches::IsTouchDragDropEnabled()) 959 if (switches::IsTouchDragDropEnabled())
959 webview()->settings()->setTouchDragDropEnabled(true); 960 webview()->settings()->setTouchDragDropEnabled(true);
960 961
961 if (switches::IsTouchEditingEnabled()) 962 if (switches::IsTouchEditingEnabled())
962 webview()->settings()->setTouchEditingEnabled(true); 963 webview()->settings()->setTouchEditingEnabled(true);
963 964
964 if (!params->frame_name.empty()) 965 if (!params->frame_name.empty())
965 webview()->mainFrame()->setName(params->frame_name); 966 webview()->mainFrame()->setName(params->frame_name);
966 967
(...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after
2003 // mark it as such. This test checks if this is the first time UpdateURL 2004 // mark it as such. This test checks if this is the first time UpdateURL
2004 // has been called since WillNavigateToURL was called to initiate the load. 2005 // has been called since WillNavigateToURL was called to initiate the load.
2005 if (page_id_ > last_page_id_sent_to_browser_) 2006 if (page_id_ > last_page_id_sent_to_browser_)
2006 params.transition = PAGE_TRANSITION_MANUAL_SUBFRAME; 2007 params.transition = PAGE_TRANSITION_MANUAL_SUBFRAME;
2007 else 2008 else
2008 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; 2009 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME;
2009 2010
2010 DCHECK(!navigation_state->history_list_was_cleared()); 2011 DCHECK(!navigation_state->history_list_was_cleared());
2011 params.history_list_was_cleared = false; 2012 params.history_list_was_cleared = false;
2012 2013
2013 Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); 2014 // Don't send this message while the subframe is swapped out.
2015 // TODO(creis): This whole method should move to RenderFrame.
2016 RenderFrameImpl* rf = RenderFrameImpl::FindByWebFrame(frame);
2017 if (!rf || !rf->is_swapped_out())
2018 Send(new ViewHostMsg_FrameNavigate(routing_id_, params));
2014 } 2019 }
2015 2020
2016 last_page_id_sent_to_browser_ = 2021 last_page_id_sent_to_browser_ =
2017 std::max(last_page_id_sent_to_browser_, page_id_); 2022 std::max(last_page_id_sent_to_browser_, page_id_);
2018 2023
2019 // If we end up reusing this WebRequest (for example, due to a #ref click), 2024 // If we end up reusing this WebRequest (for example, due to a #ref click),
2020 // we don't want the transition type to persist. Just clear it. 2025 // we don't want the transition type to persist. Just clear it.
2021 navigation_state->set_transition_type(PAGE_TRANSITION_LINK); 2026 navigation_state->set_transition_type(PAGE_TRANSITION_LINK);
2022 } 2027 }
2023 2028
(...skipping 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after
3852 if (document_state->finish_load_time().is_null()) { 3857 if (document_state->finish_load_time().is_null()) {
3853 if (!frame->parent()) { 3858 if (!frame->parent()) {
3854 TRACE_EVENT_INSTANT0("WebCore", "LoadFinished", 3859 TRACE_EVENT_INSTANT0("WebCore", "LoadFinished",
3855 TRACE_EVENT_SCOPE_PROCESS); 3860 TRACE_EVENT_SCOPE_PROCESS);
3856 } 3861 }
3857 document_state->set_finish_load_time(Time::Now()); 3862 document_state->set_finish_load_time(Time::Now());
3858 } 3863 }
3859 3864
3860 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFinishLoad(frame)); 3865 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFinishLoad(frame));
3861 3866
3867 // Don't send this message while the subframe is swapped out.
3868 // TODO(creis): This whole method should move to RenderFrame.
3869 RenderFrameImpl* rf = RenderFrameImpl::FindByWebFrame(frame);
3870 if (rf && rf->is_swapped_out())
3871 return;
3872
3862 Send(new ViewHostMsg_DidFinishLoad(routing_id_, 3873 Send(new ViewHostMsg_DidFinishLoad(routing_id_,
3863 frame->identifier(), 3874 frame->identifier(),
3864 ds->request().url(), 3875 ds->request().url(),
3865 !frame->parent())); 3876 !frame->parent()));
3866 } 3877 }
3867 3878
3868 void RenderViewImpl::didNavigateWithinPage( 3879 void RenderViewImpl::didNavigateWithinPage(
3869 WebFrame* frame, bool is_new_navigation) { 3880 WebFrame* frame, bool is_new_navigation) {
3870 // If this was a reference fragment navigation that we initiated, then we 3881 // If this was a reference fragment navigation that we initiated, then we
3871 // could end up having a non-null pending navigation params. We just need to 3882 // 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
5304 suppress_dialogs_until_swap_out_ = false; 5315 suppress_dialogs_until_swap_out_ = false;
5305 5316
5306 Send(new ViewHostMsg_SwapOut_ACK(routing_id_)); 5317 Send(new ViewHostMsg_SwapOut_ACK(routing_id_));
5307 } 5318 }
5308 5319
5309 void RenderViewImpl::NavigateToSwappedOutURL(blink::WebFrame* frame) { 5320 void RenderViewImpl::NavigateToSwappedOutURL(blink::WebFrame* frame) {
5310 // We use loadRequest instead of loadHTMLString because the former commits 5321 // We use loadRequest instead of loadHTMLString because the former commits
5311 // synchronously. Otherwise a new navigation can interrupt the navigation 5322 // synchronously. Otherwise a new navigation can interrupt the navigation
5312 // to kSwappedOutURL. If that happens to be to the page we had been 5323 // to kSwappedOutURL. If that happens to be to the page we had been
5313 // showing, then WebKit will never send a commit and we'll be left spinning. 5324 // showing, then WebKit will never send a commit and we'll be left spinning.
5314 CHECK(is_swapped_out_); 5325 // TODO(creis): Until we move this to RenderFrame, we may call this from a
5326 // swapped out RenderFrame while our own is_swapped_out_ is false.
5327 RenderFrameImpl* rf = RenderFrameImpl::FindByWebFrame(frame);
5328 CHECK(is_swapped_out_ || rf->is_swapped_out());
5315 GURL swappedOutURL(kSwappedOutURL); 5329 GURL swappedOutURL(kSwappedOutURL);
5316 WebURLRequest request(swappedOutURL); 5330 WebURLRequest request(swappedOutURL);
5317 frame->loadRequest(request); 5331 frame->loadRequest(request);
5318 } 5332 }
5319 5333
5320 void RenderViewImpl::OnClosePage() { 5334 void RenderViewImpl::OnClosePage() {
5321 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage()); 5335 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage());
5322 // TODO(creis): We'd rather use webview()->Close() here, but that currently 5336 // TODO(creis): We'd rather use webview()->Close() here, but that currently
5323 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs 5337 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs
5324 // in the onunload handler from appearing. For now, we're bypassing that and 5338 // 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
6463 for (size_t i = 0; i < icon_urls.size(); i++) { 6477 for (size_t i = 0; i < icon_urls.size(); i++) {
6464 WebURL url = icon_urls[i].iconURL(); 6478 WebURL url = icon_urls[i].iconURL();
6465 if (!url.isEmpty()) 6479 if (!url.isEmpty())
6466 urls.push_back(FaviconURL(url, 6480 urls.push_back(FaviconURL(url,
6467 ToFaviconType(icon_urls[i].iconType()))); 6481 ToFaviconType(icon_urls[i].iconType())));
6468 } 6482 }
6469 SendUpdateFaviconURL(urls); 6483 SendUpdateFaviconURL(urls);
6470 } 6484 }
6471 6485
6472 } // namespace content 6486 } // namespace content
OLDNEW
« content/renderer/render_frame_impl.cc ('K') | « content/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698