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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 #include "ui/gfx/native_widget_types.h" | 194 #include "ui/gfx/native_widget_types.h" |
194 #include "ui/gfx/point.h" | 195 #include "ui/gfx/point.h" |
195 #include "ui/gfx/rect.h" | 196 #include "ui/gfx/rect.h" |
196 #include "ui/gfx/rect_conversions.h" | 197 #include "ui/gfx/rect_conversions.h" |
197 #include "ui/gfx/size_conversions.h" | 198 #include "ui/gfx/size_conversions.h" |
198 #include "ui/shell_dialogs/selected_file_info.h" | 199 #include "ui/shell_dialogs/selected_file_info.h" |
199 #include "v8/include/v8.h" | 200 #include "v8/include/v8.h" |
200 #include "webkit/appcache/web_application_cache_host_impl.h" | 201 #include "webkit/appcache/web_application_cache_host_impl.h" |
201 #include "webkit/base/file_path_string_conversions.h" | 202 #include "webkit/base/file_path_string_conversions.h" |
202 #include "webkit/dom_storage/dom_storage_types.h" | 203 #include "webkit/dom_storage/dom_storage_types.h" |
203 #include "webkit/glue/glue_serialize.h" | |
204 #include "webkit/glue/webdropdata.h" | 204 #include "webkit/glue/webdropdata.h" |
205 #include "webkit/glue/webkit_glue.h" | 205 #include "webkit/glue/webkit_glue.h" |
206 #include "webkit/glue/weburlresponse_extradata_impl.h" | 206 #include "webkit/glue/weburlresponse_extradata_impl.h" |
207 #include "webkit/media/webmediaplayer_impl.h" | 207 #include "webkit/media/webmediaplayer_impl.h" |
208 #include "webkit/media/webmediaplayer_ms.h" | 208 #include "webkit/media/webmediaplayer_ms.h" |
209 #include "webkit/media/webmediaplayer_params.h" | 209 #include "webkit/media/webmediaplayer_params.h" |
210 #include "webkit/plugins/npapi/plugin_list.h" | 210 #include "webkit/plugins/npapi/plugin_list.h" |
211 #include "webkit/plugins/npapi/plugin_utils.h" | 211 #include "webkit/plugins/npapi/plugin_utils.h" |
212 #include "webkit/plugins/npapi/webplugin_delegate.h" | 212 #include "webkit/plugins/npapi/webplugin_delegate.h" |
213 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | 213 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 bool reload_original_url = | 1227 bool reload_original_url = |
1228 (params.navigation_type == | 1228 (params.navigation_type == |
1229 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); | 1229 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); |
1230 bool ignore_cache = (params.navigation_type == | 1230 bool ignore_cache = (params.navigation_type == |
1231 ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE); | 1231 ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE); |
1232 | 1232 |
1233 if (reload_original_url) | 1233 if (reload_original_url) |
1234 frame->reloadWithOverrideURL(params.url, true); | 1234 frame->reloadWithOverrideURL(params.url, true); |
1235 else | 1235 else |
1236 frame->reload(ignore_cache); | 1236 frame->reload(ignore_cache); |
1237 } else if (!params.state.empty()) { | 1237 } else if (params.page_state.IsValid()) { |
1238 // We must know the page ID of the page we are navigating back to. | 1238 // We must know the page ID of the page we are navigating back to. |
1239 DCHECK_NE(params.page_id, -1); | 1239 DCHECK_NE(params.page_id, -1); |
1240 WebHistoryItem item = webkit_glue::HistoryItemFromString(params.state); | 1240 WebHistoryItem item = PageStateToHistoryItem(params.page_state); |
1241 if (!item.isNull()) { | 1241 if (!item.isNull()) { |
1242 // Ensure we didn't save the swapped out URL in UpdateState, since the | 1242 // Ensure we didn't save the swapped out URL in UpdateState, since the |
1243 // browser should never be telling us to navigate to swappedout://. | 1243 // browser should never be telling us to navigate to swappedout://. |
1244 CHECK(item.urlString() != WebString::fromUTF8(kSwappedOutURL)); | 1244 CHECK(item.urlString() != WebString::fromUTF8(kSwappedOutURL)); |
1245 frame->loadHistoryItem(item); | 1245 frame->loadHistoryItem(item); |
1246 } | 1246 } |
1247 } else if (!params.base_url_for_data_url.is_empty()) { | 1247 } else if (!params.base_url_for_data_url.is_empty()) { |
1248 // A loadData request with a specified base URL. | 1248 // A loadData request with a specified base URL. |
1249 std::string mime_type, charset, data; | 1249 std::string mime_type, charset, data; |
1250 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { | 1250 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1321 // In case LoadRequest failed before DidCreateDataSource was called. | 1321 // In case LoadRequest failed before DidCreateDataSource was called. |
1322 pending_navigation_params_.reset(); | 1322 pending_navigation_params_.reset(); |
1323 } | 1323 } |
1324 | 1324 |
1325 bool RenderViewImpl::IsBackForwardToStaleEntry( | 1325 bool RenderViewImpl::IsBackForwardToStaleEntry( |
1326 const ViewMsg_Navigate_Params& params, | 1326 const ViewMsg_Navigate_Params& params, |
1327 bool is_reload) { | 1327 bool is_reload) { |
1328 // Make sure this isn't a back/forward to an entry we have already cropped | 1328 // Make sure this isn't a back/forward to an entry we have already cropped |
1329 // or replaced from our history, before the browser knew about it. If so, | 1329 // or replaced from our history, before the browser knew about it. If so, |
1330 // a new navigation has committed in the mean time, and we can ignore this. | 1330 // a new navigation has committed in the mean time, and we can ignore this. |
1331 bool is_back_forward = !is_reload && !params.state.empty(); | 1331 bool is_back_forward = !is_reload && params.page_state.IsValid(); |
1332 | 1332 |
1333 // Note: if the history_list_length_ is 0 for a back/forward, we must be | 1333 // Note: if the history_list_length_ is 0 for a back/forward, we must be |
1334 // restoring from a previous session. We'll update our state in OnNavigate. | 1334 // restoring from a previous session. We'll update our state in OnNavigate. |
1335 if (!is_back_forward || history_list_length_ <= 0) | 1335 if (!is_back_forward || history_list_length_ <= 0) |
1336 return false; | 1336 return false; |
1337 | 1337 |
1338 DCHECK_EQ(static_cast<int>(history_page_ids_.size()), history_list_length_); | 1338 DCHECK_EQ(static_cast<int>(history_page_ids_.size()), history_list_length_); |
1339 | 1339 |
1340 // Check for whether the forward history has been cropped due to a recent | 1340 // Check for whether the forward history has been cropped due to a recent |
1341 // navigation the browser didn't know about. | 1341 // navigation the browser didn't know about. |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1682 | 1682 |
1683 const PasswordForm* password_form_data = document_state->password_form_data(); | 1683 const PasswordForm* password_form_data = document_state->password_form_data(); |
1684 if (password_form_data) | 1684 if (password_form_data) |
1685 params.password_form = *password_form_data; | 1685 params.password_form = *password_form_data; |
1686 | 1686 |
1687 params.gesture = navigation_gesture_; | 1687 params.gesture = navigation_gesture_; |
1688 navigation_gesture_ = NavigationGestureUnknown; | 1688 navigation_gesture_ = NavigationGestureUnknown; |
1689 | 1689 |
1690 // Make navigation state a part of the FrameNavigate message so that commited | 1690 // Make navigation state a part of the FrameNavigate message so that commited |
1691 // entry had it at all times. | 1691 // entry had it at all times. |
1692 const WebHistoryItem& item = frame->currentHistoryItem(); | 1692 WebHistoryItem item = frame->currentHistoryItem(); |
1693 if (!item.isNull()) { | 1693 if (item.isNull()) { |
1694 params.content_state = webkit_glue::HistoryItemToString(item); | 1694 item.initialize(); |
1695 } else { | 1695 item.setURLString(request.url().spec().utf16()); |
1696 params.content_state = | |
1697 webkit_glue::CreateHistoryStateForURL(GURL(request.url())); | |
1698 } | 1696 } |
| 1697 params.page_state = HistoryItemToPageState(item); |
1699 | 1698 |
1700 if (!frame->parent()) { | 1699 if (!frame->parent()) { |
1701 // Top-level navigation. | 1700 // Top-level navigation. |
1702 | 1701 |
1703 // Reset the zoom limits in case a plugin had changed them previously. This | 1702 // Reset the zoom limits in case a plugin had changed them previously. This |
1704 // will also call us back which will cause us to send a message to | 1703 // will also call us back which will cause us to send a message to |
1705 // update WebContentsImpl. | 1704 // update WebContentsImpl. |
1706 webview()->zoomLimitsChanged( | 1705 webview()->zoomLimitsChanged( |
1707 WebView::zoomFactorToZoomLevel(kMinimumZoomFactor), | 1706 WebView::zoomFactorToZoomLevel(kMinimumZoomFactor), |
1708 WebView::zoomFactorToZoomLevel(kMaximumZoomFactor)); | 1707 WebView::zoomFactorToZoomLevel(kMaximumZoomFactor)); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1853 | 1852 |
1854 void RenderViewImpl::SendUpdateState(const WebHistoryItem& item) { | 1853 void RenderViewImpl::SendUpdateState(const WebHistoryItem& item) { |
1855 if (item.isNull()) | 1854 if (item.isNull()) |
1856 return; | 1855 return; |
1857 | 1856 |
1858 // Don't send state updates for kSwappedOutURL. | 1857 // Don't send state updates for kSwappedOutURL. |
1859 if (item.urlString() == WebString::fromUTF8(kSwappedOutURL)) | 1858 if (item.urlString() == WebString::fromUTF8(kSwappedOutURL)) |
1860 return; | 1859 return; |
1861 | 1860 |
1862 Send(new ViewHostMsg_UpdateState( | 1861 Send(new ViewHostMsg_UpdateState( |
1863 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); | 1862 routing_id_, page_id_, HistoryItemToPageState(item))); |
1864 } | 1863 } |
1865 | 1864 |
1866 void RenderViewImpl::OpenURL(WebFrame* frame, | 1865 void RenderViewImpl::OpenURL(WebFrame* frame, |
1867 const GURL& url, | 1866 const GURL& url, |
1868 const Referrer& referrer, | 1867 const Referrer& referrer, |
1869 WebNavigationPolicy policy) { | 1868 WebNavigationPolicy policy) { |
1870 ViewHostMsg_OpenURL_Params params; | 1869 ViewHostMsg_OpenURL_Params params; |
1871 params.url = url; | 1870 params.url = url; |
1872 params.referrer = referrer; | 1871 params.referrer = referrer; |
1873 params.disposition = NavigationPolicyToDisposition(policy); | 1872 params.disposition = NavigationPolicyToDisposition(policy); |
(...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3300 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which | 3299 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which |
3301 // can result in stale data for pages that are set to expire. We explicitly | 3300 // can result in stale data for pages that are set to expire. We explicitly |
3302 // override that by setting the policy here so that as necessary we load | 3301 // override that by setting the policy here so that as necessary we load |
3303 // from the network. | 3302 // from the network. |
3304 internal_data->set_cache_policy_override( | 3303 internal_data->set_cache_policy_override( |
3305 WebURLRequest::UseProtocolCachePolicy); | 3304 WebURLRequest::UseProtocolCachePolicy); |
3306 } | 3305 } |
3307 | 3306 |
3308 if (IsReload(params)) | 3307 if (IsReload(params)) |
3309 document_state->set_load_type(DocumentState::RELOAD); | 3308 document_state->set_load_type(DocumentState::RELOAD); |
3310 else if (!params.state.empty()) | 3309 else if (params.page_state.IsValid()) |
3311 document_state->set_load_type(DocumentState::HISTORY_LOAD); | 3310 document_state->set_load_type(DocumentState::HISTORY_LOAD); |
3312 else | 3311 else |
3313 document_state->set_load_type(DocumentState::NORMAL_LOAD); | 3312 document_state->set_load_type(DocumentState::NORMAL_LOAD); |
3314 | 3313 |
3315 internal_data->set_referrer_policy(params.referrer.policy); | 3314 internal_data->set_referrer_policy(params.referrer.policy); |
3316 internal_data->set_is_overriding_user_agent(params.is_overriding_user_agent); | 3315 internal_data->set_is_overriding_user_agent(params.is_overriding_user_agent); |
3317 internal_data->set_must_reset_scroll_and_scale_state( | 3316 internal_data->set_must_reset_scroll_and_scale_state( |
3318 params.navigation_type == | 3317 params.navigation_type == |
3319 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); | 3318 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); |
3320 document_state->set_can_load_local_resources(params.can_load_local_resources); | 3319 document_state->set_can_load_local_resources(params.can_load_local_resources); |
(...skipping 3256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6577 WebURL url = icon_urls[i].iconURL(); | 6576 WebURL url = icon_urls[i].iconURL(); |
6578 if (!url.isEmpty()) | 6577 if (!url.isEmpty()) |
6579 urls.push_back(FaviconURL(url, | 6578 urls.push_back(FaviconURL(url, |
6580 ToFaviconType(icon_urls[i].iconType()))); | 6579 ToFaviconType(icon_urls[i].iconType()))); |
6581 } | 6580 } |
6582 SendUpdateFaviconURL(urls); | 6581 SendUpdateFaviconURL(urls); |
6583 } | 6582 } |
6584 | 6583 |
6585 | 6584 |
6586 } // namespace content | 6585 } // namespace content |
OLD | NEW |