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/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 Loading... |
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_->set_web_frame(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 Loading... |
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 // TODO(creis): How did this work before for top-level frames? |
| 2017 bool frame_is_swapped_out = false; |
| 2018 if (frame->parent()) { |
| 2019 RenderFrameImpl* rf = RenderFrameImpl::FindByWebFrame(frame); |
| 2020 frame_is_swapped_out = rf->is_swapped_out(); |
| 2021 } |
| 2022 if (!frame_is_swapped_out) |
| 2023 Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); |
2014 } | 2024 } |
2015 | 2025 |
2016 last_page_id_sent_to_browser_ = | 2026 last_page_id_sent_to_browser_ = |
2017 std::max(last_page_id_sent_to_browser_, page_id_); | 2027 std::max(last_page_id_sent_to_browser_, page_id_); |
2018 | 2028 |
2019 // If we end up reusing this WebRequest (for example, due to a #ref click), | 2029 // 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. | 2030 // we don't want the transition type to persist. Just clear it. |
2021 navigation_state->set_transition_type(PAGE_TRANSITION_LINK); | 2031 navigation_state->set_transition_type(PAGE_TRANSITION_LINK); |
2022 } | 2032 } |
2023 | 2033 |
(...skipping 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3852 if (document_state->finish_load_time().is_null()) { | 3862 if (document_state->finish_load_time().is_null()) { |
3853 if (!frame->parent()) { | 3863 if (!frame->parent()) { |
3854 TRACE_EVENT_INSTANT0("WebCore", "LoadFinished", | 3864 TRACE_EVENT_INSTANT0("WebCore", "LoadFinished", |
3855 TRACE_EVENT_SCOPE_PROCESS); | 3865 TRACE_EVENT_SCOPE_PROCESS); |
3856 } | 3866 } |
3857 document_state->set_finish_load_time(Time::Now()); | 3867 document_state->set_finish_load_time(Time::Now()); |
3858 } | 3868 } |
3859 | 3869 |
3860 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFinishLoad(frame)); | 3870 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFinishLoad(frame)); |
3861 | 3871 |
| 3872 // Don't send this message while the subframe is swapped out. |
| 3873 // TODO(creis): This whole method should move to RenderFrame. |
| 3874 // TODO(creis): How did this work before for top-level frames? |
| 3875 if (frame->parent()) { |
| 3876 RenderFrameImpl* rf = RenderFrameImpl::FindByWebFrame(frame); |
| 3877 if (rf && rf->is_swapped_out()) |
| 3878 return; |
| 3879 } |
| 3880 |
3862 Send(new ViewHostMsg_DidFinishLoad(routing_id_, | 3881 Send(new ViewHostMsg_DidFinishLoad(routing_id_, |
3863 frame->identifier(), | 3882 frame->identifier(), |
3864 ds->request().url(), | 3883 ds->request().url(), |
3865 !frame->parent())); | 3884 !frame->parent())); |
3866 } | 3885 } |
3867 | 3886 |
3868 void RenderViewImpl::didNavigateWithinPage( | 3887 void RenderViewImpl::didNavigateWithinPage( |
3869 WebFrame* frame, bool is_new_navigation) { | 3888 WebFrame* frame, bool is_new_navigation) { |
3870 // If this was a reference fragment navigation that we initiated, then we | 3889 // 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 | 3890 // 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 Loading... |
5304 suppress_dialogs_until_swap_out_ = false; | 5323 suppress_dialogs_until_swap_out_ = false; |
5305 | 5324 |
5306 Send(new ViewHostMsg_SwapOut_ACK(routing_id_)); | 5325 Send(new ViewHostMsg_SwapOut_ACK(routing_id_)); |
5307 } | 5326 } |
5308 | 5327 |
5309 void RenderViewImpl::NavigateToSwappedOutURL(blink::WebFrame* frame) { | 5328 void RenderViewImpl::NavigateToSwappedOutURL(blink::WebFrame* frame) { |
5310 // We use loadRequest instead of loadHTMLString because the former commits | 5329 // We use loadRequest instead of loadHTMLString because the former commits |
5311 // synchronously. Otherwise a new navigation can interrupt the navigation | 5330 // synchronously. Otherwise a new navigation can interrupt the navigation |
5312 // to kSwappedOutURL. If that happens to be to the page we had been | 5331 // 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. | 5332 // showing, then WebKit will never send a commit and we'll be left spinning. |
5314 CHECK(is_swapped_out_); | 5333 // TODO(creis): Until we move this to RenderFrame, we may call this from a |
| 5334 // swapped out RenderFrame while our own is_swapped_out_ is false. |
| 5335 // TODO(creis): How did this work before for top-level frames? |
| 5336 bool is_swapped_out = is_swapped_out_; |
| 5337 if (frame->parent()) { |
| 5338 RenderFrameImpl* rf = RenderFrameImpl::FindByWebFrame(frame); |
| 5339 is_swapped_out |= rf->is_swapped_out(); |
| 5340 } |
| 5341 CHECK(is_swapped_out); |
5315 GURL swappedOutURL(kSwappedOutURL); | 5342 GURL swappedOutURL(kSwappedOutURL); |
5316 WebURLRequest request(swappedOutURL); | 5343 WebURLRequest request(swappedOutURL); |
5317 frame->loadRequest(request); | 5344 frame->loadRequest(request); |
5318 } | 5345 } |
5319 | 5346 |
5320 void RenderViewImpl::OnClosePage() { | 5347 void RenderViewImpl::OnClosePage() { |
5321 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage()); | 5348 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage()); |
5322 // TODO(creis): We'd rather use webview()->Close() here, but that currently | 5349 // TODO(creis): We'd rather use webview()->Close() here, but that currently |
5323 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs | 5350 // 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 | 5351 // 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 Loading... |
6463 for (size_t i = 0; i < icon_urls.size(); i++) { | 6490 for (size_t i = 0; i < icon_urls.size(); i++) { |
6464 WebURL url = icon_urls[i].iconURL(); | 6491 WebURL url = icon_urls[i].iconURL(); |
6465 if (!url.isEmpty()) | 6492 if (!url.isEmpty()) |
6466 urls.push_back(FaviconURL(url, | 6493 urls.push_back(FaviconURL(url, |
6467 ToFaviconType(icon_urls[i].iconType()))); | 6494 ToFaviconType(icon_urls[i].iconType()))); |
6468 } | 6495 } |
6469 SendUpdateFaviconURL(urls); | 6496 SendUpdateFaviconURL(urls); |
6470 } | 6497 } |
6471 | 6498 |
6472 } // namespace content | 6499 } // namespace content |
OLD | NEW |