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

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: revert code change for manual testing/:wq. 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 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"
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;
25 }
26
27 namespace autocheckout {
Ilya Sherman 2013/01/24 22:01:55 nit: Please also wrap this in the autofill namespa
benquan 2013/01/25 00:55:31 Done.
28
29 // WhitelistManager is responsible for download and caching Autocheckout
30 // whitelist from the server.
31 class WhitelistManager : public net::URLFetcherDelegate,
32 public base::SupportsUserData::Data {
Ilya Sherman 2013/01/24 22:01:55 nit: I don't think you need to inherit from Suppor
benquan 2013/01/25 00:55:31 Done.
33 public:
34
Ilya Sherman 2013/01/24 22:01:55 nit: Omit this newline
benquan 2013/01/25 00:55:31 Done.
35 static WhitelistManager* GetForBrowserContext(
36 content::BrowserContext* context);
37
38 // Checks if the given url is whitelisted.
39 bool IsAutocheckoutEnabled(const GURL& url);
40
41 // Schedules a future call to TriggerDownload if one isn't already pending.
42 // Returns true if a new download activity is scheduled.
43 bool ScheduleDownload(int interval_seconds);
Ilya Sherman 2013/01/24 22:01:55 Why is this public?
Ilya Sherman 2013/01/24 22:01:55 nit: Use size_t rather than int, since you never w
benquan 2013/01/25 00:55:31 Done.
benquan 2013/01/25 00:55:31 Done.
44
45 private:
46 explicit WhitelistManager(net::URLRequestContextGetter* context_getter);
47
48 // Timer callback indicating it's time to download whitelist from server.
49 void TriggerDownload();
50
51 // Implements net::URLFetcherDelegate.
52 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
53
54 // Parse whitelist data and build whitelist
Ilya Sherman 2013/01/24 22:01:55 nit: End comment with a period.
Ilya Sherman 2013/01/24 22:01:55 Please describe (at a high level) what format the
benquan 2013/01/25 00:55:31 Done.
benquan 2013/01/25 00:55:31 Done.
55 void BuildWhitelist(const std::string& data);
56
57 // The context for the request.
58 // The pointer value is const, so this can only be set in the constructor.
Ilya Sherman 2013/01/24 22:01:55 nit: Omit this line; it's redundant with the code.
benquan 2013/01/25 00:55:31 Done.
59 // Must not be null.
60 net::URLRequestContextGetter* const context_getter_; // WEAK
61
62 // Indicates that the last triggered download hasn't resolved yet.
63 bool callback_pending_;
Ilya Sherman 2013/01/24 22:01:55 nit: Perhaps name this has_callback_pending_ or ca
benquan 2013/01/25 00:55:31 Done.
64
65 // State of the kEnableExperimentalFormFilling flag.
66 const bool experimental_form_filling_enabled_;
67
68 // The request object.
69 scoped_ptr<net::URLFetcher> request_;
70
71 // A list of whitelisted url prefixes.
72 std::vector<std::string> url_prefixes_;
73
74 base::OneShotTimer<WhitelistManager> download_timer_;
75
76 friend class WhitelistManagerTest;
Ilya Sherman 2013/01/24 22:01:55 Rather than friending the test, which allows the t
benquan 2013/01/25 00:55:31 TestWhitelistManager still can not access Whitelis
Ilya Sherman 2013/01/25 01:22:40 The members should remain private, but you can add
benquan 2013/01/26 02:05:53 Some functions needed by tests are also lifted to
77
78 DISALLOW_COPY_AND_ASSIGN(WhitelistManager);
79 };
80
81 } // namespace autocheckout
82
83 #endif // CHROME_BROWSER_AUTOFILL_AUTOCHECKOUT_WHITELIST_MANAGER_H_
84
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698