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..01524dd1d7ecaf2b9160d9d2710121313e948c13 |
--- /dev/null |
+++ b/chrome/browser/supervised_user/experimental/safe_search_url_reporter.h |
@@ -0,0 +1,72 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
Marc Treib
2016/03/21 12:32:21
2016 :)
atanasova
2016/03/22 15:45:41
Done.
|
+// 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 <stddef.h> |
Marc Treib
2016/03/21 12:32:21
probably not needed?
atanasova
2016/03/22 15:45:41
Done.
|
+ |
+#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/containers/mru_cache.h" |
Marc Treib
2016/03/21 12:32:21
not needed
atanasova
2016/03/22 15:45:41
Done.
|
+#include "base/macros.h" |
+#include "url/gurl.h" |
+ |
+class GURL; |
+class Profile; |
+ |
+namespace net { |
+class URLFetcher; |
+class URLReportContextGetter; |
+} |
+ |
+class SafeSearchUrlReporter : public OAuth2TokenService::Consumer, |
+ public net::URLFetcherDelegate { |
+ public: |
+ SafeSearchUrlReporter(OAuth2TokenService* oauth2_token_service, |
+ const std::string& account_id, |
+ net::URLRequestContextGetter* context); |
+ ~SafeSearchUrlReporter() override; |
+ |
+ typedef base::Callback<void(bool)> SuccessCallback; |
Marc Treib
2016/03/21 12:32:21
nit: I prefer
using SuccessCallback = ...
atanasova
2016/03/22 15:45:41
Done.
|
+ |
+ 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_; |
Marc Treib
2016/03/21 12:32:21
Optional: I think all of these can be const.
atanasova
2016/03/22 15:45:41
Actually the methods that are using them do not wo
Marc Treib
2016/03/22 16:06:49
Acknowledged.
|
+ |
+ std::vector<scoped_ptr<Report>> reports_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SafeSearchUrlReporter); |
+}; |
+ |
+#endif // CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SAFE_SEARCH_URL_REPORTER_H_ |