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

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: Refactor code 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 2014 The Chromium Authors. All rights reserved.
Marc Treib 2016/03/21 12:32:21 2016 :)
atanasova 2016/03/22 15:45:41 Done.
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 <stddef.h>
Marc Treib 2016/03/21 12:32:21 probably not needed?
atanasova 2016/03/22 15:45:41 Done.
9
10 #include "base/memory/scoped_ptr.h"
11 #include "google_apis/gaia/oauth2_token_service.h"
12 #include "net/url_request/url_fetcher_delegate.h"
13 #include "base/callback_forward.h"
14 #include "base/containers/mru_cache.h"
Marc Treib 2016/03/21 12:32:21 not needed
atanasova 2016/03/22 15:45:41 Done.
15 #include "base/macros.h"
16 #include "url/gurl.h"
17
18 class GURL;
19 class Profile;
20
21 namespace net {
22 class URLFetcher;
23 class URLReportContextGetter;
24 }
25
26 class SafeSearchUrlReporter : public OAuth2TokenService::Consumer,
27 public net::URLFetcherDelegate {
28 public:
29 SafeSearchUrlReporter(OAuth2TokenService* oauth2_token_service,
30 const std::string& account_id,
31 net::URLRequestContextGetter* context);
32 ~SafeSearchUrlReporter() override;
33
34 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.
35
36 static scoped_ptr<SafeSearchUrlReporter> CreateWithProfile(Profile* profile);
37
38 void ReportUrl(const GURL& url, const SuccessCallback& callback);
39
40 void set_url_fetcher_id_for_testing(int id) { url_fetcher_id_ = id; }
41
42 private:
43 struct Report;
44 using ReportIterator = std::vector<scoped_ptr<Report>>::iterator;
45
46 // OAuth2TokenService::Consumer implementation:
47 void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
48 const std::string& access_token,
49 const base::Time& expiration_time) override;
50 void OnGetTokenFailure(const OAuth2TokenService::Request* request,
51 const GoogleServiceAuthError& error) override;
52
53 // net::URLFetcherDelegate implementation.
54 void OnURLFetchComplete(const net::URLFetcher* source) override;
55
56 // Requests an access token, which is the first thing we need. This is where
57 // we restart when the returned access token has expired.
58 void StartFetching(Report* Report);
59
60 void DispatchResult(ReportIterator it, bool success);
61
62 OAuth2TokenService* oauth2_token_service_;
63 std::string account_id_;
64 net::URLRequestContextGetter* context_;
65 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.
66
67 std::vector<scoped_ptr<Report>> reports_;
68
69 DISALLOW_COPY_AND_ASSIGN(SafeSearchUrlReporter);
70 };
71
72 #endif // CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SAFE_SEARCH_URL_REPORTER_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698