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

Side by Side Diff: chrome/browser/supervised_user/experimental/supervised_user_async_url_checker.h

Issue 690423003: Supervised user SafeSites: Expose & use API key from src-internal (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years 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
« no previous file with comments | « no previous file | chrome/browser/supervised_user/experimental/supervised_user_async_url_checker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_ASYNC_URL_CH ECKER_H_ 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_ASYNC_URL_CH ECKER_H_
6 #define CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_ASYNC_URL_CH ECKER_H_ 6 #define CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_ASYNC_URL_CH ECKER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
(...skipping 14 matching lines...) Expand all
25 // supervised user, and returns the result asynchronously via a callback. 25 // supervised user, and returns the result asynchronously via a callback.
26 class SupervisedUserAsyncURLChecker : net::URLFetcherDelegate { 26 class SupervisedUserAsyncURLChecker : net::URLFetcherDelegate {
27 public: 27 public:
28 // Returns whether |url| should be blocked. Called from CheckURL. 28 // Returns whether |url| should be blocked. Called from CheckURL.
29 typedef base::Callback<void(const GURL&, 29 typedef base::Callback<void(const GURL&,
30 SupervisedUserURLFilter::FilteringBehavior, 30 SupervisedUserURLFilter::FilteringBehavior,
31 bool /* uncertain */)> 31 bool /* uncertain */)>
32 CheckCallback; 32 CheckCallback;
33 33
34 SupervisedUserAsyncURLChecker(net::URLRequestContextGetter* context, 34 SupervisedUserAsyncURLChecker(net::URLRequestContextGetter* context,
35 const std::string& cx, 35 const std::string& cx);
36 const std::string& api_key);
37 SupervisedUserAsyncURLChecker(net::URLRequestContextGetter* context, 36 SupervisedUserAsyncURLChecker(net::URLRequestContextGetter* context,
38 const std::string& cx, 37 const std::string& cx,
39 const std::string& api_key,
40 size_t cache_size); 38 size_t cache_size);
41 virtual ~SupervisedUserAsyncURLChecker(); 39 virtual ~SupervisedUserAsyncURLChecker();
42 40
43 // Returns whether |callback| was run synchronously. 41 // Returns whether |callback| was run synchronously.
44 bool CheckURL(const GURL& url, const CheckCallback& callback); 42 bool CheckURL(const GURL& url, const CheckCallback& callback);
45 43
46 private: 44 private:
47 struct Check; 45 struct Check;
48 struct CheckResult { 46 struct CheckResult {
49 CheckResult(SupervisedUserURLFilter::FilteringBehavior behavior, 47 CheckResult(SupervisedUserURLFilter::FilteringBehavior behavior,
50 bool uncertain); 48 bool uncertain);
51 SupervisedUserURLFilter::FilteringBehavior behavior; 49 SupervisedUserURLFilter::FilteringBehavior behavior;
52 bool uncertain; 50 bool uncertain;
53 }; 51 };
54 52
55 void SetApiKey(const std::string& api_key);
56
57 // net::URLFetcherDelegate implementation. 53 // net::URLFetcherDelegate implementation.
58 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; 54 virtual void OnURLFetchComplete(const net::URLFetcher* source) override;
59 55
60 net::URLRequestContextGetter* context_; 56 net::URLRequestContextGetter* context_;
61 std::string cx_; 57 std::string cx_;
62 std::string api_key_;
63 58
64 ScopedVector<Check> checks_in_progress_; 59 ScopedVector<Check> checks_in_progress_;
65 60
66 base::MRUCache<GURL, CheckResult> cache_; 61 base::MRUCache<GURL, CheckResult> cache_;
67 62
68 DISALLOW_COPY_AND_ASSIGN(SupervisedUserAsyncURLChecker); 63 DISALLOW_COPY_AND_ASSIGN(SupervisedUserAsyncURLChecker);
69 }; 64 };
70 65
71 #endif // CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_ASYNC_URL _CHECKER_H_ 66 #endif // CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_ASYNC_URL _CHECKER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/supervised_user/experimental/supervised_user_async_url_checker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698