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 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 webview()->settings()->setCompositedScrollingForFramesEnabled( | 953 webview()->settings()->setCompositedScrollingForFramesEnabled( |
954 ShouldUseCompositedScrollingForFrames(device_scale_factor_)); | 954 ShouldUseCompositedScrollingForFrames(device_scale_factor_)); |
955 | 955 |
956 ApplyWebPreferences(webkit_preferences_, webview()); | 956 ApplyWebPreferences(webkit_preferences_, webview()); |
957 | 957 |
958 main_render_frame_.reset( | 958 main_render_frame_.reset( |
959 RenderFrameImpl::Create(this, params->main_frame_routing_id)); | 959 RenderFrameImpl::Create(this, params->main_frame_routing_id)); |
960 // The main frame WebFrame object is closed by | 960 // The main frame WebFrame object is closed by |
961 // RenderViewImpl::frameDetached(). | 961 // RenderViewImpl::frameDetached(). |
962 webview()->setMainFrame(WebFrame::create(main_render_frame_.get())); | 962 webview()->setMainFrame(WebFrame::create(main_render_frame_.get())); |
| 963 main_render_frame_->set_web_frame(webview()->mainFrame()); |
963 | 964 |
964 if (switches::IsTouchDragDropEnabled()) | 965 if (switches::IsTouchDragDropEnabled()) |
965 webview()->settings()->setTouchDragDropEnabled(true); | 966 webview()->settings()->setTouchDragDropEnabled(true); |
966 | 967 |
967 if (switches::IsTouchEditingEnabled()) | 968 if (switches::IsTouchEditingEnabled()) |
968 webview()->settings()->setTouchEditingEnabled(true); | 969 webview()->settings()->setTouchEditingEnabled(true); |
969 | 970 |
970 if (!params->frame_name.empty()) | 971 if (!params->frame_name.empty()) |
971 webview()->mainFrame()->setName(params->frame_name); | 972 webview()->mainFrame()->setName(params->frame_name); |
972 | 973 |
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2150 // mark it as such. This test checks if this is the first time UpdateURL | 2151 // mark it as such. This test checks if this is the first time UpdateURL |
2151 // has been called since WillNavigateToURL was called to initiate the load. | 2152 // has been called since WillNavigateToURL was called to initiate the load. |
2152 if (page_id_ > last_page_id_sent_to_browser_) | 2153 if (page_id_ > last_page_id_sent_to_browser_) |
2153 params.transition = PAGE_TRANSITION_MANUAL_SUBFRAME; | 2154 params.transition = PAGE_TRANSITION_MANUAL_SUBFRAME; |
2154 else | 2155 else |
2155 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; | 2156 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; |
2156 | 2157 |
2157 DCHECK(!navigation_state->history_list_was_cleared()); | 2158 DCHECK(!navigation_state->history_list_was_cleared()); |
2158 params.history_list_was_cleared = false; | 2159 params.history_list_was_cleared = false; |
2159 | 2160 |
2160 Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); | 2161 // Don't send this message while the subframe is swapped out. |
| 2162 // TODO(creis): This whole method should move to RenderFrame. |
| 2163 RenderFrameImpl* rf = RenderFrameImpl::FindByWebFrame(frame); |
| 2164 if (!rf->is_swapped_out()) |
| 2165 Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); |
2161 } | 2166 } |
2162 | 2167 |
2163 last_page_id_sent_to_browser_ = | 2168 last_page_id_sent_to_browser_ = |
2164 std::max(last_page_id_sent_to_browser_, page_id_); | 2169 std::max(last_page_id_sent_to_browser_, page_id_); |
2165 | 2170 |
2166 // If we end up reusing this WebRequest (for example, due to a #ref click), | 2171 // If we end up reusing this WebRequest (for example, due to a #ref click), |
2167 // we don't want the transition type to persist. Just clear it. | 2172 // we don't want the transition type to persist. Just clear it. |
2168 navigation_state->set_transition_type(PAGE_TRANSITION_LINK); | 2173 navigation_state->set_transition_type(PAGE_TRANSITION_LINK); |
2169 } | 2174 } |
2170 | 2175 |
(...skipping 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3920 if (document_state->finish_load_time().is_null()) { | 3925 if (document_state->finish_load_time().is_null()) { |
3921 if (!frame->parent()) { | 3926 if (!frame->parent()) { |
3922 TRACE_EVENT_INSTANT0("WebCore", "LoadFinished", | 3927 TRACE_EVENT_INSTANT0("WebCore", "LoadFinished", |
3923 TRACE_EVENT_SCOPE_PROCESS); | 3928 TRACE_EVENT_SCOPE_PROCESS); |
3924 } | 3929 } |
3925 document_state->set_finish_load_time(Time::Now()); | 3930 document_state->set_finish_load_time(Time::Now()); |
3926 } | 3931 } |
3927 | 3932 |
3928 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFinishLoad(frame)); | 3933 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFinishLoad(frame)); |
3929 | 3934 |
| 3935 // Don't send this message while the subframe is swapped out. |
| 3936 // TODO(creis): This whole method should move to RenderFrame. |
| 3937 RenderFrameImpl* rf = RenderFrameImpl::FindByWebFrame(frame); |
| 3938 if (rf && rf->is_swapped_out()) |
| 3939 return; |
| 3940 |
3930 Send(new ViewHostMsg_DidFinishLoad(routing_id_, | 3941 Send(new ViewHostMsg_DidFinishLoad(routing_id_, |
3931 frame->identifier(), | 3942 frame->identifier(), |
3932 ds->request().url(), | 3943 ds->request().url(), |
3933 !frame->parent())); | 3944 !frame->parent())); |
3934 } | 3945 } |
3935 | 3946 |
3936 void RenderViewImpl::didNavigateWithinPage( | 3947 void RenderViewImpl::didNavigateWithinPage( |
3937 WebFrame* frame, bool is_new_navigation) { | 3948 WebFrame* frame, bool is_new_navigation) { |
3938 // If this was a reference fragment navigation that we initiated, then we | 3949 // If this was a reference fragment navigation that we initiated, then we |
3939 // could end up having a non-null pending navigation params. We just need to | 3950 // could end up having a non-null pending navigation params. We just need to |
(...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5398 suppress_dialogs_until_swap_out_ = false; | 5409 suppress_dialogs_until_swap_out_ = false; |
5399 | 5410 |
5400 Send(new ViewHostMsg_SwapOut_ACK(routing_id_)); | 5411 Send(new ViewHostMsg_SwapOut_ACK(routing_id_)); |
5401 } | 5412 } |
5402 | 5413 |
5403 void RenderViewImpl::NavigateToSwappedOutURL(blink::WebFrame* frame) { | 5414 void RenderViewImpl::NavigateToSwappedOutURL(blink::WebFrame* frame) { |
5404 // We use loadRequest instead of loadHTMLString because the former commits | 5415 // We use loadRequest instead of loadHTMLString because the former commits |
5405 // synchronously. Otherwise a new navigation can interrupt the navigation | 5416 // synchronously. Otherwise a new navigation can interrupt the navigation |
5406 // to kSwappedOutURL. If that happens to be to the page we had been | 5417 // to kSwappedOutURL. If that happens to be to the page we had been |
5407 // showing, then WebKit will never send a commit and we'll be left spinning. | 5418 // showing, then WebKit will never send a commit and we'll be left spinning. |
5408 CHECK(is_swapped_out_); | 5419 // TODO(creis): Until we move this to RenderFrame, we may call this from a |
| 5420 // swapped out RenderFrame while our own is_swapped_out_ is false. |
| 5421 //CHECK(is_swapped_out_); |
5409 GURL swappedOutURL(kSwappedOutURL); | 5422 GURL swappedOutURL(kSwappedOutURL); |
5410 WebURLRequest request(swappedOutURL); | 5423 WebURLRequest request(swappedOutURL); |
5411 frame->loadRequest(request); | 5424 frame->loadRequest(request); |
5412 } | 5425 } |
5413 | 5426 |
5414 void RenderViewImpl::OnClosePage() { | 5427 void RenderViewImpl::OnClosePage() { |
5415 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage()); | 5428 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage()); |
5416 // TODO(creis): We'd rather use webview()->Close() here, but that currently | 5429 // TODO(creis): We'd rather use webview()->Close() here, but that currently |
5417 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs | 5430 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs |
5418 // in the onunload handler from appearing. For now, we're bypassing that and | 5431 // in the onunload handler from appearing. For now, we're bypassing that and |
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6662 for (size_t i = 0; i < icon_urls.size(); i++) { | 6675 for (size_t i = 0; i < icon_urls.size(); i++) { |
6663 WebURL url = icon_urls[i].iconURL(); | 6676 WebURL url = icon_urls[i].iconURL(); |
6664 if (!url.isEmpty()) | 6677 if (!url.isEmpty()) |
6665 urls.push_back(FaviconURL(url, | 6678 urls.push_back(FaviconURL(url, |
6666 ToFaviconType(icon_urls[i].iconType()))); | 6679 ToFaviconType(icon_urls[i].iconType()))); |
6667 } | 6680 } |
6668 SendUpdateFaviconURL(urls); | 6681 SendUpdateFaviconURL(urls); |
6669 } | 6682 } |
6670 | 6683 |
6671 } // namespace content | 6684 } // namespace content |
OLD | NEW |