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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #include "content/public/common/content_switches.h" | 51 #include "content/public/common/content_switches.h" |
52 #include "content/public/common/context_menu_params.h" | 52 #include "content/public/common/context_menu_params.h" |
53 #include "content/public/common/favicon_url.h" | 53 #include "content/public/common/favicon_url.h" |
54 #include "content/public/common/file_chooser_params.h" | 54 #include "content/public/common/file_chooser_params.h" |
55 #include "content/public/common/ssl_status.h" | 55 #include "content/public/common/ssl_status.h" |
56 #include "content/public/common/three_d_api_types.h" | 56 #include "content/public/common/three_d_api_types.h" |
57 #include "content/public/common/url_constants.h" | 57 #include "content/public/common/url_constants.h" |
58 #include "content/public/renderer/content_renderer_client.h" | 58 #include "content/public/renderer/content_renderer_client.h" |
59 #include "content/public/renderer/context_menu_client.h" | 59 #include "content/public/renderer/context_menu_client.h" |
60 #include "content/public/renderer/document_state.h" | 60 #include "content/public/renderer/document_state.h" |
| 61 #include "content/public/renderer/history_item_serialization.h" |
61 #include "content/public/renderer/navigation_state.h" | 62 #include "content/public/renderer/navigation_state.h" |
62 #include "content/public/renderer/password_form_conversion_utils.h" | 63 #include "content/public/renderer/password_form_conversion_utils.h" |
63 #include "content/public/renderer/render_view_observer.h" | 64 #include "content/public/renderer/render_view_observer.h" |
64 #include "content/public/renderer/render_view_visitor.h" | 65 #include "content/public/renderer/render_view_visitor.h" |
65 #include "content/renderer/accessibility/renderer_accessibility.h" | 66 #include "content/renderer/accessibility/renderer_accessibility.h" |
66 #include "content/renderer/accessibility/renderer_accessibility_complete.h" | 67 #include "content/renderer/accessibility/renderer_accessibility_complete.h" |
67 #include "content/renderer/accessibility/renderer_accessibility_focus_only.h" | 68 #include "content/renderer/accessibility/renderer_accessibility_focus_only.h" |
68 #include "content/renderer/browser_plugin/browser_plugin.h" | 69 #include "content/renderer/browser_plugin/browser_plugin.h" |
69 #include "content/renderer/browser_plugin/browser_plugin_manager.h" | 70 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
70 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" | 71 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 #include "ui/gfx/native_widget_types.h" | 190 #include "ui/gfx/native_widget_types.h" |
190 #include "ui/gfx/point.h" | 191 #include "ui/gfx/point.h" |
191 #include "ui/gfx/rect.h" | 192 #include "ui/gfx/rect.h" |
192 #include "ui/gfx/rect_conversions.h" | 193 #include "ui/gfx/rect_conversions.h" |
193 #include "ui/gfx/size_conversions.h" | 194 #include "ui/gfx/size_conversions.h" |
194 #include "ui/shell_dialogs/selected_file_info.h" | 195 #include "ui/shell_dialogs/selected_file_info.h" |
195 #include "v8/include/v8.h" | 196 #include "v8/include/v8.h" |
196 #include "webkit/appcache/web_application_cache_host_impl.h" | 197 #include "webkit/appcache/web_application_cache_host_impl.h" |
197 #include "webkit/base/file_path_string_conversions.h" | 198 #include "webkit/base/file_path_string_conversions.h" |
198 #include "webkit/dom_storage/dom_storage_types.h" | 199 #include "webkit/dom_storage/dom_storage_types.h" |
199 #include "webkit/glue/glue_serialize.h" | |
200 #include "webkit/glue/webdropdata.h" | 200 #include "webkit/glue/webdropdata.h" |
201 #include "webkit/glue/webkit_glue.h" | 201 #include "webkit/glue/webkit_glue.h" |
202 #include "webkit/glue/weburlresponse_extradata_impl.h" | 202 #include "webkit/glue/weburlresponse_extradata_impl.h" |
203 #include "webkit/media/webmediaplayer_impl.h" | 203 #include "webkit/media/webmediaplayer_impl.h" |
204 #include "webkit/media/webmediaplayer_ms.h" | 204 #include "webkit/media/webmediaplayer_ms.h" |
205 #include "webkit/media/webmediaplayer_params.h" | 205 #include "webkit/media/webmediaplayer_params.h" |
206 #include "webkit/plugins/npapi/plugin_list.h" | 206 #include "webkit/plugins/npapi/plugin_list.h" |
207 #include "webkit/plugins/npapi/plugin_utils.h" | 207 #include "webkit/plugins/npapi/plugin_utils.h" |
208 #include "webkit/plugins/npapi/webplugin_delegate.h" | 208 #include "webkit/plugins/npapi/webplugin_delegate.h" |
209 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | 209 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1199 bool reload_original_url = | 1199 bool reload_original_url = |
1200 (params.navigation_type == | 1200 (params.navigation_type == |
1201 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); | 1201 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); |
1202 bool ignore_cache = (params.navigation_type == | 1202 bool ignore_cache = (params.navigation_type == |
1203 ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE); | 1203 ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE); |
1204 | 1204 |
1205 if (reload_original_url) | 1205 if (reload_original_url) |
1206 frame->reloadWithOverrideURL(params.url, true); | 1206 frame->reloadWithOverrideURL(params.url, true); |
1207 else | 1207 else |
1208 frame->reload(ignore_cache); | 1208 frame->reload(ignore_cache); |
1209 } else if (!params.state.empty()) { | 1209 } else if (params.page_state.IsValid()) { |
1210 // We must know the page ID of the page we are navigating back to. | 1210 // We must know the page ID of the page we are navigating back to. |
1211 DCHECK_NE(params.page_id, -1); | 1211 DCHECK_NE(params.page_id, -1); |
1212 WebHistoryItem item = webkit_glue::HistoryItemFromString(params.state); | 1212 WebHistoryItem item = PageStateToHistoryItem(params.page_state); |
1213 if (!item.isNull()) { | 1213 if (!item.isNull()) { |
1214 // Ensure we didn't save the swapped out URL in UpdateState, since the | 1214 // Ensure we didn't save the swapped out URL in UpdateState, since the |
1215 // browser should never be telling us to navigate to swappedout://. | 1215 // browser should never be telling us to navigate to swappedout://. |
1216 CHECK(item.urlString() != WebString::fromUTF8(kSwappedOutURL)); | 1216 CHECK(item.urlString() != WebString::fromUTF8(kSwappedOutURL)); |
1217 frame->loadHistoryItem(item); | 1217 frame->loadHistoryItem(item); |
1218 } | 1218 } |
1219 } else if (!params.base_url_for_data_url.is_empty()) { | 1219 } else if (!params.base_url_for_data_url.is_empty()) { |
1220 // A loadData request with a specified base URL. | 1220 // A loadData request with a specified base URL. |
1221 std::string mime_type, charset, data; | 1221 std::string mime_type, charset, data; |
1222 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { | 1222 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 // In case LoadRequest failed before DidCreateDataSource was called. | 1293 // In case LoadRequest failed before DidCreateDataSource was called. |
1294 pending_navigation_params_.reset(); | 1294 pending_navigation_params_.reset(); |
1295 } | 1295 } |
1296 | 1296 |
1297 bool RenderViewImpl::IsBackForwardToStaleEntry( | 1297 bool RenderViewImpl::IsBackForwardToStaleEntry( |
1298 const ViewMsg_Navigate_Params& params, | 1298 const ViewMsg_Navigate_Params& params, |
1299 bool is_reload) { | 1299 bool is_reload) { |
1300 // Make sure this isn't a back/forward to an entry we have already cropped | 1300 // Make sure this isn't a back/forward to an entry we have already cropped |
1301 // or replaced from our history, before the browser knew about it. If so, | 1301 // or replaced from our history, before the browser knew about it. If so, |
1302 // a new navigation has committed in the mean time, and we can ignore this. | 1302 // a new navigation has committed in the mean time, and we can ignore this. |
1303 bool is_back_forward = !is_reload && !params.state.empty(); | 1303 bool is_back_forward = !is_reload && params.page_state.IsValid(); |
1304 | 1304 |
1305 // Note: if the history_list_length_ is 0 for a back/forward, we must be | 1305 // Note: if the history_list_length_ is 0 for a back/forward, we must be |
1306 // restoring from a previous session. We'll update our state in OnNavigate. | 1306 // restoring from a previous session. We'll update our state in OnNavigate. |
1307 if (!is_back_forward || history_list_length_ <= 0) | 1307 if (!is_back_forward || history_list_length_ <= 0) |
1308 return false; | 1308 return false; |
1309 | 1309 |
1310 DCHECK_EQ(static_cast<int>(history_page_ids_.size()), history_list_length_); | 1310 DCHECK_EQ(static_cast<int>(history_page_ids_.size()), history_list_length_); |
1311 | 1311 |
1312 // Check for whether the forward history has been cropped due to a recent | 1312 // Check for whether the forward history has been cropped due to a recent |
1313 // navigation the browser didn't know about. | 1313 // navigation the browser didn't know about. |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1663 | 1663 |
1664 const PasswordForm* password_form_data = document_state->password_form_data(); | 1664 const PasswordForm* password_form_data = document_state->password_form_data(); |
1665 if (password_form_data) | 1665 if (password_form_data) |
1666 params.password_form = *password_form_data; | 1666 params.password_form = *password_form_data; |
1667 | 1667 |
1668 params.gesture = navigation_gesture_; | 1668 params.gesture = navigation_gesture_; |
1669 navigation_gesture_ = NavigationGestureUnknown; | 1669 navigation_gesture_ = NavigationGestureUnknown; |
1670 | 1670 |
1671 // Make navigation state a part of the FrameNavigate message so that commited | 1671 // Make navigation state a part of the FrameNavigate message so that commited |
1672 // entry had it at all times. | 1672 // entry had it at all times. |
1673 const WebHistoryItem& item = frame->currentHistoryItem(); | 1673 WebHistoryItem item = frame->currentHistoryItem(); |
1674 if (!item.isNull()) { | 1674 if (item.isNull()) { |
1675 params.content_state = webkit_glue::HistoryItemToString(item); | 1675 item.initialize(); |
1676 } else { | 1676 item.setURLString(request.url().spec().utf16()); |
1677 params.content_state = | |
1678 webkit_glue::CreateHistoryStateForURL(GURL(request.url())); | |
1679 } | 1677 } |
| 1678 params.page_state = HistoryItemToPageState(item); |
1680 | 1679 |
1681 if (!frame->parent()) { | 1680 if (!frame->parent()) { |
1682 // Top-level navigation. | 1681 // Top-level navigation. |
1683 | 1682 |
1684 // Reset the zoom limits in case a plugin had changed them previously. This | 1683 // Reset the zoom limits in case a plugin had changed them previously. This |
1685 // will also call us back which will cause us to send a message to | 1684 // will also call us back which will cause us to send a message to |
1686 // update WebContentsImpl. | 1685 // update WebContentsImpl. |
1687 webview()->zoomLimitsChanged( | 1686 webview()->zoomLimitsChanged( |
1688 WebView::zoomFactorToZoomLevel(kMinimumZoomFactor), | 1687 WebView::zoomFactorToZoomLevel(kMinimumZoomFactor), |
1689 WebView::zoomFactorToZoomLevel(kMaximumZoomFactor)); | 1688 WebView::zoomFactorToZoomLevel(kMaximumZoomFactor)); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1834 | 1833 |
1835 void RenderViewImpl::SendUpdateState(const WebHistoryItem& item) { | 1834 void RenderViewImpl::SendUpdateState(const WebHistoryItem& item) { |
1836 if (item.isNull()) | 1835 if (item.isNull()) |
1837 return; | 1836 return; |
1838 | 1837 |
1839 // Don't send state updates for kSwappedOutURL. | 1838 // Don't send state updates for kSwappedOutURL. |
1840 if (item.urlString() == WebString::fromUTF8(kSwappedOutURL)) | 1839 if (item.urlString() == WebString::fromUTF8(kSwappedOutURL)) |
1841 return; | 1840 return; |
1842 | 1841 |
1843 Send(new ViewHostMsg_UpdateState( | 1842 Send(new ViewHostMsg_UpdateState( |
1844 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); | 1843 routing_id_, page_id_, HistoryItemToPageState(item))); |
1845 } | 1844 } |
1846 | 1845 |
1847 void RenderViewImpl::OpenURL(WebFrame* frame, | 1846 void RenderViewImpl::OpenURL(WebFrame* frame, |
1848 const GURL& url, | 1847 const GURL& url, |
1849 const Referrer& referrer, | 1848 const Referrer& referrer, |
1850 WebNavigationPolicy policy) { | 1849 WebNavigationPolicy policy) { |
1851 ViewHostMsg_OpenURL_Params params; | 1850 ViewHostMsg_OpenURL_Params params; |
1852 params.url = url; | 1851 params.url = url; |
1853 params.referrer = referrer; | 1852 params.referrer = referrer; |
1854 params.disposition = NavigationPolicyToDisposition(policy); | 1853 params.disposition = NavigationPolicyToDisposition(policy); |
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3284 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which | 3283 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which |
3285 // can result in stale data for pages that are set to expire. We explicitly | 3284 // can result in stale data for pages that are set to expire. We explicitly |
3286 // override that by setting the policy here so that as necessary we load | 3285 // override that by setting the policy here so that as necessary we load |
3287 // from the network. | 3286 // from the network. |
3288 internal_data->set_cache_policy_override( | 3287 internal_data->set_cache_policy_override( |
3289 WebURLRequest::UseProtocolCachePolicy); | 3288 WebURLRequest::UseProtocolCachePolicy); |
3290 } | 3289 } |
3291 | 3290 |
3292 if (IsReload(params)) | 3291 if (IsReload(params)) |
3293 document_state->set_load_type(DocumentState::RELOAD); | 3292 document_state->set_load_type(DocumentState::RELOAD); |
3294 else if (!params.state.empty()) | 3293 else if (params.page_state.IsValid()) |
3295 document_state->set_load_type(DocumentState::HISTORY_LOAD); | 3294 document_state->set_load_type(DocumentState::HISTORY_LOAD); |
3296 else | 3295 else |
3297 document_state->set_load_type(DocumentState::NORMAL_LOAD); | 3296 document_state->set_load_type(DocumentState::NORMAL_LOAD); |
3298 | 3297 |
3299 internal_data->set_referrer_policy(params.referrer.policy); | 3298 internal_data->set_referrer_policy(params.referrer.policy); |
3300 internal_data->set_is_overriding_user_agent(params.is_overriding_user_agent); | 3299 internal_data->set_is_overriding_user_agent(params.is_overriding_user_agent); |
3301 internal_data->set_must_reset_scroll_and_scale_state( | 3300 internal_data->set_must_reset_scroll_and_scale_state( |
3302 params.navigation_type == | 3301 params.navigation_type == |
3303 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); | 3302 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); |
3304 document_state->set_can_load_local_resources(params.can_load_local_resources); | 3303 document_state->set_can_load_local_resources(params.can_load_local_resources); |
(...skipping 3231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6536 WebURL url = icon_urls[i].iconURL(); | 6535 WebURL url = icon_urls[i].iconURL(); |
6537 if (!url.isEmpty()) | 6536 if (!url.isEmpty()) |
6538 urls.push_back(FaviconURL(url, | 6537 urls.push_back(FaviconURL(url, |
6539 ToFaviconType(icon_urls[i].iconType()))); | 6538 ToFaviconType(icon_urls[i].iconType()))); |
6540 } | 6539 } |
6541 SendUpdateFaviconURL(urls); | 6540 SendUpdateFaviconURL(urls); |
6542 } | 6541 } |
6543 | 6542 |
6544 | 6543 |
6545 } // namespace content | 6544 } // namespace content |
OLD | NEW |