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

Unified Diff: chrome/browser/privacy_blacklist/blacklist_test_util.cc

Issue 501082: Implement delaying resource requests until privacy blacklists are ready. (Closed)
Patch Set: don't get stuck on errors Created 10 years, 12 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/privacy_blacklist/blacklist_test_util.cc
diff --git a/chrome/browser/privacy_blacklist/blacklist_test_util.cc b/chrome/browser/privacy_blacklist/blacklist_test_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..da4fdc96bd5f2231e803bb64e576e0f53d641afd
--- /dev/null
+++ b/chrome/browser/privacy_blacklist/blacklist_test_util.cc
@@ -0,0 +1,76 @@
+// Copyright (c) 2009 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.
+
+#include "chrome/browser/privacy_blacklist/blacklist_test_util.h"
+
+#include "base/file_path.h"
+#include "base/values.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/extension_constants.h"
+#include "chrome/common/notification_service.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+BlacklistTestingProfile::BlacklistTestingProfile() {
+ EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
+ path_ = temp_dir_.path();
+}
+
+TestBlacklistPathProvider::TestBlacklistPathProvider(Profile* profile)
+ : profile_(profile) {
+}
+
+bool TestBlacklistPathProvider::AreBlacklistPathsReady() const {
+ return true;
+}
+
+std::vector<FilePath> TestBlacklistPathProvider::GetPersistentBlacklistPaths() {
+ return persistent_paths_;
+}
+
+std::vector<FilePath> TestBlacklistPathProvider::GetTransientBlacklistPaths() {
+ return transient_paths_;
+}
+
+void TestBlacklistPathProvider::AddPersistentPath(const FilePath& path) {
+ persistent_paths_.push_back(path);
+ SendUpdateNotification();
+}
+
+void TestBlacklistPathProvider::AddTransientPath(const FilePath& path) {
+ transient_paths_.push_back(path);
+ SendUpdateNotification();
+}
+
+void TestBlacklistPathProvider::clear() {
+ persistent_paths_.clear();
+ transient_paths_.clear();
+ SendUpdateNotification();
+}
+
+void TestBlacklistPathProvider::SendUpdateNotification() {
+ ListValue* privacy_blacklists = new ListValue;
+ privacy_blacklists->Append(new StringValue("dummy.pbl"));
+
+ DictionaryValue manifest;
+ manifest.SetString(extension_manifest_keys::kVersion, "1.0");
+ manifest.SetString(extension_manifest_keys::kName, "test");
+ manifest.Set(extension_manifest_keys::kPrivacyBlacklists,
+ privacy_blacklists);
+
+ // Create an extension with dummy path.
+#if defined(OS_WIN)
+ FilePath path(FILE_PATH_LITERAL("c:\\foo"));
+#elif defined(OS_POSIX)
+ FilePath path(FILE_PATH_LITERAL("/foo"));
+#endif
+ Extension extension(path);
+ std::string error;
+ ASSERT_TRUE(extension.InitFromValue(manifest, false, &error));
+ ASSERT_TRUE(error.empty());
+
+ NotificationService::current()->Notify(
+ NotificationType::EXTENSION_LOADED,
+ Source<Profile>(profile_),
+ Details<Extension>(&extension));
+}
« no previous file with comments | « chrome/browser/privacy_blacklist/blacklist_test_util.h ('k') | chrome/browser/privacy_blacklist/blacklist_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698