OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/supervised_user/experimental/safe_search_url_reporter.h
" | 5 #include "chrome/browser/supervised_user/experimental/safe_search_url_reporter.h
" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 (*it)->url_fetcher.get(), | 142 (*it)->url_fetcher.get(), |
143 data_use_measurement::DataUseUserData::SUPERVISED_USER); | 143 data_use_measurement::DataUseUserData::SUPERVISED_USER); |
144 (*it)->url_fetcher->SetRequestContext(context_); | 144 (*it)->url_fetcher->SetRequestContext(context_); |
145 (*it)->url_fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 145 (*it)->url_fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
146 net::LOAD_DO_NOT_SAVE_COOKIES); | 146 net::LOAD_DO_NOT_SAVE_COOKIES); |
147 (*it)->url_fetcher->SetAutomaticallyRetryOnNetworkChanges(kNumRetries); | 147 (*it)->url_fetcher->SetAutomaticallyRetryOnNetworkChanges(kNumRetries); |
148 (*it)->url_fetcher->AddExtraRequestHeader( | 148 (*it)->url_fetcher->AddExtraRequestHeader( |
149 base::StringPrintf(kAuthorizationHeaderFormat, access_token.c_str())); | 149 base::StringPrintf(kAuthorizationHeaderFormat, access_token.c_str())); |
150 | 150 |
151 base::DictionaryValue dict; | 151 base::DictionaryValue dict; |
152 dict.SetStringWithoutPathExpansion(kUrlKey, (*it)->url.spec().c_str()); | 152 dict.SetStringWithoutPathExpansion(kUrlKey, (*it)->url.spec()); |
153 | 153 |
154 std::string body; | 154 std::string body; |
155 base::JSONWriter::Write(dict, &body); | 155 base::JSONWriter::Write(dict, &body); |
156 (*it)->url_fetcher->SetUploadData("application/json", body); | 156 (*it)->url_fetcher->SetUploadData("application/json", body); |
157 | 157 |
158 (*it)->url_fetcher->Start(); | 158 (*it)->url_fetcher->Start(); |
159 } | 159 } |
160 | 160 |
161 void SafeSearchURLReporter::OnGetTokenFailure( | 161 void SafeSearchURLReporter::OnGetTokenFailure( |
162 const OAuth2TokenService::Request* request, | 162 const OAuth2TokenService::Request* request, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 return; | 205 return; |
206 } | 206 } |
207 | 207 |
208 DispatchResult(it, true); | 208 DispatchResult(it, true); |
209 } | 209 } |
210 | 210 |
211 void SafeSearchURLReporter::DispatchResult(ReportIterator it, bool success) { | 211 void SafeSearchURLReporter::DispatchResult(ReportIterator it, bool success) { |
212 (*it)->callback.Run(success); | 212 (*it)->callback.Run(success); |
213 reports_.erase(it); | 213 reports_.erase(it); |
214 } | 214 } |
OLD | NEW |