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

Unified Diff: chrome/browser/autofill/autocheckout/whitelist_manager.h

Issue 11867025: Download autocheckout whitelist and enable autocheckout for whitelisted sites only. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pass autocheckout url prefix to FormStructure's constructor. Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
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..ac89176a2a243d147f8e289a8e031fe3a8d75dbb
--- /dev/null
+++ b/chrome/browser/autofill/autocheckout/whitelist_manager.h
@@ -0,0 +1,99 @@
+// 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/supports_user_data.h"
+#include "base/time.h"
Ilya Sherman 2013/01/31 05:01:29 nit: Move this to the .cc file.
benquan 2013/01/31 23:17:08 Looks like this is not needed anymore, deleted.
+#include "base/timer.h"
+#include "net/url_request/url_fetcher_delegate.h"
+
+class GURL;
+
+namespace content {
+class BrowserContext;
+}
+
+namespace net {
+class URLRequestContextGetter;
+class URLFetcher;
Ilya Sherman 2013/01/31 05:01:29 nit: Alphabetize
benquan 2013/01/31 23:17:08 Done.
+}
+
+namespace autofill {
+namespace autocheckout {
+
+// WhitelistManager is responsible for download and caching Autocheckout
+// whitelist from the server.
Ilya Sherman 2013/01/31 05:01:29 nit: Suggested tweaked wording: "Downloads and cac
benquan 2013/01/31 23:17:08 Done.
+class WhitelistManager : public net::URLFetcherDelegate,
+ public base::SupportsUserData::Data {
+ public:
+ static WhitelistManager* GetForBrowserContext(
+ content::BrowserContext* context);
+
+ // Matches the url with whitelist and return the matched url prefix.
+ // Returns empty string when it is not matched.
+ std::string GetMatchedURLPrefix(const GURL& url) const;
+
+ protected:
+ explicit WhitelistManager(net::URLRequestContextGetter* context_getter);
+
+ // Schedules a future call to TriggerDownload if one isn't already pending.
+ virtual void ScheduleDownload(size_t interval_seconds);
+
+ // Start the download timer. It is called by ScheduleDownload(), and exposed
+ // as a separate method for mocking out in tests.
+ virtual void StartDownloadTimer(size_t interval_seconds);
+
+ // Timer callback indicating it's time to download whitelist from server.
+ void TriggerDownload();
+
+ // Used by tests only.
+ void StopDownloadTimer();
+
+ const std::vector<std::string>& url_prefixes() const {
+ return url_prefixes_;
+ }
+
+ bool callback_is_pending() const { return callback_is_pending_; }
Ilya Sherman 2013/01/31 05:01:29 nit: This doesn't seem to be used.
benquan 2013/01/31 23:17:08 Done.
+
+ void set_callback_is_pending(bool callback_is_pending) {
+ callback_is_pending_ = callback_is_pending;
+ }
Ilya Sherman 2013/01/31 05:01:29 nit: You could omit this method by setting callbac
benquan 2013/01/31 23:17:08 Done.
+
+ private:
+ // Implements net::URLFetcherDelegate.
+ virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
+
+ // Parse whitelist data and build whitelist.
+ void BuildWhitelist(const std::string& data);
+
+ // A list of whitelisted url prefixes.
+ std::vector<std::string> url_prefixes_;
+
+ base::OneShotTimer<WhitelistManager> download_timer_;
+
+ // Indicates that the last triggered download hasn't resolved yet.
+ bool callback_is_pending_;
+
+ // The context for the request.
+ net::URLRequestContextGetter* const context_getter_; // WEAK
+
+ // State of the kEnableExperimentalFormFilling flag.
+ const bool experimental_form_filling_enabled_;
+
+ // The request object.
+ scoped_ptr<net::URLFetcher> request_;
+
+ DISALLOW_COPY_AND_ASSIGN(WhitelistManager);
+};
+
+} // namespace autocheckout
+} // namespace autofill
+
+#endif // CHROME_BROWSER_AUTOFILL_AUTOCHECKOUT_WHITELIST_MANAGER_H_
+

Powered by Google App Engine
This is Rietveld 408576698