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