Chromium Code Reviews

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

Issue 753683004: Revert of Supervised user SafeSites: Expose & use API key from src-internal (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« 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...)
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);
36 SupervisedUserAsyncURLChecker(net::URLRequestContextGetter* context, 37 SupervisedUserAsyncURLChecker(net::URLRequestContextGetter* context,
37 const std::string& cx, 38 const std::string& cx,
39 const std::string& api_key,
38 size_t cache_size); 40 size_t cache_size);
39 virtual ~SupervisedUserAsyncURLChecker(); 41 virtual ~SupervisedUserAsyncURLChecker();
40 42
41 // Returns whether |callback| was run synchronously. 43 // Returns whether |callback| was run synchronously.
42 bool CheckURL(const GURL& url, const CheckCallback& callback); 44 bool CheckURL(const GURL& url, const CheckCallback& callback);
43 45
44 private: 46 private:
45 struct Check; 47 struct Check;
46 struct CheckResult { 48 struct CheckResult {
47 CheckResult(SupervisedUserURLFilter::FilteringBehavior behavior, 49 CheckResult(SupervisedUserURLFilter::FilteringBehavior behavior,
48 bool uncertain); 50 bool uncertain);
49 SupervisedUserURLFilter::FilteringBehavior behavior; 51 SupervisedUserURLFilter::FilteringBehavior behavior;
50 bool uncertain; 52 bool uncertain;
51 }; 53 };
52 54
55 void SetApiKey(const std::string& api_key);
56
53 // net::URLFetcherDelegate implementation. 57 // net::URLFetcherDelegate implementation.
54 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; 58 virtual void OnURLFetchComplete(const net::URLFetcher* source) override;
55 59
56 net::URLRequestContextGetter* context_; 60 net::URLRequestContextGetter* context_;
57 std::string cx_; 61 std::string cx_;
62 std::string api_key_;
58 63
59 ScopedVector<Check> checks_in_progress_; 64 ScopedVector<Check> checks_in_progress_;
60 65
61 base::MRUCache<GURL, CheckResult> cache_; 66 base::MRUCache<GURL, CheckResult> cache_;
62 67
63 DISALLOW_COPY_AND_ASSIGN(SupervisedUserAsyncURLChecker); 68 DISALLOW_COPY_AND_ASSIGN(SupervisedUserAsyncURLChecker);
64 }; 69 };
65 70
66 #endif // CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_ASYNC_URL _CHECKER_H_ 71 #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