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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
392 ds->redirectChain(urls); | 392 ds->redirectChain(urls); |
393 result->reserve(urls.size()); | 393 result->reserve(urls.size()); |
394 for (size_t i = 0; i < urls.size(); ++i) { | 394 for (size_t i = 0; i < urls.size(); ++i) { |
395 if (urls[i] != GURL(kSwappedOutURL)) | 395 if (urls[i] != GURL(kSwappedOutURL)) |
396 result->push_back(urls[i]); | 396 result->push_back(urls[i]); |
397 else | 397 else |
398 result->push_back(blank_url); | 398 result->push_back(blank_url); |
399 } | 399 } |
400 } | 400 } |
401 | 401 |
402 // If |data_source| is non-null and has a DocumentState associated with it, | 402 // If |data_source| is non-null and has an InternalDocumentStateData associated |
403 // the AltErrorPageResourceFetcher is reset. | 403 // with it, the AltErrorPageResourceFetcher is reset. |
404 static void StopAltErrorPageFetcher(WebDataSource* data_source) { | 404 static void StopAltErrorPageFetcher(WebDataSource* data_source) { |
405 if (data_source) { | 405 if (data_source) { |
406 DocumentState* document_state = DocumentState::FromDataSource(data_source); | 406 InternalDocumentStateData* internal_data = |
407 if (document_state) | 407 InternalDocumentStateData::FromDataSource(data_source); |
408 document_state->set_alt_error_page_fetcher(NULL); | 408 if (internal_data) |
409 internal_data->set_alt_error_page_fetcher(NULL); | |
409 } | 410 } |
410 } | 411 } |
411 | 412 |
412 static bool IsReload(const ViewMsg_Navigate_Params& params) { | 413 static bool IsReload(const ViewMsg_Navigate_Params& params) { |
413 return | 414 return |
414 params.navigation_type == ViewMsg_Navigate_Type::RELOAD || | 415 params.navigation_type == ViewMsg_Navigate_Type::RELOAD || |
415 params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE || | 416 params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE || |
416 params.navigation_type == | 417 params.navigation_type == |
417 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; | 418 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; |
418 } | 419 } |
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1604 void RenderViewImpl::UpdateURL(WebFrame* frame) { | 1605 void RenderViewImpl::UpdateURL(WebFrame* frame) { |
1605 WebDataSource* ds = frame->dataSource(); | 1606 WebDataSource* ds = frame->dataSource(); |
1606 DCHECK(ds); | 1607 DCHECK(ds); |
1607 | 1608 |
1608 const WebURLRequest& request = ds->request(); | 1609 const WebURLRequest& request = ds->request(); |
1609 const WebURLRequest& original_request = ds->originalRequest(); | 1610 const WebURLRequest& original_request = ds->originalRequest(); |
1610 const WebURLResponse& response = ds->response(); | 1611 const WebURLResponse& response = ds->response(); |
1611 | 1612 |
1612 DocumentState* document_state = DocumentState::FromDataSource(ds); | 1613 DocumentState* document_state = DocumentState::FromDataSource(ds); |
1613 NavigationState* navigation_state = document_state->navigation_state(); | 1614 NavigationState* navigation_state = document_state->navigation_state(); |
1615 InternalDocumentStateData* internal_data = | |
1616 InternalDocumentStateData::FromDocumentState(document_state); | |
1614 | 1617 |
1615 ViewHostMsg_FrameNavigate_Params params; | 1618 ViewHostMsg_FrameNavigate_Params params; |
1616 params.http_status_code = response.httpStatusCode(); | 1619 params.http_status_code = response.httpStatusCode(); |
1617 params.is_post = false; | 1620 params.is_post = false; |
1618 params.post_id = -1; | 1621 params.post_id = -1; |
1619 params.page_id = page_id_; | 1622 params.page_id = page_id_; |
1620 params.frame_id = frame->identifier(); | 1623 params.frame_id = frame->identifier(); |
1621 params.socket_address.set_host(response.remoteIPAddress().utf8()); | 1624 params.socket_address.set_host(response.remoteIPAddress().utf8()); |
1622 params.socket_address.set_port(response.remotePort()); | 1625 params.socket_address.set_port(response.remotePort()); |
1623 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse(response); | 1626 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse(response); |
1624 if (extra_data) { | 1627 if (extra_data) { |
1625 params.was_fetched_via_proxy = extra_data->was_fetched_via_proxy(); | 1628 params.was_fetched_via_proxy = extra_data->was_fetched_via_proxy(); |
1626 } | 1629 } |
1627 params.was_within_same_page = navigation_state->was_within_same_page(); | 1630 params.was_within_same_page = navigation_state->was_within_same_page(); |
1628 if (!document_state->security_info().empty()) { | 1631 params.security_info = response.securityInfo(); |
sky
2013/04/08 16:53:49
I removed scurity_info entirely as it didn't appea
| |
1629 // SSL state specified in the request takes precedence over the one in the | |
1630 // response. | |
1631 // So far this is only intended for error pages that are not expected to be | |
1632 // over ssl, so we should not get any clash. | |
1633 DCHECK(response.securityInfo().isEmpty()); | |
1634 params.security_info = document_state->security_info(); | |
1635 } else { | |
1636 params.security_info = response.securityInfo(); | |
1637 } | |
1638 | 1632 |
1639 // Set the URL to be displayed in the browser UI to the user. | 1633 // Set the URL to be displayed in the browser UI to the user. |
1640 params.url = GetLoadingUrl(frame); | 1634 params.url = GetLoadingUrl(frame); |
1641 DCHECK(!is_swapped_out_ || params.url == GURL(kSwappedOutURL)); | 1635 DCHECK(!is_swapped_out_ || params.url == GURL(kSwappedOutURL)); |
1642 | 1636 |
1643 if (frame->document().baseURL() != params.url) | 1637 if (frame->document().baseURL() != params.url) |
1644 params.base_url = frame->document().baseURL(); | 1638 params.base_url = frame->document().baseURL(); |
1645 | 1639 |
1646 GetRedirectChain(ds, ¶ms.redirects); | 1640 GetRedirectChain(ds, ¶ms.redirects); |
1647 params.should_update_history = !ds->hasUnreachableURL() && | 1641 params.should_update_history = !ds->hasUnreachableURL() && |
1648 !response.isMultipartPayload() && (response.httpStatusCode() != 404); | 1642 !response.isMultipartPayload() && (response.httpStatusCode() != 404); |
1649 | 1643 |
1650 params.searchable_form_url = document_state->searchable_form_url(); | 1644 params.searchable_form_url = internal_data->searchable_form_url(); |
1651 params.searchable_form_encoding = | 1645 params.searchable_form_encoding = internal_data->searchable_form_encoding(); |
1652 document_state->searchable_form_encoding(); | |
1653 | 1646 |
1654 const PasswordForm* password_form_data = | 1647 const PasswordForm* password_form_data = document_state->password_form_data(); |
1655 document_state->password_form_data(); | |
1656 if (password_form_data) | 1648 if (password_form_data) |
1657 params.password_form = *password_form_data; | 1649 params.password_form = *password_form_data; |
1658 | 1650 |
1659 params.gesture = navigation_gesture_; | 1651 params.gesture = navigation_gesture_; |
1660 navigation_gesture_ = NavigationGestureUnknown; | 1652 navigation_gesture_ = NavigationGestureUnknown; |
1661 | 1653 |
1662 // Make navigation state a part of the FrameNavigate message so that commited | 1654 // Make navigation state a part of the FrameNavigate message so that commited |
1663 // entry had it at all times. | 1655 // entry had it at all times. |
1664 const WebHistoryItem& item = frame->currentHistoryItem(); | 1656 const WebHistoryItem& item = frame->currentHistoryItem(); |
1665 if (!item.isNull()) { | 1657 if (!item.isNull()) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1733 GetReferrerPolicyFromRequest(frame, original_request)); | 1725 GetReferrerPolicyFromRequest(frame, original_request)); |
1734 } | 1726 } |
1735 | 1727 |
1736 string16 method = request.httpMethod(); | 1728 string16 method = request.httpMethod(); |
1737 if (EqualsASCII(method, "POST")) { | 1729 if (EqualsASCII(method, "POST")) { |
1738 params.is_post = true; | 1730 params.is_post = true; |
1739 params.post_id = ExtractPostId(item); | 1731 params.post_id = ExtractPostId(item); |
1740 } | 1732 } |
1741 | 1733 |
1742 // Send the user agent override back. | 1734 // Send the user agent override back. |
1743 params.is_overriding_user_agent = | 1735 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); |
1744 document_state->is_overriding_user_agent(); | |
1745 | 1736 |
1746 // Track the URL of the original request. | 1737 // Track the URL of the original request. |
1747 params.original_request_url = original_request.url(); | 1738 params.original_request_url = original_request.url(); |
1748 | 1739 |
1749 // Save some histogram data so we can compute the average memory used per | 1740 // Save some histogram data so we can compute the average memory used per |
1750 // page load of the glyphs. | 1741 // page load of the glyphs. |
1751 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", | 1742 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", |
1752 webkit_glue::GetGlyphPageCount()); | 1743 webkit_glue::GetGlyphPageCount()); |
1753 | 1744 |
1754 // This message needs to be sent before any of allowScripts(), | 1745 // This message needs to be sent before any of allowScripts(), |
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2834 EditCommands edit_commands; | 2825 EditCommands edit_commands; |
2835 edit_commands.push_back(EditCommand(name, value)); | 2826 edit_commands.push_back(EditCommand(name, value)); |
2836 OnSetEditCommandsForNextKeyEvent(edit_commands); | 2827 OnSetEditCommandsForNextKeyEvent(edit_commands); |
2837 } | 2828 } |
2838 | 2829 |
2839 void RenderViewImpl::ClearEditCommands() { | 2830 void RenderViewImpl::ClearEditCommands() { |
2840 edit_commands_.clear(); | 2831 edit_commands_.clear(); |
2841 } | 2832 } |
2842 | 2833 |
2843 SSLStatus RenderViewImpl::GetSSLStatusOfFrame(WebKit::WebFrame* frame) const { | 2834 SSLStatus RenderViewImpl::GetSSLStatusOfFrame(WebKit::WebFrame* frame) const { |
2844 SSLStatus ssl_status; | 2835 return SSLStatus(); |
Dan Beam
2013/07/03 17:44:36
what is the point of this method now?
| |
2845 | |
2846 DocumentState* doc_state = DocumentState::FromDataSource(frame->dataSource()); | |
2847 if (doc_state && !doc_state->security_info().empty()) { | |
2848 DeserializeSecurityInfo(doc_state->security_info(), | |
2849 &ssl_status.cert_id, | |
2850 &ssl_status.cert_status, | |
2851 &ssl_status.security_bits, | |
2852 &ssl_status.connection_status); | |
2853 } | |
2854 | |
2855 return ssl_status; | |
2856 } | 2836 } |
2857 | 2837 |
2858 void RenderViewImpl::loadURLExternally( | 2838 void RenderViewImpl::loadURLExternally( |
2859 WebFrame* frame, const WebURLRequest& request, | 2839 WebFrame* frame, const WebURLRequest& request, |
2860 WebNavigationPolicy policy, | 2840 WebNavigationPolicy policy, |
2861 const WebString& suggested_name) { | 2841 const WebString& suggested_name) { |
2862 Referrer referrer( | 2842 Referrer referrer( |
2863 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), | 2843 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), |
2864 GetReferrerPolicyFromRequest(frame, request)); | 2844 GetReferrerPolicyFromRequest(frame, request)); |
2865 if (policy == WebKit::WebNavigationPolicyDownload) { | 2845 if (policy == WebKit::WebNavigationPolicyDownload) { |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3103 DocumentState* document_state = | 3083 DocumentState* document_state = |
3104 DocumentState::FromDataSource(frame->dataSource()); | 3084 DocumentState::FromDataSource(frame->dataSource()); |
3105 document_state->set_password_form_data(CreatePasswordForm(form)); | 3085 document_state->set_password_form_data(CreatePasswordForm(form)); |
3106 } | 3086 } |
3107 | 3087 |
3108 void RenderViewImpl::willSubmitForm(WebFrame* frame, | 3088 void RenderViewImpl::willSubmitForm(WebFrame* frame, |
3109 const WebFormElement& form) { | 3089 const WebFormElement& form) { |
3110 DocumentState* document_state = | 3090 DocumentState* document_state = |
3111 DocumentState::FromDataSource(frame->provisionalDataSource()); | 3091 DocumentState::FromDataSource(frame->provisionalDataSource()); |
3112 NavigationState* navigation_state = document_state->navigation_state(); | 3092 NavigationState* navigation_state = document_state->navigation_state(); |
3093 InternalDocumentStateData* internal_data = | |
3094 InternalDocumentStateData::FromDocumentState(document_state); | |
3113 | 3095 |
3114 if (navigation_state->transition_type() == PAGE_TRANSITION_LINK) | 3096 if (navigation_state->transition_type() == PAGE_TRANSITION_LINK) |
3115 navigation_state->set_transition_type(PAGE_TRANSITION_FORM_SUBMIT); | 3097 navigation_state->set_transition_type(PAGE_TRANSITION_FORM_SUBMIT); |
3116 | 3098 |
3117 // Save these to be processed when the ensuing navigation is committed. | 3099 // Save these to be processed when the ensuing navigation is committed. |
3118 WebSearchableFormData web_searchable_form_data(form); | 3100 WebSearchableFormData web_searchable_form_data(form); |
3119 document_state->set_searchable_form_url(web_searchable_form_data.url()); | 3101 internal_data->set_searchable_form_url(web_searchable_form_data.url()); |
3120 document_state->set_searchable_form_encoding( | 3102 internal_data->set_searchable_form_encoding( |
3121 web_searchable_form_data.encoding().utf8()); | 3103 web_searchable_form_data.encoding().utf8()); |
3122 scoped_ptr<PasswordForm> password_form_data = | 3104 scoped_ptr<PasswordForm> password_form_data = |
3123 CreatePasswordForm(form); | 3105 CreatePasswordForm(form); |
3124 | 3106 |
3125 // In order to save the password that the user actually typed and not one | 3107 // In order to save the password that the user actually typed and not one |
3126 // that may have gotten transformed by the site prior to submit, recover it | 3108 // that may have gotten transformed by the site prior to submit, recover it |
3127 // from the form contents already stored by |willSendSubmitEvent| into the | 3109 // from the form contents already stored by |willSendSubmitEvent| into the |
3128 // dataSource's NavigationState (as opposed to the provisionalDataSource's, | 3110 // dataSource's NavigationState (as opposed to the provisionalDataSource's, |
3129 // which is what we're storing into now.) | 3111 // which is what we're storing into now.) |
3130 if (password_form_data.get()) { | 3112 if (password_form_data.get()) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3189 if (!content_initiated) | 3171 if (!content_initiated) |
3190 PopulateDocumentStateFromPending(document_state); | 3172 PopulateDocumentStateFromPending(document_state); |
3191 } | 3173 } |
3192 | 3174 |
3193 // Carry over the user agent override flag, if it exists. | 3175 // Carry over the user agent override flag, if it exists. |
3194 if (content_initiated && webview() && webview()->mainFrame() && | 3176 if (content_initiated && webview() && webview()->mainFrame() && |
3195 webview()->mainFrame()->dataSource()) { | 3177 webview()->mainFrame()->dataSource()) { |
3196 DocumentState* old_document_state = | 3178 DocumentState* old_document_state = |
3197 DocumentState::FromDataSource(webview()->mainFrame()->dataSource()); | 3179 DocumentState::FromDataSource(webview()->mainFrame()->dataSource()); |
3198 if (old_document_state) { | 3180 if (old_document_state) { |
3199 document_state->set_is_overriding_user_agent( | 3181 InternalDocumentStateData* internal_data = |
3200 old_document_state->is_overriding_user_agent()); | 3182 InternalDocumentStateData::FromDocumentState(document_state); |
3183 InternalDocumentStateData* old_internal_data = | |
3184 InternalDocumentStateData::FromDocumentState(old_document_state); | |
3185 internal_data->set_is_overriding_user_agent( | |
3186 old_internal_data->is_overriding_user_agent()); | |
3201 } | 3187 } |
3202 } | 3188 } |
3203 | 3189 |
3204 // The rest of RenderView assumes that a WebDataSource will always have a | 3190 // The rest of RenderView assumes that a WebDataSource will always have a |
3205 // non-null NavigationState. | 3191 // non-null NavigationState. |
3206 if (content_initiated) { | 3192 if (content_initiated) { |
3207 document_state->set_navigation_state( | 3193 document_state->set_navigation_state( |
3208 NavigationState::CreateContentInitiated()); | 3194 NavigationState::CreateContentInitiated()); |
3209 } else { | 3195 } else { |
3210 document_state->set_navigation_state(CreateNavigationStateFromPending()); | 3196 document_state->set_navigation_state(CreateNavigationStateFromPending()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3258 | 3244 |
3259 FOR_EACH_OBSERVER( | 3245 FOR_EACH_OBSERVER( |
3260 RenderViewObserver, observers_, DidCreateDataSource(frame, ds)); | 3246 RenderViewObserver, observers_, DidCreateDataSource(frame, ds)); |
3261 } | 3247 } |
3262 | 3248 |
3263 void RenderViewImpl::PopulateDocumentStateFromPending( | 3249 void RenderViewImpl::PopulateDocumentStateFromPending( |
3264 DocumentState* document_state) { | 3250 DocumentState* document_state) { |
3265 const ViewMsg_Navigate_Params& params = *pending_navigation_params_.get(); | 3251 const ViewMsg_Navigate_Params& params = *pending_navigation_params_.get(); |
3266 document_state->set_request_time(params.request_time); | 3252 document_state->set_request_time(params.request_time); |
3267 | 3253 |
3254 InternalDocumentStateData* internal_data = | |
3255 InternalDocumentStateData::FromDocumentState(document_state); | |
3256 | |
3268 if (!params.url.SchemeIs(chrome::kJavaScriptScheme) && | 3257 if (!params.url.SchemeIs(chrome::kJavaScriptScheme) && |
3269 params.navigation_type == ViewMsg_Navigate_Type::RESTORE) { | 3258 params.navigation_type == ViewMsg_Navigate_Type::RESTORE) { |
3270 // We're doing a load of a page that was restored from the last session. By | 3259 // We're doing a load of a page that was restored from the last session. By |
3271 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which | 3260 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which |
3272 // can result in stale data for pages that are set to expire. We explicitly | 3261 // can result in stale data for pages that are set to expire. We explicitly |
3273 // override that by setting the policy here so that as necessary we load | 3262 // override that by setting the policy here so that as necessary we load |
3274 // from the network. | 3263 // from the network. |
3275 document_state->set_cache_policy_override( | 3264 internal_data->set_cache_policy_override( |
3276 WebURLRequest::UseProtocolCachePolicy); | 3265 WebURLRequest::UseProtocolCachePolicy); |
3277 } | 3266 } |
3278 | 3267 |
3279 if (IsReload(params)) | 3268 if (IsReload(params)) |
3280 document_state->set_load_type(DocumentState::RELOAD); | 3269 document_state->set_load_type(DocumentState::RELOAD); |
3281 else if (!params.state.empty()) | 3270 else if (!params.state.empty()) |
3282 document_state->set_load_type(DocumentState::HISTORY_LOAD); | 3271 document_state->set_load_type(DocumentState::HISTORY_LOAD); |
3283 else | 3272 else |
3284 document_state->set_load_type(DocumentState::NORMAL_LOAD); | 3273 document_state->set_load_type(DocumentState::NORMAL_LOAD); |
3285 | 3274 |
3286 document_state->set_referrer_policy(params.referrer.policy); | 3275 internal_data->set_referrer_policy(params.referrer.policy); |
3287 document_state->set_is_overriding_user_agent(params.is_overriding_user_agent); | 3276 internal_data->set_is_overriding_user_agent(params.is_overriding_user_agent); |
3288 document_state->set_must_reset_scroll_and_scale_state( | 3277 internal_data->set_must_reset_scroll_and_scale_state( |
3289 params.navigation_type == | 3278 params.navigation_type == |
3290 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); | 3279 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); |
3291 document_state->set_can_load_local_resources(params.can_load_local_resources); | 3280 document_state->set_can_load_local_resources(params.can_load_local_resources); |
3292 } | 3281 } |
3293 | 3282 |
3294 NavigationState* RenderViewImpl::CreateNavigationStateFromPending() { | 3283 NavigationState* RenderViewImpl::CreateNavigationStateFromPending() { |
3295 const ViewMsg_Navigate_Params& params = *pending_navigation_params_.get(); | 3284 const ViewMsg_Navigate_Params& params = *pending_navigation_params_.get(); |
3296 NavigationState* navigation_state = NULL; | 3285 NavigationState* navigation_state = NULL; |
3297 | 3286 |
3298 // A navigation resulting from loading a javascript URL should not be treated | 3287 // A navigation resulting from loading a javascript URL should not be treated |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3510 if (MaybeLoadAlternateErrorPage(frame, error, replace)) | 3499 if (MaybeLoadAlternateErrorPage(frame, error, replace)) |
3511 return; | 3500 return; |
3512 | 3501 |
3513 // Fallback to a local error page. | 3502 // Fallback to a local error page. |
3514 LoadNavigationErrorPage(frame, failed_request, error, std::string(), replace); | 3503 LoadNavigationErrorPage(frame, failed_request, error, std::string(), replace); |
3515 } | 3504 } |
3516 | 3505 |
3517 void RenderViewImpl::didReceiveDocumentData( | 3506 void RenderViewImpl::didReceiveDocumentData( |
3518 WebFrame* frame, const char* data, size_t data_len, | 3507 WebFrame* frame, const char* data, size_t data_len, |
3519 bool& prevent_default) { | 3508 bool& prevent_default) { |
3520 DocumentState* document_state = | 3509 InternalDocumentStateData* internal_data = |
3521 DocumentState::FromDataSource(frame->dataSource()); | 3510 InternalDocumentStateData::FromDataSource(frame->dataSource()); |
3522 document_state->set_use_error_page(false); | 3511 internal_data->set_use_error_page(false); |
3523 } | 3512 } |
3524 | 3513 |
3525 void RenderViewImpl::didCommitProvisionalLoad(WebFrame* frame, | 3514 void RenderViewImpl::didCommitProvisionalLoad(WebFrame* frame, |
3526 bool is_new_navigation) { | 3515 bool is_new_navigation) { |
3527 DocumentState* document_state = | 3516 DocumentState* document_state = |
3528 DocumentState::FromDataSource(frame->dataSource()); | 3517 DocumentState::FromDataSource(frame->dataSource()); |
3529 NavigationState* navigation_state = document_state->navigation_state(); | 3518 NavigationState* navigation_state = document_state->navigation_state(); |
3519 InternalDocumentStateData* internal_data = | |
3520 InternalDocumentStateData::FromDocumentState(document_state); | |
3530 | 3521 |
3531 if (document_state->commit_load_time().is_null()) | 3522 if (document_state->commit_load_time().is_null()) |
3532 document_state->set_commit_load_time(Time::Now()); | 3523 document_state->set_commit_load_time(Time::Now()); |
3533 | 3524 |
3534 if (document_state->must_reset_scroll_and_scale_state()) { | 3525 if (internal_data->must_reset_scroll_and_scale_state()) { |
3535 webview()->resetScrollAndScaleState(); | 3526 webview()->resetScrollAndScaleState(); |
3536 document_state->set_must_reset_scroll_and_scale_state(false); | 3527 internal_data->set_must_reset_scroll_and_scale_state(false); |
3537 } | 3528 } |
3538 | 3529 |
3539 if (is_new_navigation) { | 3530 if (is_new_navigation) { |
3540 // When we perform a new navigation, we need to update the last committed | 3531 // When we perform a new navigation, we need to update the last committed |
3541 // session history entry with state for the page we are leaving. | 3532 // session history entry with state for the page we are leaving. |
3542 UpdateSessionHistory(frame); | 3533 UpdateSessionHistory(frame); |
3543 | 3534 |
3544 // We bump our Page ID to correspond with the new session history entry. | 3535 // We bump our Page ID to correspond with the new session history entry. |
3545 page_id_ = next_page_id_++; | 3536 page_id_ = next_page_id_++; |
3546 | 3537 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3771 if (!top_frame) | 3762 if (!top_frame) |
3772 top_frame = frame; | 3763 top_frame = frame; |
3773 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); | 3764 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); |
3774 WebDataSource* top_data_source = top_frame->dataSource(); | 3765 WebDataSource* top_data_source = top_frame->dataSource(); |
3775 WebDataSource* data_source = | 3766 WebDataSource* data_source = |
3776 provisional_data_source ? provisional_data_source : top_data_source; | 3767 provisional_data_source ? provisional_data_source : top_data_source; |
3777 | 3768 |
3778 PageTransition transition_type = PAGE_TRANSITION_LINK; | 3769 PageTransition transition_type = PAGE_TRANSITION_LINK; |
3779 DocumentState* document_state = DocumentState::FromDataSource(data_source); | 3770 DocumentState* document_state = DocumentState::FromDataSource(data_source); |
3780 DCHECK(document_state); | 3771 DCHECK(document_state); |
3772 InternalDocumentStateData* internal_data = | |
3773 InternalDocumentStateData::FromDocumentState(document_state); | |
3781 NavigationState* navigation_state = document_state->navigation_state(); | 3774 NavigationState* navigation_state = document_state->navigation_state(); |
3782 transition_type = navigation_state->transition_type(); | 3775 transition_type = navigation_state->transition_type(); |
3783 | 3776 |
3784 GURL request_url(request.url()); | 3777 GURL request_url(request.url()); |
3785 GURL new_url; | 3778 GURL new_url; |
3786 if (GetContentClient()->renderer()->WillSendRequest( | 3779 if (GetContentClient()->renderer()->WillSendRequest( |
3787 frame, | 3780 frame, |
3788 transition_type, | 3781 transition_type, |
3789 request_url, | 3782 request_url, |
3790 request.firstPartyForCookies(), | 3783 request.firstPartyForCookies(), |
3791 &new_url)) { | 3784 &new_url)) { |
3792 request.setURL(WebURL(new_url)); | 3785 request.setURL(WebURL(new_url)); |
3793 } | 3786 } |
3794 | 3787 |
3795 if (document_state->is_cache_policy_override_set()) | 3788 if (internal_data->is_cache_policy_override_set()) |
3796 request.setCachePolicy(document_state->cache_policy_override()); | 3789 request.setCachePolicy(internal_data->cache_policy_override()); |
3797 | 3790 |
3798 WebKit::WebReferrerPolicy referrer_policy; | 3791 WebKit::WebReferrerPolicy referrer_policy; |
3799 if (document_state && document_state->is_referrer_policy_set()) { | 3792 if (internal_data->is_referrer_policy_set()) { |
3800 referrer_policy = document_state->referrer_policy(); | 3793 referrer_policy = internal_data->referrer_policy(); |
3801 document_state->clear_referrer_policy(); | 3794 internal_data->clear_referrer_policy(); |
3802 } else { | 3795 } else { |
3803 referrer_policy = frame->document().referrerPolicy(); | 3796 referrer_policy = frame->document().referrerPolicy(); |
3804 } | 3797 } |
3805 | 3798 |
3806 // The request's extra data may indicate that we should set a custom user | 3799 // The request's extra data may indicate that we should set a custom user |
3807 // agent. This needs to be done here, after WebKit is through with setting the | 3800 // agent. This needs to be done here, after WebKit is through with setting the |
3808 // user agent on its own. | 3801 // user agent on its own. |
3809 WebString custom_user_agent; | 3802 WebString custom_user_agent; |
3810 if (request.extraData()) { | 3803 if (request.extraData()) { |
3811 webkit_glue::WebURLRequestExtraDataImpl* old_extra_data = | 3804 webkit_glue::WebURLRequestExtraDataImpl* old_extra_data = |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3884 extra_data->was_fetched_via_spdy()); | 3877 extra_data->was_fetched_via_spdy()); |
3885 document_state->set_was_npn_negotiated( | 3878 document_state->set_was_npn_negotiated( |
3886 extra_data->was_npn_negotiated()); | 3879 extra_data->was_npn_negotiated()); |
3887 document_state->set_npn_negotiated_protocol( | 3880 document_state->set_npn_negotiated_protocol( |
3888 extra_data->npn_negotiated_protocol()); | 3881 extra_data->npn_negotiated_protocol()); |
3889 document_state->set_was_alternate_protocol_available( | 3882 document_state->set_was_alternate_protocol_available( |
3890 extra_data->was_alternate_protocol_available()); | 3883 extra_data->was_alternate_protocol_available()); |
3891 document_state->set_was_fetched_via_proxy( | 3884 document_state->set_was_fetched_via_proxy( |
3892 extra_data->was_fetched_via_proxy()); | 3885 extra_data->was_fetched_via_proxy()); |
3893 } | 3886 } |
3894 document_state->set_http_status_code(http_status_code); | 3887 InternalDocumentStateData* internal_data = |
3888 InternalDocumentStateData::FromDocumentState(document_state); | |
3889 internal_data->set_http_status_code(http_status_code); | |
3895 // Whether or not the http status code actually corresponds to an error is | 3890 // Whether or not the http status code actually corresponds to an error is |
3896 // only checked when the page is done loading, if |use_error_page| is | 3891 // only checked when the page is done loading, if |use_error_page| is |
3897 // still true. | 3892 // still true. |
3898 document_state->set_use_error_page(true); | 3893 internal_data->set_use_error_page(true); |
3899 } | 3894 } |
3900 | 3895 |
3901 void RenderViewImpl::didFinishResourceLoad( | 3896 void RenderViewImpl::didFinishResourceLoad( |
3902 WebFrame* frame, unsigned identifier) { | 3897 WebFrame* frame, unsigned identifier) { |
3903 DocumentState* document_state = | 3898 InternalDocumentStateData* internal_data = |
3904 DocumentState::FromDataSource(frame->dataSource()); | 3899 InternalDocumentStateData::FromDataSource(frame->dataSource()); |
3905 if (!document_state->use_error_page()) | 3900 if (!internal_data->use_error_page()) |
3906 return; | 3901 return; |
3907 | 3902 |
3908 // Do not show error page when DevTools is attached. | 3903 // Do not show error page when DevTools is attached. |
3909 if (devtools_agent_->IsAttached()) | 3904 if (devtools_agent_->IsAttached()) |
3910 return; | 3905 return; |
3911 | 3906 |
3912 // Display error page, if appropriate. | 3907 // Display error page, if appropriate. |
3913 int http_status_code = document_state->http_status_code(); | 3908 int http_status_code = internal_data->http_status_code(); |
3914 if (http_status_code == 404) { | 3909 if (http_status_code == 404) { |
3915 // On 404s, try a remote search page as a fallback. | 3910 // On 404s, try a remote search page as a fallback. |
3916 const GURL& document_url = frame->document().url(); | 3911 const GURL& document_url = frame->document().url(); |
3917 | 3912 |
3918 const GURL& error_page_url = | 3913 const GURL& error_page_url = |
3919 GetAlternateErrorPageURL(document_url, HTTP_404); | 3914 GetAlternateErrorPageURL(document_url, HTTP_404); |
3920 if (error_page_url.is_valid()) { | 3915 if (error_page_url.is_valid()) { |
3921 WebURLError original_error; | 3916 WebURLError original_error; |
3922 original_error.domain = "http"; | 3917 original_error.domain = "http"; |
3923 original_error.reason = 404; | 3918 original_error.reason = 404; |
3924 original_error.unreachableURL = document_url; | 3919 original_error.unreachableURL = document_url; |
3925 | 3920 |
3926 document_state->set_alt_error_page_fetcher( | 3921 internal_data->set_alt_error_page_fetcher( |
3927 new AltErrorPageResourceFetcher( | 3922 new AltErrorPageResourceFetcher( |
3928 error_page_url, frame, original_error, | 3923 error_page_url, frame, original_error, |
3929 base::Bind(&RenderViewImpl::AltErrorPageFinished, | 3924 base::Bind(&RenderViewImpl::AltErrorPageFinished, |
3930 base::Unretained(this)))); | 3925 base::Unretained(this)))); |
3931 return; | 3926 return; |
3932 } | 3927 } |
3933 } | 3928 } |
3934 | 3929 |
3935 std::string error_domain; | 3930 std::string error_domain; |
3936 if (GetContentClient()->renderer()->HasErrorPage( | 3931 if (GetContentClient()->renderer()->HasErrorPage( |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4393 | 4388 |
4394 // If we're in the middle of committing a load, the data source we need | 4389 // If we're in the middle of committing a load, the data source we need |
4395 // will still be provisional. | 4390 // will still be provisional. |
4396 WebFrame* main_frame = webview()->mainFrame(); | 4391 WebFrame* main_frame = webview()->mainFrame(); |
4397 WebDataSource* data_source = NULL; | 4392 WebDataSource* data_source = NULL; |
4398 if (main_frame->provisionalDataSource()) | 4393 if (main_frame->provisionalDataSource()) |
4399 data_source = main_frame->provisionalDataSource(); | 4394 data_source = main_frame->provisionalDataSource(); |
4400 else | 4395 else |
4401 data_source = main_frame->dataSource(); | 4396 data_source = main_frame->dataSource(); |
4402 | 4397 |
4403 DocumentState* document_state = | 4398 InternalDocumentStateData* internal_data = data_source ? |
4404 data_source ? DocumentState::FromDataSource(data_source) : NULL; | 4399 InternalDocumentStateData::FromDataSource(data_source) : NULL; |
4405 if (document_state && document_state->is_overriding_user_agent()) | 4400 if (internal_data && internal_data->is_overriding_user_agent()) |
4406 return WebString::fromUTF8(renderer_preferences_.user_agent_override); | 4401 return WebString::fromUTF8(renderer_preferences_.user_agent_override); |
4407 else | 4402 return WebKit::WebString(); |
4408 return WebKit::WebString(); | |
4409 } | 4403 } |
4410 | 4404 |
4411 bool RenderViewImpl::allowWebGL(WebFrame* frame, bool default_value) { | 4405 bool RenderViewImpl::allowWebGL(WebFrame* frame, bool default_value) { |
4412 if (!default_value) | 4406 if (!default_value) |
4413 return false; | 4407 return false; |
4414 | 4408 |
4415 bool blocked = true; | 4409 bool blocked = true; |
4416 Send(new ViewHostMsg_Are3DAPIsBlocked( | 4410 Send(new ViewHostMsg_Are3DAPIsBlocked( |
4417 routing_id_, | 4411 routing_id_, |
4418 GURL(frame->top()->document().securityOrigin().toString()), | 4412 GURL(frame->top()->document().securityOrigin().toString()), |
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5604 // Load an empty page first so there is an immediate response to the error, | 5598 // Load an empty page first so there is an immediate response to the error, |
5605 // and then kick off a request for the alternate error page. | 5599 // and then kick off a request for the alternate error page. |
5606 frame->loadHTMLString(std::string(), | 5600 frame->loadHTMLString(std::string(), |
5607 GURL(kUnreachableWebDataURL), | 5601 GURL(kUnreachableWebDataURL), |
5608 error.unreachableURL, | 5602 error.unreachableURL, |
5609 replace); | 5603 replace); |
5610 | 5604 |
5611 // Now, create a fetcher for the error page and associate it with the data | 5605 // Now, create a fetcher for the error page and associate it with the data |
5612 // source we just created via the LoadHTMLString call. That way if another | 5606 // source we just created via the LoadHTMLString call. That way if another |
5613 // navigation occurs, the fetcher will get destroyed. | 5607 // navigation occurs, the fetcher will get destroyed. |
5614 DocumentState* document_state = | 5608 InternalDocumentStateData* internal_data = |
5615 DocumentState::FromDataSource(frame->provisionalDataSource()); | 5609 InternalDocumentStateData::FromDataSource(frame->provisionalDataSource()); |
5616 document_state->set_alt_error_page_fetcher( | 5610 internal_data->set_alt_error_page_fetcher( |
5617 new AltErrorPageResourceFetcher( | 5611 new AltErrorPageResourceFetcher( |
5618 error_page_url, frame, error, | 5612 error_page_url, frame, error, |
5619 base::Bind(&RenderViewImpl::AltErrorPageFinished, | 5613 base::Bind(&RenderViewImpl::AltErrorPageFinished, |
5620 base::Unretained(this)))); | 5614 base::Unretained(this)))); |
5621 return true; | 5615 return true; |
5622 } | 5616 } |
5623 | 5617 |
5624 void RenderViewImpl::AltErrorPageFinished(WebFrame* frame, | 5618 void RenderViewImpl::AltErrorPageFinished(WebFrame* frame, |
5625 const WebURLError& original_error, | 5619 const WebURLError& original_error, |
5626 const std::string& html) { | 5620 const std::string& html) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5675 if (!webview()) | 5669 if (!webview()) |
5676 return; | 5670 return; |
5677 | 5671 |
5678 WebFrame* main_frame = webview()->mainFrame(); | 5672 WebFrame* main_frame = webview()->mainFrame(); |
5679 | 5673 |
5680 // If we have a provisional frame we are between the start and commit stages | 5674 // If we have a provisional frame we are between the start and commit stages |
5681 // of loading and we don't want to save stats. | 5675 // of loading and we don't want to save stats. |
5682 if (!main_frame->provisionalDataSource()) { | 5676 if (!main_frame->provisionalDataSource()) { |
5683 WebDataSource* ds = main_frame->dataSource(); | 5677 WebDataSource* ds = main_frame->dataSource(); |
5684 DocumentState* document_state = DocumentState::FromDataSource(ds); | 5678 DocumentState* document_state = DocumentState::FromDataSource(ds); |
5685 | |
5686 InternalDocumentStateData* data = | 5679 InternalDocumentStateData* data = |
5687 InternalDocumentStateData::FromDataSource(ds); | 5680 InternalDocumentStateData::FromDocumentState(document_state); |
5688 if (data->did_first_visually_non_empty_layout() && | 5681 if (data->did_first_visually_non_empty_layout() && |
5689 !data->did_first_visually_non_empty_paint()) { | 5682 !data->did_first_visually_non_empty_paint()) { |
5690 data->set_did_first_visually_non_empty_paint(true); | 5683 data->set_did_first_visually_non_empty_paint(true); |
5691 Send(new ViewHostMsg_DidFirstVisuallyNonEmptyPaint(routing_id_, | 5684 Send(new ViewHostMsg_DidFirstVisuallyNonEmptyPaint(routing_id_, |
5692 page_id_)); | 5685 page_id_)); |
5693 } | 5686 } |
5694 | 5687 |
5695 // TODO(jar): The following code should all be inside a method, probably in | 5688 // TODO(jar): The following code should all be inside a method, probably in |
5696 // NavigatorState. | 5689 // NavigatorState. |
5697 Time now = Time::Now(); | 5690 Time now = Time::Now(); |
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6619 WebURL url = icon_urls[i].iconURL(); | 6612 WebURL url = icon_urls[i].iconURL(); |
6620 if (!url.isEmpty()) | 6613 if (!url.isEmpty()) |
6621 urls.push_back(FaviconURL(url, | 6614 urls.push_back(FaviconURL(url, |
6622 ToFaviconType(icon_urls[i].iconType()))); | 6615 ToFaviconType(icon_urls[i].iconType()))); |
6623 } | 6616 } |
6624 SendUpdateFaviconURL(urls); | 6617 SendUpdateFaviconURL(urls); |
6625 } | 6618 } |
6626 | 6619 |
6627 | 6620 |
6628 } // namespace content | 6621 } // namespace content |
OLD | NEW |