OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 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_AUTOFILL_AUTOCHECKOUT_WHITELIST_MANAGER_H_ | |
6 #define CHROME_BROWSER_AUTOFILL_AUTOCHECKOUT_WHITELIST_MANAGER_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/gtest_prod_util.h" | |
ahutter
2013/01/19 02:07:16
Where are you using this?
benquan
2013/01/23 23:50:53
Done.
| |
12 #include "base/memory/ref_counted.h" | |
13 #include "base/supports_user_data.h" | |
14 #include "base/time.h" | |
15 #include "net/url_request/url_fetcher_delegate.h" | |
16 | |
17 class GURL; | |
18 | |
19 namespace content { | |
20 class BrowserContext; | |
21 } | |
22 | |
23 namespace net { | |
24 class URLRequestContextGetter; | |
25 class URLFetcher; | |
26 } | |
27 | |
28 namespace autocheckout { | |
29 | |
30 // WhitelistManager is responsible for download and caching autocheckout | |
ahutter
2013/01/19 02:07:16
nit: Autocheckout
benquan
2013/01/23 23:50:53
Done.
| |
31 // whitelist from the server. | |
32 class WhitelistManager : public net::URLFetcherDelegate, | |
33 public base::SupportsUserData::Data { | |
ahutter
2013/01/19 02:07:16
Comments in SupportsUserData say you need a virtua
benquan
2013/01/23 23:50:53
That comment seems not necessary, because virtual-
| |
34 public: | |
35 | |
36 static WhitelistManager* GetForBrowserContext( | |
37 content::BrowserContext* context); | |
38 static void RemoveFromBrowserContext( | |
39 content::BrowserContext* context); | |
40 | |
41 // Checks if the given url is whitelisted. | |
42 bool IsAutocheckoutEnabled(const GURL& url); | |
43 | |
44 private: | |
45 explicit WhitelistManager(net::URLRequestContextGetter* context_getter); | |
46 | |
47 // Download whitelist file from the server and build memory cache. | |
48 // Returns true if net::URLFetcher query is initiated. | |
49 bool DownloadWhitelist(); | |
50 | |
51 // Implements net::URLFetcherDelegate. | |
52 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | |
53 | |
54 // Parse whitelist data and build whitelist | |
55 void BuildWhitelist(const std::string& data); | |
56 | |
57 // The context for the request. | |
58 scoped_refptr<net::URLRequestContextGetter> context_getter_; | |
59 | |
60 // Time when next whitelist query is allowed. | |
61 base::Time next_query_request_; | |
62 | |
63 // State of the kEnableExperimentalFormFilling flag. | |
64 const bool experimental_form_filling_enabled_; | |
65 | |
66 // The request object. | |
67 scoped_ptr<net::URLFetcher> request_; | |
68 | |
69 // A list of whitelisted url prefixes. | |
70 std::vector<std::string> url_prefixes_; | |
71 | |
72 friend class WhitelistManagerTest; | |
73 | |
74 DISALLOW_COPY_AND_ASSIGN(WhitelistManager); | |
75 }; | |
76 | |
77 } // namespace autocheckout | |
78 | |
79 #endif // CHROME_BROWSER_AUTOFILL_AUTOCHECKOUT_WHITELIST_MANAGER_H_ | |
80 | |
OLD | NEW |