Chromium Code Reviews| Index: chrome/browser/autofill/autocheckout/whitelist_manager.h |
| diff --git a/chrome/browser/autofill/autocheckout/whitelist_manager.h b/chrome/browser/autofill/autocheckout/whitelist_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..94f737a4cc9efbe320a50b0614320172cf3acdad |
| --- /dev/null |
| +++ b/chrome/browser/autofill/autocheckout/whitelist_manager.h |
| @@ -0,0 +1,80 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_AUTOFILL_AUTOCHECKOUT_WHITELIST_MANAGER_H_ |
| +#define CHROME_BROWSER_AUTOFILL_AUTOCHECKOUT_WHITELIST_MANAGER_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#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.
|
| +#include "base/memory/ref_counted.h" |
| +#include "base/supports_user_data.h" |
| +#include "base/time.h" |
| +#include "net/url_request/url_fetcher_delegate.h" |
| + |
| +class GURL; |
| + |
| +namespace content { |
| +class BrowserContext; |
| +} |
| + |
| +namespace net { |
| +class URLRequestContextGetter; |
| +class URLFetcher; |
| +} |
| + |
| +namespace autocheckout { |
| + |
| +// 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.
|
| +// whitelist from the server. |
| +class WhitelistManager : public net::URLFetcherDelegate, |
| + 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-
|
| + public: |
| + |
| + static WhitelistManager* GetForBrowserContext( |
| + content::BrowserContext* context); |
| + static void RemoveFromBrowserContext( |
| + content::BrowserContext* context); |
| + |
| + // Checks if the given url is whitelisted. |
| + bool IsAutocheckoutEnabled(const GURL& url); |
| + |
| + private: |
| + explicit WhitelistManager(net::URLRequestContextGetter* context_getter); |
| + |
| + // Download whitelist file from the server and build memory cache. |
| + // Returns true if net::URLFetcher query is initiated. |
| + bool DownloadWhitelist(); |
| + |
| + // Implements net::URLFetcherDelegate. |
| + virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| + |
| + // Parse whitelist data and build whitelist |
| + void BuildWhitelist(const std::string& data); |
| + |
| + // The context for the request. |
| + scoped_refptr<net::URLRequestContextGetter> context_getter_; |
| + |
| + // Time when next whitelist query is allowed. |
| + base::Time next_query_request_; |
| + |
| + // State of the kEnableExperimentalFormFilling flag. |
| + const bool experimental_form_filling_enabled_; |
| + |
| + // The request object. |
| + scoped_ptr<net::URLFetcher> request_; |
| + |
| + // A list of whitelisted url prefixes. |
| + std::vector<std::string> url_prefixes_; |
| + |
| + friend class WhitelistManagerTest; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(WhitelistManager); |
| +}; |
| + |
| +} // namespace autocheckout |
| + |
| +#endif // CHROME_BROWSER_AUTOFILL_AUTOCHECKOUT_WHITELIST_MANAGER_H_ |
| + |