OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <utility> | 5 #include <utility> |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "chrome/browser/extensions/extension_service_test_base.h" | 8 #include "chrome/browser/extensions/extension_service_test_base.h" |
9 #include "chrome/browser/extensions/extension_util.h" | 9 #include "chrome/browser/extensions/extension_util.h" |
10 #include "chrome/browser/extensions/permissions_updater.h" | 10 #include "chrome/browser/extensions/permissions_updater.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 scriptable_host_list.Append(pattern->GetAsString()); | 35 scriptable_host_list.Append(pattern->GetAsString()); |
36 } | 36 } |
37 | 37 |
38 ListBuilder explicit_host_list; | 38 ListBuilder explicit_host_list; |
39 for (std::set<URLPattern>::const_iterator pattern = explicit_hosts.begin(); | 39 for (std::set<URLPattern>::const_iterator pattern = explicit_hosts.begin(); |
40 pattern != explicit_hosts.end(); ++pattern) { | 40 pattern != explicit_hosts.end(); ++pattern) { |
41 explicit_host_list.Append(pattern->GetAsString()); | 41 explicit_host_list.Append(pattern->GetAsString()); |
42 } | 42 } |
43 | 43 |
44 DictionaryBuilder script; | 44 DictionaryBuilder script; |
45 script.Set("matches", std::move(scriptable_host_list)) | 45 script.Set("matches", scriptable_host_list.Build()) |
46 .Set("js", std::move(ListBuilder().Append("foo.js"))); | 46 .Set("js", ListBuilder().Append("foo.js").Build()); |
47 | 47 |
48 return ExtensionBuilder() | 48 return ExtensionBuilder() |
49 .SetLocation(location) | 49 .SetLocation(location) |
50 .SetManifest( | 50 .SetManifest(DictionaryBuilder() |
51 std::move(DictionaryBuilder() | 51 .Set("name", name) |
52 .Set("name", name) | 52 .Set("description", "foo") |
53 .Set("description", "foo") | 53 .Set("manifest_version", 2) |
54 .Set("manifest_version", 2) | 54 .Set("version", "0.1.2.3") |
55 .Set("version", "0.1.2.3") | 55 .Set("content_scripts", |
56 .Set("content_scripts", | 56 ListBuilder().Append(script.Build()).Build()) |
57 std::move(ListBuilder().Append(std::move(script)))) | 57 .Set("permissions", explicit_host_list.Build()) |
58 .Set("permissions", std::move(explicit_host_list)))) | 58 .Build()) |
59 .SetID(crx_file::id_util::GenerateId(name)) | 59 .SetID(crx_file::id_util::GenerateId(name)) |
60 .Build(); | 60 .Build(); |
61 } | 61 } |
62 | 62 |
63 testing::AssertionResult SetsAreEqual(const std::set<URLPattern>& set1, | 63 testing::AssertionResult SetsAreEqual(const std::set<URLPattern>& set1, |
64 const std::set<URLPattern>& set2) { | 64 const std::set<URLPattern>& set2) { |
65 // Take the (set1 - set2) U (set2 - set1). This is then the set of all | 65 // Take the (set1 - set2) U (set2 - set1). This is then the set of all |
66 // elements which are in either set1 or set2, but not both. | 66 // elements which are in either set1 or set2, but not both. |
67 // If the sets are equal, this is none. | 67 // If the sets are equal, this is none. |
68 std::set<URLPattern> difference = base::STLSetUnion<std::set<URLPattern>>( | 68 std::set<URLPattern> difference = base::STLSetUnion<std::set<URLPattern>>( |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 EXPECT_EQ(PermissionsData::ACCESS_WITHHELD, get_page_access(kUrl2)); | 323 EXPECT_EQ(PermissionsData::ACCESS_WITHHELD, get_page_access(kUrl2)); |
324 | 324 |
325 modifier.RemoveGrantedHostPermission(kUrl); | 325 modifier.RemoveGrantedHostPermission(kUrl); |
326 EXPECT_FALSE(modifier.HasGrantedHostPermission(kUrl)); | 326 EXPECT_FALSE(modifier.HasGrantedHostPermission(kUrl)); |
327 EXPECT_FALSE(modifier.HasGrantedHostPermission(kUrl2)); | 327 EXPECT_FALSE(modifier.HasGrantedHostPermission(kUrl2)); |
328 EXPECT_EQ(PermissionsData::ACCESS_WITHHELD, get_page_access(kUrl)); | 328 EXPECT_EQ(PermissionsData::ACCESS_WITHHELD, get_page_access(kUrl)); |
329 EXPECT_EQ(PermissionsData::ACCESS_WITHHELD, get_page_access(kUrl2)); | 329 EXPECT_EQ(PermissionsData::ACCESS_WITHHELD, get_page_access(kUrl2)); |
330 } | 330 } |
331 | 331 |
332 } // namespace extensions | 332 } // namespace extensions |
OLD | NEW |