OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/pepper_permission_util.h" | 5 #include "chrome/common/pepper_permission_util.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "chrome/common/extensions/features/feature_channel.h" | 10 #include "chrome/common/extensions/features/feature_channel.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 return ExtensionBuilder() | 36 return ExtensionBuilder() |
37 .SetManifest(manifest.Pass()) | 37 .SetManifest(manifest.Pass()) |
38 .AddFlags(Extension::FROM_WEBSTORE) | 38 .AddFlags(Extension::FROM_WEBSTORE) |
39 .SetID(id) | 39 .SetID(id) |
40 .Build(); | 40 .Build(); |
41 } | 41 } |
42 | 42 |
43 } // namespace | 43 } // namespace |
44 | 44 |
45 TEST(PepperPermissionUtilTest, ExtensionWhitelisting) { | 45 TEST(PepperPermissionUtilTest, ExtensionWhitelisting) { |
46 ScopedCurrentChannel current_channel(chrome::VersionInfo::CHANNEL_UNKNOWN); | 46 ScopedCurrentChannel current_channel(version_info::Channel::UNKNOWN); |
47 ExtensionSet extensions; | 47 ExtensionSet extensions; |
48 std::string whitelisted_id = | 48 std::string whitelisted_id = |
49 crx_file::id_util::GenerateId("whitelisted_extension"); | 49 crx_file::id_util::GenerateId("whitelisted_extension"); |
50 scoped_ptr<base::DictionaryValue> manifest = | 50 scoped_ptr<base::DictionaryValue> manifest = |
51 DictionaryBuilder() | 51 DictionaryBuilder() |
52 .Set("name", "Whitelisted Extension") | 52 .Set("name", "Whitelisted Extension") |
53 .Set("version", "1.0") | 53 .Set("version", "1.0") |
54 .Set("manifest_version", 2) | 54 .Set("manifest_version", 2) |
55 .Build(); | 55 .Build(); |
56 scoped_refptr<Extension> ext = ExtensionBuilder() | 56 scoped_refptr<Extension> ext = ExtensionBuilder() |
(...skipping 15 matching lines...) Expand all Loading... |
72 whitelist.insert(whitelisted_id); | 72 whitelist.insert(whitelisted_id); |
73 EXPECT_TRUE( | 73 EXPECT_TRUE( |
74 IsExtensionOrSharedModuleWhitelisted(GURL(url), &extensions, whitelist)); | 74 IsExtensionOrSharedModuleWhitelisted(GURL(url), &extensions, whitelist)); |
75 EXPECT_FALSE(IsExtensionOrSharedModuleWhitelisted( | 75 EXPECT_FALSE(IsExtensionOrSharedModuleWhitelisted( |
76 GURL(bad_scheme_url), &extensions, whitelist)); | 76 GURL(bad_scheme_url), &extensions, whitelist)); |
77 EXPECT_FALSE(IsExtensionOrSharedModuleWhitelisted( | 77 EXPECT_FALSE(IsExtensionOrSharedModuleWhitelisted( |
78 GURL(bad_host_url), &extensions, whitelist)); | 78 GURL(bad_host_url), &extensions, whitelist)); |
79 } | 79 } |
80 | 80 |
81 TEST(PepperPermissionUtilTest, SharedModuleWhitelisting) { | 81 TEST(PepperPermissionUtilTest, SharedModuleWhitelisting) { |
82 ScopedCurrentChannel current_channel(chrome::VersionInfo::CHANNEL_UNKNOWN); | 82 ScopedCurrentChannel current_channel(version_info::Channel::UNKNOWN); |
83 ExtensionSet extensions; | 83 ExtensionSet extensions; |
84 std::string whitelisted_id = crx_file::id_util::GenerateId("extension_id"); | 84 std::string whitelisted_id = crx_file::id_util::GenerateId("extension_id"); |
85 std::string bad_id = crx_file::id_util::GenerateId("bad_id"); | 85 std::string bad_id = crx_file::id_util::GenerateId("bad_id"); |
86 | 86 |
87 scoped_ptr<base::DictionaryValue> shared_module_manifest = | 87 scoped_ptr<base::DictionaryValue> shared_module_manifest = |
88 DictionaryBuilder() | 88 DictionaryBuilder() |
89 .Set("name", "Whitelisted Shared Module") | 89 .Set("name", "Whitelisted Shared Module") |
90 .Set("version", "1.0") | 90 .Set("version", "1.0") |
91 .Set("manifest_version", 2) | 91 .Set("manifest_version", 2) |
92 .Set("export", | 92 .Set("export", |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 GURL(not_in_sm_whitelist_url), &extensions, whitelist)); | 130 GURL(not_in_sm_whitelist_url), &extensions, whitelist)); |
131 | 131 |
132 // Note that the whitelist should be empty after this call, so tests checking | 132 // Note that the whitelist should be empty after this call, so tests checking |
133 // for failure to import will fail because of this. | 133 // for failure to import will fail because of this. |
134 whitelist.erase(shared_module->id()); | 134 whitelist.erase(shared_module->id()); |
135 EXPECT_FALSE(IsExtensionOrSharedModuleWhitelisted( | 135 EXPECT_FALSE(IsExtensionOrSharedModuleWhitelisted( |
136 GURL(extension_url), &extensions, whitelist)); | 136 GURL(extension_url), &extensions, whitelist)); |
137 } | 137 } |
138 | 138 |
139 } // namespace extensions | 139 } // namespace extensions |
OLD | NEW |