OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/extension_permission_set.h" | 5 #include "chrome/common/extensions/extension_permission_set.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
865 scriptable_hosts.AddPattern( | 865 scriptable_hosts.AddPattern( |
866 URLPattern(URLPattern::SCHEME_HTTP, "http://*.example.com/*")); | 866 URLPattern(URLPattern::SCHEME_HTTP, "http://*.example.com/*")); |
867 | 867 |
868 expected.insert("*.google.com"); | 868 expected.insert("*.google.com"); |
869 expected.insert("*.example.com"); | 869 expected.insert("*.example.com"); |
870 | 870 |
871 perm_set = new ExtensionPermissionSet( | 871 perm_set = new ExtensionPermissionSet( |
872 empty_perms, explicit_hosts, scriptable_hosts); | 872 empty_perms, explicit_hosts, scriptable_hosts); |
873 EXPECT_EQ(expected, perm_set->GetDistinctHostsForDisplay()); | 873 EXPECT_EQ(expected, perm_set->GetDistinctHostsForDisplay()); |
874 } | 874 } |
875 | |
876 { | |
877 // We don't display warnings for file URLs because they are off by default. | |
878 SCOPED_TRACE("file urls"); | |
asargent_no_longer_on_chrome
2011/08/05 22:56:37
Whoa, SCOPED_TRACE is awesome! I had never heard o
| |
879 explicit_hosts.ClearPatterns(); | |
880 scriptable_hosts.ClearPatterns(); | |
881 expected.clear(); | |
882 | |
883 explicit_hosts.AddPattern( | |
884 URLPattern(URLPattern::SCHEME_FILE, "file:///*")); | |
885 | |
886 perm_set = new ExtensionPermissionSet( | |
887 empty_perms, explicit_hosts, scriptable_hosts); | |
888 EXPECT_EQ(expected, perm_set->GetDistinctHostsForDisplay()); | |
889 } | |
875 } | 890 } |
876 | 891 |
877 TEST(ExtensionPermissionSetTest, GetDistinctHostsForDisplay_ComIsBestRcd) { | 892 TEST(ExtensionPermissionSetTest, GetDistinctHostsForDisplay_ComIsBestRcd) { |
878 scoped_refptr<ExtensionPermissionSet> perm_set; | 893 scoped_refptr<ExtensionPermissionSet> perm_set; |
879 ExtensionAPIPermissionSet empty_perms; | 894 ExtensionAPIPermissionSet empty_perms; |
880 URLPatternSet explicit_hosts; | 895 URLPatternSet explicit_hosts; |
881 URLPatternSet scriptable_hosts; | 896 URLPatternSet scriptable_hosts; |
882 explicit_hosts.AddPattern( | 897 explicit_hosts.AddPattern( |
883 URLPattern(URLPattern::SCHEME_HTTP, "http://www.foo.ca/path")); | 898 URLPattern(URLPattern::SCHEME_HTTP, "http://www.foo.ca/path")); |
884 explicit_hosts.AddPattern( | 899 explicit_hosts.AddPattern( |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1081 AddPattern(&non_empty_extent, "http://www.google.com/*"); | 1096 AddPattern(&non_empty_extent, "http://www.google.com/*"); |
1082 | 1097 |
1083 perm_set = new ExtensionPermissionSet( | 1098 perm_set = new ExtensionPermissionSet( |
1084 empty_apis, non_empty_extent, empty_extent); | 1099 empty_apis, non_empty_extent, empty_extent); |
1085 EXPECT_FALSE(perm_set->IsEmpty()); | 1100 EXPECT_FALSE(perm_set->IsEmpty()); |
1086 | 1101 |
1087 perm_set = new ExtensionPermissionSet( | 1102 perm_set = new ExtensionPermissionSet( |
1088 empty_apis, empty_extent, non_empty_extent); | 1103 empty_apis, empty_extent, non_empty_extent); |
1089 EXPECT_FALSE(perm_set->IsEmpty()); | 1104 EXPECT_FALSE(perm_set->IsEmpty()); |
1090 } | 1105 } |
OLD | NEW |