Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: chrome/browser/net/chrome_network_delegate.cc

Issue 11970002: Added Client-Hints. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Made float literals explicit in tests Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/net/chrome_network_delegate.h ('k') | chrome/browser/net/client_hints.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/net/chrome_network_delegate.h" 5 #include "chrome/browser/net/chrome_network_delegate.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/prefs/public/pref_member.h" 14 #include "base/prefs/public/pref_member.h"
15 #include "base/string_split.h" 15 #include "base/string_split.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/content_settings/cookie_settings.h" 18 #include "chrome/browser/content_settings/cookie_settings.h"
19 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 19 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
20 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 20 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
21 #include "chrome/browser/extensions/api/proxy/proxy_api.h" 21 #include "chrome/browser/extensions/api/proxy/proxy_api.h"
22 #include "chrome/browser/extensions/api/web_request/web_request_api.h" 22 #include "chrome/browser/extensions/api/web_request/web_request_api.h"
23 #include "chrome/browser/extensions/event_router_forwarder.h" 23 #include "chrome/browser/extensions/event_router_forwarder.h"
24 #include "chrome/browser/extensions/extension_info_map.h" 24 #include "chrome/browser/extensions/extension_info_map.h"
25 #include "chrome/browser/extensions/extension_process_manager.h" 25 #include "chrome/browser/extensions/extension_process_manager.h"
26 #include "chrome/browser/extensions/extension_system.h" 26 #include "chrome/browser/extensions/extension_system.h"
27 #include "chrome/browser/google/google_util.h" 27 #include "chrome/browser/google/google_util.h"
28 #include "chrome/browser/net/client_hints.h"
28 #include "chrome/browser/net/connect_interceptor.h" 29 #include "chrome/browser/net/connect_interceptor.h"
29 #include "chrome/browser/net/load_time_stats.h" 30 #include "chrome/browser/net/load_time_stats.h"
30 #include "chrome/browser/performance_monitor/performance_monitor.h" 31 #include "chrome/browser/performance_monitor/performance_monitor.h"
31 #include "chrome/browser/profiles/profile_manager.h" 32 #include "chrome/browser/profiles/profile_manager.h"
32 #include "chrome/browser/task_manager/task_manager.h" 33 #include "chrome/browser/task_manager/task_manager.h"
33 #include "chrome/common/pref_names.h" 34 #include "chrome/common/pref_names.h"
34 #include "chrome/common/url_constants.h" 35 #include "chrome/common/url_constants.h"
35 #include "content/public/browser/browser_thread.h" 36 #include "content/public/browser/browser_thread.h"
36 #include "content/public/browser/render_view_host.h" 37 #include "content/public/browser/render_view_host.h"
37 #include "content/public/browser/resource_request_info.h" 38 #include "content/public/browser/resource_request_info.h"
(...skipping 30 matching lines...) Expand all
68 bool ChromeNetworkDelegate::g_allow_file_access_ = true; 69 bool ChromeNetworkDelegate::g_allow_file_access_ = true;
69 #endif 70 #endif
70 71
71 // This remains false unless the --disable-extensions-http-throttling 72 // This remains false unless the --disable-extensions-http-throttling
72 // flag is passed to the browser. 73 // flag is passed to the browser.
73 bool ChromeNetworkDelegate::g_never_throttle_requests_ = false; 74 bool ChromeNetworkDelegate::g_never_throttle_requests_ = false;
74 75
75 namespace { 76 namespace {
76 77
77 const char kDNTHeader[] = "DNT"; 78 const char kDNTHeader[] = "DNT";
79 const char kClientHintsHeader[] = "CH";
78 80
79 // If the |request| failed due to problems with a proxy, forward the error to 81 // If the |request| failed due to problems with a proxy, forward the error to
80 // the proxy extension API. 82 // the proxy extension API.
81 void ForwardProxyErrors(net::URLRequest* request, 83 void ForwardProxyErrors(net::URLRequest* request,
82 extensions::EventRouterForwarder* event_router, 84 extensions::EventRouterForwarder* event_router,
83 void* profile) { 85 void* profile) {
84 if (request->status().status() == net::URLRequestStatus::FAILED) { 86 if (request->status().status() == net::URLRequestStatus::FAILED) {
85 switch (request->status().error()) { 87 switch (request->status().error()) {
86 case net::ERR_PROXY_AUTH_UNSUPPORTED: 88 case net::ERR_PROXY_AUTH_UNSUPPORTED:
87 case net::ERR_PROXY_CONNECTION_FAILED: 89 case net::ERR_PROXY_CONNECTION_FAILED:
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 CookieSettings* cookie_settings) { 294 CookieSettings* cookie_settings) {
293 cookie_settings_ = cookie_settings; 295 cookie_settings_ = cookie_settings;
294 } 296 }
295 297
296 void ChromeNetworkDelegate::set_predictor( 298 void ChromeNetworkDelegate::set_predictor(
297 chrome_browser_net::Predictor* predictor) { 299 chrome_browser_net::Predictor* predictor) {
298 connect_interceptor_.reset( 300 connect_interceptor_.reset(
299 new chrome_browser_net::ConnectInterceptor(predictor)); 301 new chrome_browser_net::ConnectInterceptor(predictor));
300 } 302 }
301 303
304 void ChromeNetworkDelegate::set_enable_client_hints() {
305 client_hints_.reset(new ClientHints());
306 client_hints_->Init();
307 }
308
302 // static 309 // static
303 void ChromeNetworkDelegate::NeverThrottleRequests() { 310 void ChromeNetworkDelegate::NeverThrottleRequests() {
304 g_never_throttle_requests_ = true; 311 g_never_throttle_requests_ = true;
305 } 312 }
306 313
307 // static 314 // static
308 void ChromeNetworkDelegate::InitializePrefsOnUIThread( 315 void ChromeNetworkDelegate::InitializePrefsOnUIThread(
309 BooleanPrefMember* enable_referrers, 316 BooleanPrefMember* enable_referrers,
310 BooleanPrefMember* enable_do_not_track, 317 BooleanPrefMember* enable_do_not_track,
311 BooleanPrefMember* force_google_safe_search, 318 BooleanPrefMember* force_google_safe_search,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 } 383 }
377 #endif 384 #endif
378 385
379 ForwardRequestStatus(REQUEST_STARTED, request, profile_); 386 ForwardRequestStatus(REQUEST_STARTED, request, profile_);
380 387
381 if (!enable_referrers_->GetValue()) 388 if (!enable_referrers_->GetValue())
382 request->set_referrer(std::string()); 389 request->set_referrer(std::string());
383 if (enable_do_not_track_ && enable_do_not_track_->GetValue()) 390 if (enable_do_not_track_ && enable_do_not_track_->GetValue())
384 request->SetExtraRequestHeaderByName(kDNTHeader, "1", true /* override */); 391 request->SetExtraRequestHeaderByName(kDNTHeader, "1", true /* override */);
385 392
393 if (client_hints_ != NULL) {
394 std::string client_hints_value = client_hints_->GetScreenInfoHints();
395 request->SetExtraRequestHeaderByName(kClientHintsHeader,
396 client_hints_value, true);
397 }
398
386 bool force_safe_search = force_google_safe_search_ && 399 bool force_safe_search = force_google_safe_search_ &&
387 force_google_safe_search_->GetValue(); 400 force_google_safe_search_->GetValue();
388 401
389 net::CompletionCallback wrapped_callback = callback; 402 net::CompletionCallback wrapped_callback = callback;
390 if (force_safe_search) { 403 if (force_safe_search) {
391 wrapped_callback = base::Bind(&ForceGoogleSafeSearchCallbackWrapper, 404 wrapped_callback = base::Bind(&ForceGoogleSafeSearchCallbackWrapper,
392 callback, 405 callback,
393 base::Unretained(request), 406 base::Unretained(request),
394 base::Unretained(new_url)); 407 base::Unretained(new_url));
395 } 408 }
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 685
673 void ChromeNetworkDelegate::AccumulateContentLength( 686 void ChromeNetworkDelegate::AccumulateContentLength(
674 int64 received_content_length, int64 original_content_length) { 687 int64 received_content_length, int64 original_content_length) {
675 DCHECK_GE(received_content_length, 0); 688 DCHECK_GE(received_content_length, 0);
676 DCHECK_GE(original_content_length, 0); 689 DCHECK_GE(original_content_length, 0);
677 StoreAccumulatedContentLength(received_content_length, 690 StoreAccumulatedContentLength(received_content_length,
678 original_content_length); 691 original_content_length);
679 received_content_length_ += received_content_length; 692 received_content_length_ += received_content_length;
680 original_content_length_ += original_content_length; 693 original_content_length_ += original_content_length;
681 } 694 }
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_network_delegate.h ('k') | chrome/browser/net/client_hints.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698