Chromium Code Reviews| Index: chrome/browser/supervised_user/experimental/safe_search_url_reporter.h |
| diff --git a/chrome/browser/supervised_user/experimental/safe_search_url_reporter.h b/chrome/browser/supervised_user/experimental/safe_search_url_reporter.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..794b8fa2a16c0f5a61b24f045c372aa0cedd9ed4 |
| --- /dev/null |
| +++ b/chrome/browser/supervised_user/experimental/safe_search_url_reporter.h |
| @@ -0,0 +1,69 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SAFE_SEARCH_URL_REPORTER_H_ |
| +#define CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SAFE_SEARCH_URL_REPORTER_H_ |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "google_apis/gaia/oauth2_token_service.h" |
| +#include "net/url_request/url_fetcher_delegate.h" |
| +#include "base/callback_forward.h" |
| +#include "base/macros.h" |
| +#include "url/gurl.h" |
| + |
| +class GURL; |
| +class Profile; |
| + |
| +namespace net { |
| +class URLFetcher; |
| +class URLReportContextGetter; |
| +} |
| + |
| +class SafeSearchUrlReporter : public OAuth2TokenService::Consumer, |
|
Marc Treib
2016/03/22 16:06:49
Also here: URL capitalized
atanasova
2016/03/23 10:45:00
Done.
|
| + public net::URLFetcherDelegate { |
| + public: |
| + SafeSearchUrlReporter(OAuth2TokenService* oauth2_token_service, |
| + const std::string& account_id, |
| + net::URLRequestContextGetter* context); |
| + ~SafeSearchUrlReporter() override; |
| + |
| + using SuccessCallback = base::Callback<void(bool)>; |
| + |
| + static scoped_ptr<SafeSearchUrlReporter> CreateWithProfile(Profile* profile); |
| + |
| + void ReportUrl(const GURL& url, const SuccessCallback& callback); |
| + |
| + void set_url_fetcher_id_for_testing(int id) { url_fetcher_id_ = id; } |
| + |
| + private: |
| + struct Report; |
| + using ReportIterator = std::vector<scoped_ptr<Report>>::iterator; |
| + |
| + // OAuth2TokenService::Consumer implementation: |
| + void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
| + const std::string& access_token, |
| + const base::Time& expiration_time) override; |
| + void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
| + const GoogleServiceAuthError& error) override; |
| + |
| + // net::URLFetcherDelegate implementation. |
| + void OnURLFetchComplete(const net::URLFetcher* source) override; |
| + |
| + // Requests an access token, which is the first thing we need. This is where |
| + // we restart when the returned access token has expired. |
| + void StartFetching(Report* Report); |
| + |
| + void DispatchResult(ReportIterator it, bool success); |
| + |
| + OAuth2TokenService* oauth2_token_service_; |
| + std::string account_id_; |
| + net::URLRequestContextGetter* context_; |
| + int url_fetcher_id_; |
| + |
| + std::vector<scoped_ptr<Report>> reports_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SafeSearchUrlReporter); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SAFE_SEARCH_URL_REPORTER_H_ |