| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 ProfileOAuth2TokenService* token_service = | 75 ProfileOAuth2TokenService* token_service = |
| 76 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 76 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| 77 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); | 77 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); |
| 78 return base::WrapUnique(new SafeSearchURLReporter( | 78 return base::WrapUnique(new SafeSearchURLReporter( |
| 79 token_service, signin->GetAuthenticatedAccountId(), | 79 token_service, signin->GetAuthenticatedAccountId(), |
| 80 profile->GetRequestContext())); | 80 profile->GetRequestContext())); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void SafeSearchURLReporter::ReportUrl(const GURL& url, | 83 void SafeSearchURLReporter::ReportUrl(const GURL& url, |
| 84 const SuccessCallback& callback) { | 84 const SuccessCallback& callback) { |
| 85 reports_.push_back( | 85 reports_.push_back(base::MakeUnique<Report>(url, callback, url_fetcher_id_)); |
| 86 base::WrapUnique(new Report(url, callback, url_fetcher_id_))); | |
| 87 StartFetching(reports_.back().get()); | 86 StartFetching(reports_.back().get()); |
| 88 } | 87 } |
| 89 | 88 |
| 90 void SafeSearchURLReporter::StartFetching(Report* report) { | 89 void SafeSearchURLReporter::StartFetching(Report* report) { |
| 91 OAuth2TokenService::ScopeSet scopes; | 90 OAuth2TokenService::ScopeSet scopes; |
| 92 scopes.insert(kApiScope); | 91 scopes.insert(kApiScope); |
| 93 report->access_token_request = | 92 report->access_token_request = |
| 94 oauth2_token_service_->StartRequest(account_id_, scopes, this); | 93 oauth2_token_service_->StartRequest(account_id_, scopes, this); |
| 95 } | 94 } |
| 96 | 95 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 return; | 174 return; |
| 176 } | 175 } |
| 177 | 176 |
| 178 DispatchResult(it, true); | 177 DispatchResult(it, true); |
| 179 } | 178 } |
| 180 | 179 |
| 181 void SafeSearchURLReporter::DispatchResult(ReportIterator it, bool success) { | 180 void SafeSearchURLReporter::DispatchResult(ReportIterator it, bool success) { |
| 182 (*it)->callback.Run(success); | 181 (*it)->callback.Run(success); |
| 183 reports_.erase(it); | 182 reports_.erase(it); |
| 184 } | 183 } |
| OLD | NEW |