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

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

Issue 49253005: Fetch extension blacklist states from SafeBrowsing server (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add unit tests, fix bugs. 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/test_blacklist_fetcher.h
diff --git a/chrome/browser/extensions/test_blacklist_fetcher.h b/chrome/browser/extensions/test_blacklist_fetcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..e4f08e121a8705076777ea23a1508f6caa96ac8e
--- /dev/null
+++ b/chrome/browser/extensions/test_blacklist_fetcher.h
@@ -0,0 +1,41 @@
+// 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_TEST_BLACKLIST_FETCHER_H_
+#define CHROME_BROWSER_EXTENSIONS_TEST_BLACKLIST_FETCHER_H_
+
+#include <string>
+
+#include "chrome/browser/extensions/blacklist_fetcher.h"
+#include "chrome/common/safe_browsing/crx_info.pb.h"
+#include "net/url_request/test_url_fetcher_factory.h"
+
+namespace extensions {
+
+// A wrapper for extensions::BlacklistFetcher, emulating server responses.
+class TestBlacklistFetcher {
+ public:
+ explicit TestBlacklistFetcher(BlacklistFetcher* fetcher);
+
+ void SetBlacklistVerdict(const std::string& id,
+ ClientCRXListInfoResponse_Verdict state);
+
+ // Get URLFetcher by its id from factory, send the appropriate response.
+ // Return false, if fetcher with fiven id doesn't exist or in case of
+ // incorrect request. Otherwise return true.
+ bool HandleFetcher(int id);
+
+ private:
+ BlacklistFetcher* fetcher_;
+
+ std::map<std::string, ClientCRXListInfoResponse_Verdict> verdicts_;
+
+ net::TestURLFetcherFactory url_fetcher_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestBlacklistFetcher);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_TEST_BLACKLIST_FETCHER_H_

Powered by Google App Engine
This is Rietveld 408576698