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

Side by Side 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, 9 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SAFE_SEARCH_URL_REPORTER_H_
6 #define CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SAFE_SEARCH_URL_REPORTER_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "google_apis/gaia/oauth2_token_service.h"
10 #include "net/url_request/url_fetcher_delegate.h"
11 #include "base/callback_forward.h"
12 #include "base/macros.h"
13 #include "url/gurl.h"
14
15 class GURL;
16 class Profile;
17
18 namespace net {
19 class URLFetcher;
20 class URLReportContextGetter;
21 }
22
23 class SafeSearchURLReporter : public OAuth2TokenService::Consumer,
24 public net::URLFetcherDelegate {
25 public:
26 SafeSearchURLReporter(OAuth2TokenService* oauth2_token_service,
27 const std::string& account_id,
28 net::URLRequestContextGetter* context);
29 ~SafeSearchURLReporter() override;
30
31 using SuccessCallback = base::Callback<void(bool)>;
Pam (message me for reviews) 2016/03/23 18:31:48 nit: By the style guide, this goes above the ctor.
atanasova 2016/03/23 18:45:02 Done.
32
33 static scoped_ptr<SafeSearchURLReporter> CreateWithProfile(Profile* profile);
34
35 void ReportUrl(const GURL& url, const SuccessCallback& callback);
36
37 void set_url_fetcher_id_for_testing(int id) { url_fetcher_id_ = id; }
38
39 private:
40 struct Report;
41 using ReportIterator = std::vector<scoped_ptr<Report>>::iterator;
42
43 // OAuth2TokenService::Consumer implementation:
44 void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
45 const std::string& access_token,
46 const base::Time& expiration_time) override;
47 void OnGetTokenFailure(const OAuth2TokenService::Request* request,
48 const GoogleServiceAuthError& error) override;
49
50 // net::URLFetcherDelegate implementation.
51 void OnURLFetchComplete(const net::URLFetcher* source) override;
52
53 // Requests an access token, which is the first thing we need. This is where
54 // we restart when the returned access token has expired.
55 void StartFetching(Report* Report);
56
57 void DispatchResult(ReportIterator it, bool success);
58
59 OAuth2TokenService* oauth2_token_service_;
60 std::string account_id_;
61 net::URLRequestContextGetter* context_;
62 int url_fetcher_id_;
63
64 std::vector<scoped_ptr<Report>> reports_;
65
66 DISALLOW_COPY_AND_ASSIGN(SafeSearchURLReporter);
67 };
68
69 #endif // CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SAFE_SEARCH_URL_REPORTER_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698