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

Side by Side Diff: ios/chrome/browser/net/ios_chrome_network_delegate.cc

Issue 1456783004: Remove configuration policy on iOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up gyp and DEPS Created 5 years, 1 month 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ios/chrome/browser/net/ios_chrome_network_delegate.h" 5 #include "ios/chrome/browser/net/ios_chrome_network_delegate.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/debug/alias.h" 10 #include "base/debug/alias.h"
(...skipping 10 matching lines...) Expand all
21 #include "components/domain_reliability/monitor.h" 21 #include "components/domain_reliability/monitor.h"
22 #include "ios/chrome/browser/pref_names.h" 22 #include "ios/chrome/browser/pref_names.h"
23 #include "ios/web/public/web_thread.h" 23 #include "ios/web/public/web_thread.h"
24 #include "net/base/load_flags.h" 24 #include "net/base/load_flags.h"
25 #include "net/base/net_errors.h" 25 #include "net/base/net_errors.h"
26 #include "net/cookies/cookie_options.h" 26 #include "net/cookies/cookie_options.h"
27 #include "net/http/http_status_code.h" 27 #include "net/http/http_status_code.h"
28 #include "net/log/net_log.h" 28 #include "net/log/net_log.h"
29 #include "net/url_request/url_request.h" 29 #include "net/url_request/url_request.h"
30 30
31 #if defined(ENABLE_CONFIGURATION_POLICY)
32 #include "components/policy/core/browser/url_blacklist_manager.h"
33 #endif
34
35 namespace { 31 namespace {
36 32
37 const char kDNTHeader[] = "DNT"; 33 const char kDNTHeader[] = "DNT";
38 34
39 void ReportInvalidReferrerSendOnUI() { 35 void ReportInvalidReferrerSendOnUI() {
40 base::RecordAction( 36 base::RecordAction(
41 base::UserMetricsAction("Net.URLRequest_StartJob_InvalidReferrer")); 37 base::UserMetricsAction("Net.URLRequest_StartJob_InvalidReferrer"));
42 } 38 }
43 39
44 void ReportInvalidReferrerSend(const GURL& target_url, 40 void ReportInvalidReferrerSend(const GURL& target_url,
(...skipping 21 matching lines...) Expand all
66 "Net.HttpRequestCompletionErrorCodes.MainFrame", 62 "Net.HttpRequestCompletionErrorCodes.MainFrame",
67 std::abs(request->status().error())); 63 std::abs(request->status().error()));
68 } 64 }
69 } 65 }
70 } 66 }
71 67
72 } // namespace 68 } // namespace
73 69
74 IOSChromeNetworkDelegate::IOSChromeNetworkDelegate() 70 IOSChromeNetworkDelegate::IOSChromeNetworkDelegate()
75 : enable_do_not_track_(nullptr), 71 : enable_do_not_track_(nullptr),
76 #if defined(ENABLE_CONFIGURATION_POLICY)
77 url_blacklist_manager_(nullptr),
78 #endif
79 domain_reliability_monitor_(nullptr) { 72 domain_reliability_monitor_(nullptr) {
80 } 73 }
81 74
82 IOSChromeNetworkDelegate::~IOSChromeNetworkDelegate() {} 75 IOSChromeNetworkDelegate::~IOSChromeNetworkDelegate() {}
83 76
84 // static 77 // static
85 void IOSChromeNetworkDelegate::InitializePrefsOnUIThread( 78 void IOSChromeNetworkDelegate::InitializePrefsOnUIThread(
86 BooleanPrefMember* enable_do_not_track, 79 BooleanPrefMember* enable_do_not_track,
87 PrefService* pref_service) { 80 PrefService* pref_service) {
88 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI); 81 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI);
89 if (enable_do_not_track) { 82 if (enable_do_not_track) {
90 enable_do_not_track->Init(ios::prefs::kEnableDoNotTrack, pref_service); 83 enable_do_not_track->Init(ios::prefs::kEnableDoNotTrack, pref_service);
91 enable_do_not_track->MoveToThread( 84 enable_do_not_track->MoveToThread(
92 web::WebThread::GetTaskRunnerForThread(web::WebThread::IO)); 85 web::WebThread::GetTaskRunnerForThread(web::WebThread::IO));
93 } 86 }
94 } 87 }
95 88
96 int IOSChromeNetworkDelegate::OnBeforeURLRequest( 89 int IOSChromeNetworkDelegate::OnBeforeURLRequest(
97 net::URLRequest* request, 90 net::URLRequest* request,
98 const net::CompletionCallback& callback, 91 const net::CompletionCallback& callback,
99 GURL* new_url) { 92 GURL* new_url) {
100 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. 93 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed.
101 tracked_objects::ScopedTracker tracking_profile1( 94 tracked_objects::ScopedTracker tracking_profile1(
102 FROM_HERE_WITH_EXPLICIT_FUNCTION( 95 FROM_HERE_WITH_EXPLICIT_FUNCTION(
103 "456327 URLRequest::IOSChromeNetworkDelegate::OnBeforeURLRequest")); 96 "456327 URLRequest::IOSChromeNetworkDelegate::OnBeforeURLRequest"));
104 97
105 #if defined(ENABLE_CONFIGURATION_POLICY)
106 int error = net::ERR_BLOCKED_BY_ADMINISTRATOR;
107 // iOS cannot check the resource type, block everything.
108 // See http://crbug.com/338283 and http://crbug.com/489704
109 if (url_blacklist_manager_ &&
110 url_blacklist_manager_->ShouldBlockRequestForFrame(request->url(),
111 &error)) {
112 // URL access blocked by policy.
113 request->net_log().AddEvent(
114 net::NetLog::TYPE_CHROME_POLICY_ABORTED_REQUEST,
115 net::NetLog::StringCallback("url",
116 &request->url().possibly_invalid_spec()));
117 return error;
118 }
119 #endif
120
121 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. 98 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed.
122 tracked_objects::ScopedTracker tracking_profile2( 99 tracked_objects::ScopedTracker tracking_profile2(
123 FROM_HERE_WITH_EXPLICIT_FUNCTION( 100 FROM_HERE_WITH_EXPLICIT_FUNCTION(
124 "456327 URLRequest::IOSChromeNetworkDelegate::OnBeforeURLRequest 2")); 101 "456327 URLRequest::IOSChromeNetworkDelegate::OnBeforeURLRequest 2"));
125 102
126 if (enable_do_not_track_ && enable_do_not_track_->GetValue()) 103 if (enable_do_not_track_ && enable_do_not_track_->GetValue())
127 request->SetExtraRequestHeaderByName(kDNTHeader, "1", true /* override */); 104 request->SetExtraRequestHeaderByName(kDNTHeader, "1", true /* override */);
128 105
129 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. 106 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed.
130 tracked_objects::ScopedTracker tracking_profile4( 107 tracked_objects::ScopedTracker tracking_profile4(
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 177 }
201 178
202 bool IOSChromeNetworkDelegate:: 179 bool IOSChromeNetworkDelegate::
203 OnCancelURLRequestWithPolicyViolatingReferrerHeader( 180 OnCancelURLRequestWithPolicyViolatingReferrerHeader(
204 const net::URLRequest& request, 181 const net::URLRequest& request,
205 const GURL& target_url, 182 const GURL& target_url,
206 const GURL& referrer_url) const { 183 const GURL& referrer_url) const {
207 ReportInvalidReferrerSend(target_url, referrer_url); 184 ReportInvalidReferrerSend(target_url, referrer_url);
208 return true; 185 return true;
209 } 186 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/net/ios_chrome_network_delegate.h ('k') | ios/chrome/browser/prefs/browser_prefs.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698