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

Unified Diff: chrome/browser/supervised_user/experimental/safe_search_url_reporter.h

Issue 1813833002: Add report URL to safe search API functionality. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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 side-by-side diff with in-line comments
Download patch
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..5cdf68deb57b40b4442e2218c94b634ceee04739
--- /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,
+ public net::URLFetcherDelegate {
+ public:
+ using SuccessCallback = base::Callback<void(bool)>;
+
+ SafeSearchURLReporter(OAuth2TokenService* oauth2_token_service,
+ const std::string& account_id,
+ net::URLRequestContextGetter* context);
+ ~SafeSearchURLReporter() override;
+
+ 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_

Powered by Google App Engine
This is Rietveld 408576698