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 2102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2113 &ssl_status.signed_certificate_timestamp_ids); | 2113 &ssl_status.signed_certificate_timestamp_ids); |
2114 return ssl_status; | 2114 return ssl_status; |
2115 } | 2115 } |
2116 | 2116 |
2117 const std::string& RenderViewImpl::GetAcceptLanguages() const { | 2117 const std::string& RenderViewImpl::GetAcceptLanguages() const { |
2118 return renderer_preferences_.accept_languages; | 2118 return renderer_preferences_.accept_languages; |
2119 } | 2119 } |
2120 | 2120 |
2121 void RenderViewImpl::didCreateDataSource(WebLocalFrame* frame, | 2121 void RenderViewImpl::didCreateDataSource(WebLocalFrame* frame, |
2122 WebDataSource* ds) { | 2122 WebDataSource* ds) { |
2123 bool content_initiated = !pending_navigation_params_.get(); | 2123 bool content_initiated = !pending_common_params_.get(); |
2124 bool browser_side_navigation_enabled = | |
2125 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
2126 switches::kEnableBrowserSideNavigation); | |
2127 CHECK(content_initiated || pending_commit_params_.get()); | |
2128 CHECK(content_initiated || pending_history_params_.get()); | |
2129 CHECK(content_initiated || pending_start_params_.get() || | |
2130 browser_side_navigation_enabled); | |
2124 | 2131 |
2125 // Make sure any previous redirect URLs end up in our new data source. | 2132 // Make sure any previous redirect URLs end up in our new data source. |
2126 if (pending_navigation_params_.get()) { | 2133 if (pending_commit_params_.get()) { |
2127 for (std::vector<GURL>::const_iterator i = | 2134 for (std::vector<GURL>::const_iterator i = |
2128 pending_navigation_params_->redirects.begin(); | 2135 pending_commit_params_->redirects.begin(); |
2129 i != pending_navigation_params_->redirects.end(); ++i) { | 2136 i != pending_commit_params_->redirects.end(); ++i) { |
2130 ds->appendRedirect(*i); | 2137 ds->appendRedirect(*i); |
2131 } | 2138 } |
2132 } | 2139 } |
2133 | 2140 |
2134 DocumentState* document_state = DocumentState::FromDataSource(ds); | 2141 DocumentState* document_state = DocumentState::FromDataSource(ds); |
2135 if (!document_state) { | 2142 if (!document_state) { |
2136 document_state = new DocumentState; | 2143 document_state = new DocumentState; |
2137 ds->setExtraData(document_state); | 2144 ds->setExtraData(document_state); |
2138 if (!content_initiated) | 2145 if (!content_initiated) |
2139 PopulateDocumentStateFromPending(document_state); | 2146 PopulateDocumentStateFromPending(document_state); |
(...skipping 15 matching lines...) Expand all Loading... | |
2155 } | 2162 } |
2156 } | 2163 } |
2157 | 2164 |
2158 // The rest of RenderView assumes that a WebDataSource will always have a | 2165 // The rest of RenderView assumes that a WebDataSource will always have a |
2159 // non-null NavigationState. | 2166 // non-null NavigationState. |
2160 if (content_initiated) { | 2167 if (content_initiated) { |
2161 document_state->set_navigation_state( | 2168 document_state->set_navigation_state( |
2162 NavigationState::CreateContentInitiated()); | 2169 NavigationState::CreateContentInitiated()); |
2163 } else { | 2170 } else { |
2164 document_state->set_navigation_state(CreateNavigationStateFromPending()); | 2171 document_state->set_navigation_state(CreateNavigationStateFromPending()); |
2165 pending_navigation_params_.reset(); | 2172 pending_common_params_.reset(); |
2173 pending_start_params_.reset(); | |
2174 pending_commit_params_.reset(); | |
2175 pending_history_params_.reset(); | |
2166 } | 2176 } |
2167 | 2177 |
2168 // DocumentState::referred_by_prefetcher_ is true if we are | 2178 // DocumentState::referred_by_prefetcher_ is true if we are |
2169 // navigating from a page that used prefetching using a link on that | 2179 // navigating from a page that used prefetching using a link on that |
2170 // page. We are early enough in the request process here that we | 2180 // page. We are early enough in the request process here that we |
2171 // can still see the DocumentState of the previous page and set | 2181 // can still see the DocumentState of the previous page and set |
2172 // this value appropriately. | 2182 // this value appropriately. |
2173 // TODO(gavinp): catch the important case of navigation in a new | 2183 // TODO(gavinp): catch the important case of navigation in a new |
2174 // renderer process. | 2184 // renderer process. |
2175 if (webview()) { | 2185 if (webview()) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2212 NOTREACHED(); | 2222 NOTREACHED(); |
2213 } | 2223 } |
2214 } | 2224 } |
2215 | 2225 |
2216 FOR_EACH_OBSERVER( | 2226 FOR_EACH_OBSERVER( |
2217 RenderViewObserver, observers_, DidCreateDataSource(frame, ds)); | 2227 RenderViewObserver, observers_, DidCreateDataSource(frame, ds)); |
2218 } | 2228 } |
2219 | 2229 |
2220 void RenderViewImpl::PopulateDocumentStateFromPending( | 2230 void RenderViewImpl::PopulateDocumentStateFromPending( |
2221 DocumentState* document_state) { | 2231 DocumentState* document_state) { |
2222 const FrameMsg_Navigate_Params& params = *pending_navigation_params_.get(); | 2232 document_state->set_request_time(pending_commit_params_->request_time); |
2223 document_state->set_request_time(params.request_time); | |
2224 | 2233 |
2225 InternalDocumentStateData* internal_data = | 2234 InternalDocumentStateData* internal_data = |
2226 InternalDocumentStateData::FromDocumentState(document_state); | 2235 InternalDocumentStateData::FromDocumentState(document_state); |
2227 | 2236 |
2228 if (!params.common_params.url.SchemeIs(url::kJavaScriptScheme) && | 2237 if (!pending_common_params_->url.SchemeIs(url::kJavaScriptScheme) && |
2229 params.common_params.navigation_type == FrameMsg_Navigate_Type::RESTORE) { | 2238 pending_common_params_->navigation_type == |
2239 FrameMsg_Navigate_Type::RESTORE) { | |
2230 // We're doing a load of a page that was restored from the last session. By | 2240 // We're doing a load of a page that was restored from the last session. By |
2231 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which | 2241 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which |
2232 // can result in stale data for pages that are set to expire. We explicitly | 2242 // can result in stale data for pages that are set to expire. We explicitly |
2233 // override that by setting the policy here so that as necessary we load | 2243 // override that by setting the policy here so that as necessary we load |
2234 // from the network. | 2244 // from the network. |
2235 // | 2245 // |
2236 // TODO(davidben): Remove this in favor of passing a cache policy to the | 2246 // TODO(davidben): Remove this in favor of passing a cache policy to the |
2237 // loadHistoryItem call in OnNavigate. That requires not overloading | 2247 // loadHistoryItem call in OnNavigate. That requires not overloading |
2238 // UseProtocolCachePolicy to mean both "normal load" and "determine cache | 2248 // UseProtocolCachePolicy to mean both "normal load" and "determine cache |
2239 // policy based on load type, etc". | 2249 // policy based on load type, etc". |
2240 internal_data->set_cache_policy_override( | 2250 internal_data->set_cache_policy_override( |
2241 WebURLRequest::UseProtocolCachePolicy); | 2251 WebURLRequest::UseProtocolCachePolicy); |
2242 } | 2252 } |
2243 | 2253 |
2244 if (IsReload(params.common_params.navigation_type)) | 2254 if (IsReload(pending_common_params_->navigation_type)) |
2245 document_state->set_load_type(DocumentState::RELOAD); | 2255 document_state->set_load_type(DocumentState::RELOAD); |
2246 else if (params.history_params.page_state.IsValid()) | 2256 else if (pending_history_params_->page_state.IsValid()) |
2247 document_state->set_load_type(DocumentState::HISTORY_LOAD); | 2257 document_state->set_load_type(DocumentState::HISTORY_LOAD); |
2248 else | 2258 else |
2249 document_state->set_load_type(DocumentState::NORMAL_LOAD); | 2259 document_state->set_load_type(DocumentState::NORMAL_LOAD); |
2250 | 2260 |
2251 internal_data->set_is_overriding_user_agent( | 2261 internal_data->set_is_overriding_user_agent( |
2252 params.commit_params.is_overriding_user_agent); | 2262 pending_commit_params_->is_overriding_user_agent); |
2253 internal_data->set_must_reset_scroll_and_scale_state( | 2263 internal_data->set_must_reset_scroll_and_scale_state( |
2254 params.common_params.navigation_type == | 2264 pending_common_params_->navigation_type == |
2255 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); | 2265 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); |
2256 document_state->set_can_load_local_resources(params.can_load_local_resources); | 2266 document_state->set_can_load_local_resources( |
2267 pending_commit_params_->can_load_local_resources); | |
2257 } | 2268 } |
2258 | 2269 |
2259 NavigationState* RenderViewImpl::CreateNavigationStateFromPending() { | 2270 NavigationState* RenderViewImpl::CreateNavigationStateFromPending() { |
2260 const FrameMsg_Navigate_Params& params = *pending_navigation_params_.get(); | |
2261 NavigationState* navigation_state = NULL; | 2271 NavigationState* navigation_state = NULL; |
2262 | 2272 |
2263 // A navigation resulting from loading a javascript URL should not be treated | 2273 // A navigation resulting from loading a javascript URL should not be treated |
2264 // as a browser initiated event. Instead, we want it to look as if the page | 2274 // as a browser initiated event. Instead, we want it to look as if the page |
2265 // initiated any load resulting from JS execution. | 2275 // initiated any load resulting from JS execution. |
2266 if (!params.common_params.url.SchemeIs(url::kJavaScriptScheme)) { | 2276 if (!pending_common_params_->url.SchemeIs(url::kJavaScriptScheme)) { |
2267 navigation_state = NavigationState::CreateBrowserInitiated( | 2277 navigation_state = NavigationState::CreateBrowserInitiated( |
clamy
2015/03/09 14:34:47
As explained in render_frame_impl.cc, the next goa
| |
2268 params.history_params.page_id, | 2278 pending_history_params_->page_id, |
2269 params.history_params.pending_history_list_offset, | 2279 pending_history_params_->pending_history_list_offset, |
2270 params.history_params.should_clear_history_list, | 2280 pending_history_params_->should_clear_history_list, |
2271 params.common_params.transition); | 2281 pending_common_params_->transition); |
2272 navigation_state->set_should_replace_current_entry( | 2282 navigation_state->set_allow_download( |
2273 params.should_replace_current_entry); | 2283 pending_common_params_->allow_download); |
2274 navigation_state->set_transferred_request_child_id( | 2284 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
2275 params.transferred_request_child_id); | 2285 switches::kEnableBrowserSideNavigation)) { |
2276 navigation_state->set_transferred_request_request_id( | 2286 navigation_state->set_should_replace_current_entry( |
2277 params.transferred_request_request_id); | 2287 pending_start_params_->should_replace_current_entry); |
2278 navigation_state->set_allow_download(params.common_params.allow_download); | 2288 navigation_state->set_transferred_request_child_id( |
2279 navigation_state->set_extra_headers(params.extra_headers); | 2289 pending_start_params_->transferred_request_child_id); |
2290 navigation_state->set_transferred_request_request_id( | |
2291 pending_start_params_->transferred_request_request_id); | |
2292 navigation_state->set_extra_headers(pending_start_params_->extra_headers); | |
2293 } | |
2280 } else { | 2294 } else { |
2281 navigation_state = NavigationState::CreateContentInitiated(); | 2295 navigation_state = NavigationState::CreateContentInitiated(); |
2282 } | 2296 } |
2283 return navigation_state; | 2297 return navigation_state; |
2284 } | 2298 } |
2285 | 2299 |
2286 void RenderViewImpl::didChangeIcon(WebLocalFrame* frame, | 2300 void RenderViewImpl::didChangeIcon(WebLocalFrame* frame, |
2287 WebIconURL::Type icon_type) { | 2301 WebIconURL::Type icon_type) { |
2288 if (frame->parent()) | 2302 if (frame->parent()) |
2289 return; | 2303 return; |
(...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3997 std::vector<gfx::Size> sizes; | 4011 std::vector<gfx::Size> sizes; |
3998 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4012 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
3999 if (!url.isEmpty()) | 4013 if (!url.isEmpty()) |
4000 urls.push_back( | 4014 urls.push_back( |
4001 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4015 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4002 } | 4016 } |
4003 SendUpdateFaviconURL(urls); | 4017 SendUpdateFaviconURL(urls); |
4004 } | 4018 } |
4005 | 4019 |
4006 } // namespace content | 4020 } // namespace content |
OLD | NEW |