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

Side by Side 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, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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/supports_user_data.h"
12 #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.
13 #include "base/timer.h"
14 #include "net/url_request/url_fetcher_delegate.h"
15
16 class GURL;
17
18 namespace content {
19 class BrowserContext;
20 }
21
22 namespace net {
23 class URLRequestContextGetter;
24 class URLFetcher;
Ilya Sherman 2013/01/31 05:01:29 nit: Alphabetize
benquan 2013/01/31 23:17:08 Done.
25 }
26
27 namespace autofill {
28 namespace autocheckout {
29
30 // WhitelistManager is responsible for download and caching Autocheckout
31 // 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.
32 class WhitelistManager : public net::URLFetcherDelegate,
33 public base::SupportsUserData::Data {
34 public:
35 static WhitelistManager* GetForBrowserContext(
36 content::BrowserContext* context);
37
38 // Matches the url with whitelist and return the matched url prefix.
39 // Returns empty string when it is not matched.
40 std::string GetMatchedURLPrefix(const GURL& url) const;
41
42 protected:
43 explicit WhitelistManager(net::URLRequestContextGetter* context_getter);
44
45 // Schedules a future call to TriggerDownload if one isn't already pending.
46 virtual void ScheduleDownload(size_t interval_seconds);
47
48 // Start the download timer. It is called by ScheduleDownload(), and exposed
49 // as a separate method for mocking out in tests.
50 virtual void StartDownloadTimer(size_t interval_seconds);
51
52 // Timer callback indicating it's time to download whitelist from server.
53 void TriggerDownload();
54
55 // Used by tests only.
56 void StopDownloadTimer();
57
58 const std::vector<std::string>& url_prefixes() const {
59 return url_prefixes_;
60 }
61
62 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.
63
64 void set_callback_is_pending(bool callback_is_pending) {
65 callback_is_pending_ = callback_is_pending;
66 }
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.
67
68 private:
69 // Implements net::URLFetcherDelegate.
70 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
71
72 // Parse whitelist data and build whitelist.
73 void BuildWhitelist(const std::string& data);
74
75 // A list of whitelisted url prefixes.
76 std::vector<std::string> url_prefixes_;
77
78 base::OneShotTimer<WhitelistManager> download_timer_;
79
80 // Indicates that the last triggered download hasn't resolved yet.
81 bool callback_is_pending_;
82
83 // The context for the request.
84 net::URLRequestContextGetter* const context_getter_; // WEAK
85
86 // State of the kEnableExperimentalFormFilling flag.
87 const bool experimental_form_filling_enabled_;
88
89 // The request object.
90 scoped_ptr<net::URLFetcher> request_;
91
92 DISALLOW_COPY_AND_ASSIGN(WhitelistManager);
93 };
94
95 } // namespace autocheckout
96 } // namespace autofill
97
98 #endif // CHROME_BROWSER_AUTOFILL_AUTOCHECKOUT_WHITELIST_MANAGER_H_
99
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698