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

Side by Side 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, 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
OLDNEW
(Empty)
1 // Copyright (c) 2009 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 #include "chrome/browser/privacy_blacklist/blacklist_test_util.h"
6
7 #include "base/file_path.h"
8 #include "base/values.h"
9 #include "chrome/common/extensions/extension.h"
10 #include "chrome/common/extensions/extension_constants.h"
11 #include "chrome/common/notification_service.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 BlacklistTestingProfile::BlacklistTestingProfile() {
15 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
16 path_ = temp_dir_.path();
17 }
18
19 TestBlacklistPathProvider::TestBlacklistPathProvider(Profile* profile)
20 : profile_(profile) {
21 }
22
23 bool TestBlacklistPathProvider::AreBlacklistPathsReady() const {
24 return true;
25 }
26
27 std::vector<FilePath> TestBlacklistPathProvider::GetPersistentBlacklistPaths() {
28 return persistent_paths_;
29 }
30
31 std::vector<FilePath> TestBlacklistPathProvider::GetTransientBlacklistPaths() {
32 return transient_paths_;
33 }
34
35 void TestBlacklistPathProvider::AddPersistentPath(const FilePath& path) {
36 persistent_paths_.push_back(path);
37 SendUpdateNotification();
38 }
39
40 void TestBlacklistPathProvider::AddTransientPath(const FilePath& path) {
41 transient_paths_.push_back(path);
42 SendUpdateNotification();
43 }
44
45 void TestBlacklistPathProvider::clear() {
46 persistent_paths_.clear();
47 transient_paths_.clear();
48 SendUpdateNotification();
49 }
50
51 void TestBlacklistPathProvider::SendUpdateNotification() {
52 ListValue* privacy_blacklists = new ListValue;
53 privacy_blacklists->Append(new StringValue("dummy.pbl"));
54
55 DictionaryValue manifest;
56 manifest.SetString(extension_manifest_keys::kVersion, "1.0");
57 manifest.SetString(extension_manifest_keys::kName, "test");
58 manifest.Set(extension_manifest_keys::kPrivacyBlacklists,
59 privacy_blacklists);
60
61 // Create an extension with dummy path.
62 #if defined(OS_WIN)
63 FilePath path(FILE_PATH_LITERAL("c:\\foo"));
64 #elif defined(OS_POSIX)
65 FilePath path(FILE_PATH_LITERAL("/foo"));
66 #endif
67 Extension extension(path);
68 std::string error;
69 ASSERT_TRUE(extension.InitFromValue(manifest, false, &error));
70 ASSERT_TRUE(error.empty());
71
72 NotificationService::current()->Notify(
73 NotificationType::EXTENSION_LOADED,
74 Source<Profile>(profile_),
75 Details<Extension>(&extension));
76 }
OLDNEW
« 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