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

Unified Diff: chrome/browser/extensions/blacklist_state_fetcher.h

Issue 49253005: Fetch extension blacklist states from SafeBrowsing server (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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/extensions/blacklist_state_fetcher.h
diff --git a/chrome/browser/extensions/blacklist_state_fetcher.h b/chrome/browser/extensions/blacklist_state_fetcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..20a489c7d15b8b1641aa57e5e02071e45a01cc86
--- /dev/null
+++ b/chrome/browser/extensions/blacklist_state_fetcher.h
@@ -0,0 +1,58 @@
+// Copyright 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_EXTENSIONS_BLACKLIST_STATE_FETCHER_H_
+#define CHROME_BROWSER_EXTENSIONS_BLACKLIST_STATE_FETCHER_H_
mattm 2013/11/25 21:48:55 kinda seems like the fetcher should live in the sa
Oleg Eterevsky 2013/11/27 14:07:38 I thought about it and it seems strange to have bl
mattm 2013/12/03 02:55:45 Well, it's also weird that BlacklistStateFetcher d
+
+#include <set>
+#include <string>
+
+#include "base/callback.h"
+#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/extensions/blacklist.h"
mattm 2013/12/03 02:55:45 This is just for BlacklistState? This is somewhat
Oleg Eterevsky 2013/12/04 10:45:11 As I said, I don't like the idea of some arbitrary
mattm 2013/12/10 11:09:40 I guess either is fine.
Oleg Eterevsky 2013/12/10 17:10:44 Done.
+#include "net/url_request/url_fetcher.h"
+#include "net/url_request/url_fetcher_delegate.h"
+
+namespace extensions {
+
+class BlacklistStateFetcher : public net::URLFetcherDelegate {
+ public:
+ BlacklistStateFetcher();
+
+ ~BlacklistStateFetcher();
+
+ typedef base::Callback<void(Blacklist::BlacklistState)> RequestCallback;
+
+ virtual void Request(const std::string& id, const RequestCallback& callback);
+
+ void SetSafeBrowsingConfig(const SafeBrowsingProtocolConfig& config);
mattm 2013/11/25 21:48:55 Seems cleaner to just pass the config into the con
Oleg Eterevsky 2013/11/27 14:07:38 The config is either passed here (usually in case
mattm 2013/12/03 02:55:45 Right, but with the constructor the unittests can
Oleg Eterevsky 2013/12/04 10:45:11 Ok, makes sense, in case this moves to SafeBrowsin
+
+ protected:
+ // net::URLFetcherDelegate interface.
+ virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
+
+ private:
+ GURL RequestUrl() const;
+
+ SafeBrowsingProtocolConfig safe_browsing_config_;
+ bool safe_browsing_config_initialized_;
+
+ // ID for URLFetchers for testing.
+ int url_fetcher_id_;
+
+ // Extension id by URLFetcher.
+ std::map<const net::URLFetcher*, std::string> requests_;
+
+ typedef std::multimap<std::string, RequestCallback> CallbackMultiMap;
+
+ // Callbacks by extension ID.
+ CallbackMultiMap callbacks_;
+
+ DISALLOW_COPY_AND_ASSIGN(BlacklistStateFetcher);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_BLACKLIST_STATE_FETCHER_H_
+

Powered by Google App Engine
This is Rietveld 408576698