Chromium Code Reviews| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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/common/url_utils.h" | 58 #include "content/public/common/url_utils.h" |
| 59 #include "content/public/renderer/content_renderer_client.h" | 59 #include "content/public/renderer/content_renderer_client.h" |
| 60 #include "content/public/renderer/context_menu_client.h" | 60 #include "content/public/renderer/context_menu_client.h" |
| 61 #include "content/public/renderer/document_state.h" | 61 #include "content/public/renderer/document_state.h" |
| 62 #include "content/public/renderer/history_item_serialization.h" | |
| 62 #include "content/public/renderer/navigation_state.h" | 63 #include "content/public/renderer/navigation_state.h" |
| 63 #include "content/public/renderer/password_form_conversion_utils.h" | 64 #include "content/public/renderer/password_form_conversion_utils.h" |
| 64 #include "content/public/renderer/render_view_observer.h" | 65 #include "content/public/renderer/render_view_observer.h" |
| 65 #include "content/public/renderer/render_view_visitor.h" | 66 #include "content/public/renderer/render_view_visitor.h" |
| 66 #include "content/renderer/accessibility/renderer_accessibility.h" | 67 #include "content/renderer/accessibility/renderer_accessibility.h" |
| 67 #include "content/renderer/accessibility/renderer_accessibility_complete.h" | 68 #include "content/renderer/accessibility/renderer_accessibility_complete.h" |
| 68 #include "content/renderer/accessibility/renderer_accessibility_focus_only.h" | 69 #include "content/renderer/accessibility/renderer_accessibility_focus_only.h" |
| 69 #include "content/renderer/browser_plugin/browser_plugin.h" | 70 #include "content/renderer/browser_plugin/browser_plugin.h" |
| 70 #include "content/renderer/browser_plugin/browser_plugin_manager.h" | 71 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
| 71 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" | 72 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 #include "ui/gfx/native_widget_types.h" | 192 #include "ui/gfx/native_widget_types.h" |
| 192 #include "ui/gfx/point.h" | 193 #include "ui/gfx/point.h" |
| 193 #include "ui/gfx/rect.h" | 194 #include "ui/gfx/rect.h" |
| 194 #include "ui/gfx/rect_conversions.h" | 195 #include "ui/gfx/rect_conversions.h" |
| 195 #include "ui/gfx/size_conversions.h" | 196 #include "ui/gfx/size_conversions.h" |
| 196 #include "ui/shell_dialogs/selected_file_info.h" | 197 #include "ui/shell_dialogs/selected_file_info.h" |
| 197 #include "v8/include/v8.h" | 198 #include "v8/include/v8.h" |
| 198 #include "webkit/appcache/web_application_cache_host_impl.h" | 199 #include "webkit/appcache/web_application_cache_host_impl.h" |
| 199 #include "webkit/base/file_path_string_conversions.h" | 200 #include "webkit/base/file_path_string_conversions.h" |
| 200 #include "webkit/dom_storage/dom_storage_types.h" | 201 #include "webkit/dom_storage/dom_storage_types.h" |
| 201 #include "webkit/glue/glue_serialize.h" | |
| 202 #include "webkit/glue/webdropdata.h" | 202 #include "webkit/glue/webdropdata.h" |
| 203 #include "webkit/glue/webkit_glue.h" | 203 #include "webkit/glue/webkit_glue.h" |
| 204 #include "webkit/glue/weburlresponse_extradata_impl.h" | 204 #include "webkit/glue/weburlresponse_extradata_impl.h" |
| 205 #include "webkit/media/webmediaplayer_impl.h" | 205 #include "webkit/media/webmediaplayer_impl.h" |
| 206 #include "webkit/media/webmediaplayer_ms.h" | 206 #include "webkit/media/webmediaplayer_ms.h" |
| 207 #include "webkit/media/webmediaplayer_params.h" | 207 #include "webkit/media/webmediaplayer_params.h" |
| 208 #include "webkit/plugins/npapi/plugin_list.h" | 208 #include "webkit/plugins/npapi/plugin_list.h" |
| 209 #include "webkit/plugins/npapi/plugin_utils.h" | 209 #include "webkit/plugins/npapi/plugin_utils.h" |
| 210 #include "webkit/plugins/npapi/webplugin_delegate.h" | 210 #include "webkit/plugins/npapi/webplugin_delegate.h" |
| 211 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | 211 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
| (...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1220 bool reload_original_url = | 1220 bool reload_original_url = |
| 1221 (params.navigation_type == | 1221 (params.navigation_type == |
| 1222 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); | 1222 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); |
| 1223 bool ignore_cache = (params.navigation_type == | 1223 bool ignore_cache = (params.navigation_type == |
| 1224 ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE); | 1224 ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE); |
| 1225 | 1225 |
| 1226 if (reload_original_url) | 1226 if (reload_original_url) |
| 1227 frame->reloadWithOverrideURL(params.url, true); | 1227 frame->reloadWithOverrideURL(params.url, true); |
| 1228 else | 1228 else |
| 1229 frame->reload(ignore_cache); | 1229 frame->reload(ignore_cache); |
| 1230 } else if (!params.state.empty()) { | 1230 } else if (params.page_state.IsValid()) { |
| 1231 // We must know the page ID of the page we are navigating back to. | 1231 // We must know the page ID of the page we are navigating back to. |
| 1232 DCHECK_NE(params.page_id, -1); | 1232 DCHECK_NE(params.page_id, -1); |
| 1233 WebHistoryItem item = webkit_glue::HistoryItemFromString(params.state); | 1233 WebHistoryItem item = PageStateToHistoryItem(params.page_state); |
| 1234 if (!item.isNull()) { | 1234 if (!item.isNull()) { |
| 1235 // Ensure we didn't save the swapped out URL in UpdateState, since the | 1235 // Ensure we didn't save the swapped out URL in UpdateState, since the |
| 1236 // browser should never be telling us to navigate to swappedout://. | 1236 // browser should never be telling us to navigate to swappedout://. |
| 1237 CHECK(item.urlString() != WebString::fromUTF8(kSwappedOutURL)); | 1237 CHECK(item.urlString() != WebString::fromUTF8(kSwappedOutURL)); |
| 1238 frame->loadHistoryItem(item); | 1238 frame->loadHistoryItem(item); |
| 1239 } | 1239 } |
| 1240 } else if (!params.base_url_for_data_url.is_empty()) { | 1240 } else if (!params.base_url_for_data_url.is_empty()) { |
| 1241 // A loadData request with a specified base URL. | 1241 // A loadData request with a specified base URL. |
| 1242 std::string mime_type, charset, data; | 1242 std::string mime_type, charset, data; |
| 1243 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { | 1243 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1314 // In case LoadRequest failed before DidCreateDataSource was called. | 1314 // In case LoadRequest failed before DidCreateDataSource was called. |
| 1315 pending_navigation_params_.reset(); | 1315 pending_navigation_params_.reset(); |
| 1316 } | 1316 } |
| 1317 | 1317 |
| 1318 bool RenderViewImpl::IsBackForwardToStaleEntry( | 1318 bool RenderViewImpl::IsBackForwardToStaleEntry( |
| 1319 const ViewMsg_Navigate_Params& params, | 1319 const ViewMsg_Navigate_Params& params, |
| 1320 bool is_reload) { | 1320 bool is_reload) { |
| 1321 // Make sure this isn't a back/forward to an entry we have already cropped | 1321 // Make sure this isn't a back/forward to an entry we have already cropped |
| 1322 // or replaced from our history, before the browser knew about it. If so, | 1322 // or replaced from our history, before the browser knew about it. If so, |
| 1323 // a new navigation has committed in the mean time, and we can ignore this. | 1323 // a new navigation has committed in the mean time, and we can ignore this. |
| 1324 bool is_back_forward = !is_reload && !params.state.empty(); | 1324 bool is_back_forward = !is_reload && params.page_state.IsValid(); |
| 1325 | 1325 |
| 1326 // Note: if the history_list_length_ is 0 for a back/forward, we must be | 1326 // Note: if the history_list_length_ is 0 for a back/forward, we must be |
| 1327 // restoring from a previous session. We'll update our state in OnNavigate. | 1327 // restoring from a previous session. We'll update our state in OnNavigate. |
| 1328 if (!is_back_forward || history_list_length_ <= 0) | 1328 if (!is_back_forward || history_list_length_ <= 0) |
| 1329 return false; | 1329 return false; |
| 1330 | 1330 |
| 1331 DCHECK_EQ(static_cast<int>(history_page_ids_.size()), history_list_length_); | 1331 DCHECK_EQ(static_cast<int>(history_page_ids_.size()), history_list_length_); |
| 1332 | 1332 |
| 1333 // Check for whether the forward history has been cropped due to a recent | 1333 // Check for whether the forward history has been cropped due to a recent |
| 1334 // navigation the browser didn't know about. | 1334 // navigation the browser didn't know about. |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1675 | 1675 |
| 1676 const PasswordForm* password_form_data = document_state->password_form_data(); | 1676 const PasswordForm* password_form_data = document_state->password_form_data(); |
| 1677 if (password_form_data) | 1677 if (password_form_data) |
| 1678 params.password_form = *password_form_data; | 1678 params.password_form = *password_form_data; |
| 1679 | 1679 |
| 1680 params.gesture = navigation_gesture_; | 1680 params.gesture = navigation_gesture_; |
| 1681 navigation_gesture_ = NavigationGestureUnknown; | 1681 navigation_gesture_ = NavigationGestureUnknown; |
| 1682 | 1682 |
| 1683 // Make navigation state a part of the FrameNavigate message so that commited | 1683 // Make navigation state a part of the FrameNavigate message so that commited |
| 1684 // entry had it at all times. | 1684 // entry had it at all times. |
| 1685 const WebHistoryItem& item = frame->currentHistoryItem(); | 1685 WebHistoryItem item = frame->currentHistoryItem(); |
| 1686 if (!item.isNull()) { | 1686 if (item.isNull()) { |
| 1687 params.content_state = webkit_glue::HistoryItemToString(item); | 1687 item.initialize(); |
| 1688 } else { | 1688 item.setURLString(request.url().spec().utf16()); |
|
brettw
2013/05/23 23:38:39
ugh, hopefully our refactoring can remove the need
| |
| 1689 params.content_state = | |
| 1690 webkit_glue::CreateHistoryStateForURL(GURL(request.url())); | |
| 1691 } | 1689 } |
| 1690 params.page_state = HistoryItemToPageState(item); | |
| 1692 | 1691 |
| 1693 if (!frame->parent()) { | 1692 if (!frame->parent()) { |
| 1694 // Top-level navigation. | 1693 // Top-level navigation. |
| 1695 | 1694 |
| 1696 // Reset the zoom limits in case a plugin had changed them previously. This | 1695 // Reset the zoom limits in case a plugin had changed them previously. This |
| 1697 // will also call us back which will cause us to send a message to | 1696 // will also call us back which will cause us to send a message to |
| 1698 // update WebContentsImpl. | 1697 // update WebContentsImpl. |
| 1699 webview()->zoomLimitsChanged( | 1698 webview()->zoomLimitsChanged( |
| 1700 WebView::zoomFactorToZoomLevel(kMinimumZoomFactor), | 1699 WebView::zoomFactorToZoomLevel(kMinimumZoomFactor), |
| 1701 WebView::zoomFactorToZoomLevel(kMaximumZoomFactor)); | 1700 WebView::zoomFactorToZoomLevel(kMaximumZoomFactor)); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1846 | 1845 |
| 1847 void RenderViewImpl::SendUpdateState(const WebHistoryItem& item) { | 1846 void RenderViewImpl::SendUpdateState(const WebHistoryItem& item) { |
| 1848 if (item.isNull()) | 1847 if (item.isNull()) |
| 1849 return; | 1848 return; |
| 1850 | 1849 |
| 1851 // Don't send state updates for kSwappedOutURL. | 1850 // Don't send state updates for kSwappedOutURL. |
| 1852 if (item.urlString() == WebString::fromUTF8(kSwappedOutURL)) | 1851 if (item.urlString() == WebString::fromUTF8(kSwappedOutURL)) |
| 1853 return; | 1852 return; |
| 1854 | 1853 |
| 1855 Send(new ViewHostMsg_UpdateState( | 1854 Send(new ViewHostMsg_UpdateState( |
| 1856 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); | 1855 routing_id_, page_id_, HistoryItemToPageState(item))); |
| 1857 } | 1856 } |
| 1858 | 1857 |
| 1859 void RenderViewImpl::OpenURL(WebFrame* frame, | 1858 void RenderViewImpl::OpenURL(WebFrame* frame, |
| 1860 const GURL& url, | 1859 const GURL& url, |
| 1861 const Referrer& referrer, | 1860 const Referrer& referrer, |
| 1862 WebNavigationPolicy policy) { | 1861 WebNavigationPolicy policy) { |
| 1863 ViewHostMsg_OpenURL_Params params; | 1862 ViewHostMsg_OpenURL_Params params; |
| 1864 params.url = url; | 1863 params.url = url; |
| 1865 params.referrer = referrer; | 1864 params.referrer = referrer; |
| 1866 params.disposition = NavigationPolicyToDisposition(policy); | 1865 params.disposition = NavigationPolicyToDisposition(policy); |
| (...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3293 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which | 3292 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which |
| 3294 // can result in stale data for pages that are set to expire. We explicitly | 3293 // can result in stale data for pages that are set to expire. We explicitly |
| 3295 // override that by setting the policy here so that as necessary we load | 3294 // override that by setting the policy here so that as necessary we load |
| 3296 // from the network. | 3295 // from the network. |
| 3297 internal_data->set_cache_policy_override( | 3296 internal_data->set_cache_policy_override( |
| 3298 WebURLRequest::UseProtocolCachePolicy); | 3297 WebURLRequest::UseProtocolCachePolicy); |
| 3299 } | 3298 } |
| 3300 | 3299 |
| 3301 if (IsReload(params)) | 3300 if (IsReload(params)) |
| 3302 document_state->set_load_type(DocumentState::RELOAD); | 3301 document_state->set_load_type(DocumentState::RELOAD); |
| 3303 else if (!params.state.empty()) | 3302 else if (params.page_state.IsValid()) |
| 3304 document_state->set_load_type(DocumentState::HISTORY_LOAD); | 3303 document_state->set_load_type(DocumentState::HISTORY_LOAD); |
| 3305 else | 3304 else |
| 3306 document_state->set_load_type(DocumentState::NORMAL_LOAD); | 3305 document_state->set_load_type(DocumentState::NORMAL_LOAD); |
| 3307 | 3306 |
| 3308 internal_data->set_referrer_policy(params.referrer.policy); | 3307 internal_data->set_referrer_policy(params.referrer.policy); |
| 3309 internal_data->set_is_overriding_user_agent(params.is_overriding_user_agent); | 3308 internal_data->set_is_overriding_user_agent(params.is_overriding_user_agent); |
| 3310 internal_data->set_must_reset_scroll_and_scale_state( | 3309 internal_data->set_must_reset_scroll_and_scale_state( |
| 3311 params.navigation_type == | 3310 params.navigation_type == |
| 3312 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); | 3311 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); |
| 3313 document_state->set_can_load_local_resources(params.can_load_local_resources); | 3312 document_state->set_can_load_local_resources(params.can_load_local_resources); |
| (...skipping 3248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6562 WebURL url = icon_urls[i].iconURL(); | 6561 WebURL url = icon_urls[i].iconURL(); |
| 6563 if (!url.isEmpty()) | 6562 if (!url.isEmpty()) |
| 6564 urls.push_back(FaviconURL(url, | 6563 urls.push_back(FaviconURL(url, |
| 6565 ToFaviconType(icon_urls[i].iconType()))); | 6564 ToFaviconType(icon_urls[i].iconType()))); |
| 6566 } | 6565 } |
| 6567 SendUpdateFaviconURL(urls); | 6566 SendUpdateFaviconURL(urls); |
| 6568 } | 6567 } |
| 6569 | 6568 |
| 6570 | 6569 |
| 6571 } // namespace content | 6570 } // namespace content |
| OLD | NEW |