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 2069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2080 return renderer_preferences_.accept_languages; | 2080 return renderer_preferences_.accept_languages; |
2081 } | 2081 } |
2082 | 2082 |
2083 void RenderViewImpl::didCreateDataSource(WebLocalFrame* frame, | 2083 void RenderViewImpl::didCreateDataSource(WebLocalFrame* frame, |
2084 WebDataSource* ds) { | 2084 WebDataSource* ds) { |
2085 bool content_initiated = !pending_navigation_params_.get(); | 2085 bool content_initiated = !pending_navigation_params_.get(); |
2086 | 2086 |
2087 // Make sure any previous redirect URLs end up in our new data source. | 2087 // Make sure any previous redirect URLs end up in our new data source. |
2088 if (pending_navigation_params_.get()) { | 2088 if (pending_navigation_params_.get()) { |
2089 for (std::vector<GURL>::const_iterator i = | 2089 for (std::vector<GURL>::const_iterator i = |
2090 pending_navigation_params_->commit_params.redirects.begin(); | 2090 pending_navigation_params_->request_params.redirects.begin(); |
2091 i != pending_navigation_params_->commit_params.redirects.end(); ++i) { | 2091 i != pending_navigation_params_->request_params.redirects.end(); ++i) { |
2092 ds->appendRedirect(*i); | 2092 ds->appendRedirect(*i); |
2093 } | 2093 } |
2094 } | 2094 } |
2095 | 2095 |
2096 DocumentState* document_state = DocumentState::FromDataSource(ds); | 2096 DocumentState* document_state = DocumentState::FromDataSource(ds); |
2097 if (!document_state) { | 2097 if (!document_state) { |
2098 document_state = new DocumentState; | 2098 document_state = new DocumentState; |
2099 ds->setExtraData(document_state); | 2099 ds->setExtraData(document_state); |
2100 if (!content_initiated) | 2100 if (!content_initiated) |
2101 PopulateDocumentStateFromPending(document_state); | 2101 PopulateDocumentStateFromPending(document_state); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2175 } | 2175 } |
2176 } | 2176 } |
2177 | 2177 |
2178 FOR_EACH_OBSERVER( | 2178 FOR_EACH_OBSERVER( |
2179 RenderViewObserver, observers_, DidCreateDataSource(frame, ds)); | 2179 RenderViewObserver, observers_, DidCreateDataSource(frame, ds)); |
2180 } | 2180 } |
2181 | 2181 |
2182 void RenderViewImpl::PopulateDocumentStateFromPending( | 2182 void RenderViewImpl::PopulateDocumentStateFromPending( |
2183 DocumentState* document_state) { | 2183 DocumentState* document_state) { |
2184 document_state->set_request_time( | 2184 document_state->set_request_time( |
2185 pending_navigation_params_->commit_params.request_time); | 2185 pending_navigation_params_->request_params.request_time); |
2186 | 2186 |
2187 InternalDocumentStateData* internal_data = | 2187 InternalDocumentStateData* internal_data = |
2188 InternalDocumentStateData::FromDocumentState(document_state); | 2188 InternalDocumentStateData::FromDocumentState(document_state); |
2189 | 2189 |
2190 if (!pending_navigation_params_->common_params.url.SchemeIs( | 2190 if (!pending_navigation_params_->common_params.url.SchemeIs( |
2191 url::kJavaScriptScheme) && | 2191 url::kJavaScriptScheme) && |
2192 pending_navigation_params_->common_params.navigation_type == | 2192 pending_navigation_params_->common_params.navigation_type == |
2193 FrameMsg_Navigate_Type::RESTORE) { | 2193 FrameMsg_Navigate_Type::RESTORE) { |
2194 // We're doing a load of a page that was restored from the last session. By | 2194 // We're doing a load of a page that was restored from the last session. By |
2195 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which | 2195 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which |
2196 // can result in stale data for pages that are set to expire. We explicitly | 2196 // can result in stale data for pages that are set to expire. We explicitly |
2197 // override that by setting the policy here so that as necessary we load | 2197 // override that by setting the policy here so that as necessary we load |
2198 // from the network. | 2198 // from the network. |
2199 // | 2199 // |
2200 // TODO(davidben): Remove this in favor of passing a cache policy to the | 2200 // TODO(davidben): Remove this in favor of passing a cache policy to the |
2201 // loadHistoryItem call in OnNavigate. That requires not overloading | 2201 // loadHistoryItem call in OnNavigate. That requires not overloading |
2202 // UseProtocolCachePolicy to mean both "normal load" and "determine cache | 2202 // UseProtocolCachePolicy to mean both "normal load" and "determine cache |
2203 // policy based on load type, etc". | 2203 // policy based on load type, etc". |
2204 internal_data->set_cache_policy_override( | 2204 internal_data->set_cache_policy_override( |
2205 WebURLRequest::UseProtocolCachePolicy); | 2205 WebURLRequest::UseProtocolCachePolicy); |
2206 } | 2206 } |
2207 | 2207 |
2208 if (IsReload(pending_navigation_params_->common_params.navigation_type)) | 2208 if (IsReload(pending_navigation_params_->common_params.navigation_type)) |
2209 document_state->set_load_type(DocumentState::RELOAD); | 2209 document_state->set_load_type(DocumentState::RELOAD); |
2210 else if (pending_navigation_params_->history_params.page_state.IsValid()) | 2210 else if (pending_navigation_params_->request_params.page_state.IsValid()) |
2211 document_state->set_load_type(DocumentState::HISTORY_LOAD); | 2211 document_state->set_load_type(DocumentState::HISTORY_LOAD); |
2212 else | 2212 else |
2213 document_state->set_load_type(DocumentState::NORMAL_LOAD); | 2213 document_state->set_load_type(DocumentState::NORMAL_LOAD); |
2214 | 2214 |
2215 internal_data->set_is_overriding_user_agent( | 2215 internal_data->set_is_overriding_user_agent( |
2216 pending_navigation_params_->commit_params.is_overriding_user_agent); | 2216 pending_navigation_params_->request_params.is_overriding_user_agent); |
2217 internal_data->set_must_reset_scroll_and_scale_state( | 2217 internal_data->set_must_reset_scroll_and_scale_state( |
2218 pending_navigation_params_->common_params.navigation_type == | 2218 pending_navigation_params_->common_params.navigation_type == |
2219 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); | 2219 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); |
2220 document_state->set_can_load_local_resources( | 2220 document_state->set_can_load_local_resources( |
2221 pending_navigation_params_->commit_params.can_load_local_resources); | 2221 pending_navigation_params_->request_params.can_load_local_resources); |
2222 } | 2222 } |
2223 | 2223 |
2224 NavigationState* RenderViewImpl::CreateNavigationStateFromPending() { | 2224 NavigationState* RenderViewImpl::CreateNavigationStateFromPending() { |
2225 // A navigation resulting from loading a javascript URL should not be treated | 2225 // A navigation resulting from loading a javascript URL should not be treated |
2226 // as a browser initiated event. Instead, we want it to look as if the page | 2226 // as a browser initiated event. Instead, we want it to look as if the page |
2227 // initiated any load resulting from JS execution. | 2227 // initiated any load resulting from JS execution. |
2228 if (!pending_navigation_params_->common_params.url.SchemeIs( | 2228 if (!pending_navigation_params_->common_params.url.SchemeIs( |
2229 url::kJavaScriptScheme)) { | 2229 url::kJavaScriptScheme)) { |
2230 return NavigationStateImpl::CreateBrowserInitiated( | 2230 return NavigationStateImpl::CreateBrowserInitiated( |
2231 pending_navigation_params_->common_params, | 2231 pending_navigation_params_->common_params, |
2232 pending_navigation_params_->start_params, | 2232 pending_navigation_params_->start_params, |
2233 pending_navigation_params_->history_params); | 2233 pending_navigation_params_->request_params); |
2234 } | 2234 } |
2235 return NavigationStateImpl::CreateContentInitiated(); | 2235 return NavigationStateImpl::CreateContentInitiated(); |
2236 } | 2236 } |
2237 | 2237 |
2238 void RenderViewImpl::didChangeIcon(WebLocalFrame* frame, | 2238 void RenderViewImpl::didChangeIcon(WebLocalFrame* frame, |
2239 WebIconURL::Type icon_type) { | 2239 WebIconURL::Type icon_type) { |
2240 if (frame->parent()) | 2240 if (frame->parent()) |
2241 return; | 2241 return; |
2242 | 2242 |
2243 WebVector<WebIconURL> icon_urls = frame->iconURLs(icon_type); | 2243 WebVector<WebIconURL> icon_urls = frame->iconURLs(icon_type); |
(...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3961 std::vector<gfx::Size> sizes; | 3961 std::vector<gfx::Size> sizes; |
3962 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 3962 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
3963 if (!url.isEmpty()) | 3963 if (!url.isEmpty()) |
3964 urls.push_back( | 3964 urls.push_back( |
3965 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 3965 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
3966 } | 3966 } |
3967 SendUpdateFaviconURL(urls); | 3967 SendUpdateFaviconURL(urls); |
3968 } | 3968 } |
3969 | 3969 |
3970 } // namespace content | 3970 } // namespace content |
OLD | NEW |