OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/extensions/extension_prefs_unittest.h" | 5 #include "chrome/browser/extensions/extension_prefs_unittest.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/prefs/mock_pref_change_callback.h" | 10 #include "base/prefs/mock_pref_change_callback.h" |
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
906 // Other preferences should be untouched. | 906 // Other preferences should be untouched. |
907 EXPECT_TRUE(prefs()->AllowFileAccess(extension_a_->id())); | 907 EXPECT_TRUE(prefs()->AllowFileAccess(extension_a_->id())); |
908 } | 908 } |
909 | 909 |
910 private: | 910 private: |
911 scoped_refptr<const Extension> extension_a_; | 911 scoped_refptr<const Extension> extension_a_; |
912 scoped_refptr<const Extension> extension_b_; | 912 scoped_refptr<const Extension> extension_b_; |
913 }; | 913 }; |
914 TEST_F(ExtensionPrefsClearLastLaunched, ExtensionPrefsClearLastLaunched) {} | 914 TEST_F(ExtensionPrefsClearLastLaunched, ExtensionPrefsClearLastLaunched) {} |
915 | 915 |
916 class ExtensionPrefsComponentExtension : public ExtensionPrefsTest { | |
917 public: | |
918 ~ExtensionPrefsComponentExtension() override {} | |
919 void Initialize() override { | |
920 component_extension_ = | |
921 prefs_.AddExtensionWithManifestLocation("test", Manifest::COMPONENT); | |
not at google - send to devlin
2015/04/10 17:49:26
I don't understand. This isn't what I asked you to
Deepak
2015/04/11 05:35:26
Done.
| |
922 no_component_extension_ = prefs_.AddExtension("a"); | |
923 | |
924 APIPermissionSet api_perms; | |
925 api_perms.insert(APIPermission::kTab); | |
926 api_perms.insert(APIPermission::kBookmark); | |
927 api_perms.insert(APIPermission::kHistory); | |
928 | |
929 ManifestPermissionSet empty_manifest_permissions; | |
930 | |
931 URLPatternSet ehosts, shosts; | |
932 AddPattern(&shosts, "chrome://print/*"); | |
933 | |
934 active_perms_ = new PermissionSet(api_perms, empty_manifest_permissions, | |
935 ehosts, shosts); | |
936 // Set the active permissions. | |
937 prefs()->SetActivePermissions(component_extension_->id(), | |
938 active_perms_.get()); | |
939 prefs()->SetActivePermissions(no_component_extension_->id(), | |
940 active_perms_.get()); | |
941 } | |
942 | |
943 void Verify() override { | |
944 scoped_refptr<PermissionSet> permissions( | |
945 prefs()->GetActivePermissions(component_extension_->id())); | |
946 EXPECT_EQ(active_perms_->scriptable_hosts(), | |
947 permissions->scriptable_hosts()); | |
948 EXPECT_EQ(*active_perms_.get(), *permissions.get()); | |
949 | |
950 URLPatternSet scriptable_hosts; | |
951 std::string pref_key = "active_permissions.scriptable_host"; | |
952 EXPECT_TRUE(prefs()->ReadPrefAsURLPatternSet( | |
953 component_extension_->id(), pref_key, &scriptable_hosts, 15)); | |
954 EXPECT_FALSE(prefs()->ReadPrefAsURLPatternSet( | |
955 no_component_extension_->id(), pref_key, &scriptable_hosts, 15)); | |
956 } | |
957 | |
958 private: | |
959 scoped_refptr<PermissionSet> active_perms_; | |
960 scoped_refptr<Extension> component_extension_; | |
961 scoped_refptr<Extension> no_component_extension_; | |
962 }; | |
963 TEST_F(ExtensionPrefsComponentExtension, ExtensionPrefsComponentExtension) { | |
964 } | |
965 | |
916 } // namespace extensions | 966 } // namespace extensions |
OLD | NEW |