OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/renderer/net/net_error_helper.h" | 5 #include "chrome/renderer/net/net_error_helper.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 correction_fetcher_.reset( | 279 correction_fetcher_.reset( |
280 content::ResourceFetcher::Create(navigation_correction_url)); | 280 content::ResourceFetcher::Create(navigation_correction_url)); |
281 correction_fetcher_->SetMethod("POST"); | 281 correction_fetcher_->SetMethod("POST"); |
282 correction_fetcher_->SetBody(navigation_correction_request_body); | 282 correction_fetcher_->SetBody(navigation_correction_request_body); |
283 correction_fetcher_->SetHeader("Content-Type", "application/json"); | 283 correction_fetcher_->SetHeader("Content-Type", "application/json"); |
284 | 284 |
285 correction_fetcher_->Start( | 285 correction_fetcher_->Start( |
286 render_frame()->GetWebFrame(), | 286 render_frame()->GetWebFrame(), |
287 blink::WebURLRequest::RequestContextInternal, | 287 blink::WebURLRequest::RequestContextInternal, |
288 blink::WebURLRequest::FrameTypeNone, | 288 blink::WebURLRequest::FrameTypeNone, |
289 content::ResourceFetcher::PLATFORM_LOADER, | |
290 base::Bind(&NetErrorHelper::OnNavigationCorrectionsFetched, | 289 base::Bind(&NetErrorHelper::OnNavigationCorrectionsFetched, |
291 base::Unretained(this))); | 290 base::Unretained(this))); |
292 | 291 |
293 correction_fetcher_->SetTimeout( | 292 correction_fetcher_->SetTimeout( |
294 base::TimeDelta::FromSeconds(kNavigationCorrectionFetchTimeoutSec)); | 293 base::TimeDelta::FromSeconds(kNavigationCorrectionFetchTimeoutSec)); |
295 } | 294 } |
296 | 295 |
297 void NetErrorHelper::CancelFetchNavigationCorrections() { | 296 void NetErrorHelper::CancelFetchNavigationCorrections() { |
298 correction_fetcher_.reset(); | 297 correction_fetcher_.reset(); |
299 } | 298 } |
300 | 299 |
301 void NetErrorHelper::SendTrackingRequest( | 300 void NetErrorHelper::SendTrackingRequest( |
302 const GURL& tracking_url, | 301 const GURL& tracking_url, |
303 const std::string& tracking_request_body) { | 302 const std::string& tracking_request_body) { |
304 // If there's already a pending tracking request, this will cancel it. | 303 // If there's already a pending tracking request, this will cancel it. |
305 tracking_fetcher_.reset(content::ResourceFetcher::Create(tracking_url)); | 304 tracking_fetcher_.reset(content::ResourceFetcher::Create(tracking_url)); |
306 tracking_fetcher_->SetMethod("POST"); | 305 tracking_fetcher_->SetMethod("POST"); |
307 tracking_fetcher_->SetBody(tracking_request_body); | 306 tracking_fetcher_->SetBody(tracking_request_body); |
308 tracking_fetcher_->SetHeader("Content-Type", "application/json"); | 307 tracking_fetcher_->SetHeader("Content-Type", "application/json"); |
309 | 308 |
310 tracking_fetcher_->Start( | 309 tracking_fetcher_->Start( |
311 render_frame()->GetWebFrame(), | 310 render_frame()->GetWebFrame(), |
312 blink::WebURLRequest::RequestContextInternal, | 311 blink::WebURLRequest::RequestContextInternal, |
313 blink::WebURLRequest::FrameTypeNone, | 312 blink::WebURLRequest::FrameTypeNone, |
314 content::ResourceFetcher::PLATFORM_LOADER, | |
315 base::Bind(&NetErrorHelper::OnTrackingRequestComplete, | 313 base::Bind(&NetErrorHelper::OnTrackingRequestComplete, |
316 base::Unretained(this))); | 314 base::Unretained(this))); |
317 } | 315 } |
318 | 316 |
319 void NetErrorHelper::ReloadPage(bool bypass_cache) { | 317 void NetErrorHelper::ReloadPage(bool bypass_cache) { |
320 render_frame()->GetWebFrame()->reload( | 318 render_frame()->GetWebFrame()->reload( |
321 bypass_cache ? blink::WebFrameLoadType::ReloadBypassingCache | 319 bypass_cache ? blink::WebFrameLoadType::ReloadBypassingCache |
322 : blink::WebFrameLoadType::Reload); | 320 : blink::WebFrameLoadType::Reload); |
323 } | 321 } |
324 | 322 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 | 387 |
390 void NetErrorHelper::SetCanShowNetworkDiagnosticsDialog(bool can_show) { | 388 void NetErrorHelper::SetCanShowNetworkDiagnosticsDialog(bool can_show) { |
391 core_->OnSetCanShowNetworkDiagnosticsDialog(can_show); | 389 core_->OnSetCanShowNetworkDiagnosticsDialog(can_show); |
392 } | 390 } |
393 | 391 |
394 #if defined(OS_ANDROID) | 392 #if defined(OS_ANDROID) |
395 void NetErrorHelper::OnSetHasOfflinePages(bool has_offline_pages) { | 393 void NetErrorHelper::OnSetHasOfflinePages(bool has_offline_pages) { |
396 core_->OnSetHasOfflinePages(has_offline_pages); | 394 core_->OnSetHasOfflinePages(has_offline_pages); |
397 } | 395 } |
398 #endif // defined(OS_ANDROID) | 396 #endif // defined(OS_ANDROID) |
OLD | NEW |