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 "extensions/common/extension_api.h" | 5 #include "extensions/common/extension_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 { "management.getPermissionWarningsByManifest", true }, | 800 { "management.getPermissionWarningsByManifest", true }, |
801 { "management.uninstallSelf", true }, | 801 { "management.uninstallSelf", true }, |
802 // But other functions in those modules do. | 802 // But other functions in those modules do. |
803 { "management.getPermissionWarningsById", false }, | 803 { "management.getPermissionWarningsById", false }, |
804 { "runtime.connectNative", false }, | 804 { "runtime.connectNative", false }, |
805 }; | 805 }; |
806 | 806 |
807 scoped_ptr<ExtensionAPI> extension_api( | 807 scoped_ptr<ExtensionAPI> extension_api( |
808 ExtensionAPI::CreateWithDefaultConfiguration()); | 808 ExtensionAPI::CreateWithDefaultConfiguration()); |
809 scoped_refptr<Extension> extension = | 809 scoped_refptr<Extension> extension = |
810 BuildExtension(ExtensionBuilder().Pass()).Build(); | 810 BuildExtension(ExtensionBuilder()).Build(); |
811 | 811 |
812 for (size_t i = 0; i < arraysize(kTests); ++i) { | 812 for (size_t i = 0; i < arraysize(kTests); ++i) { |
813 EXPECT_EQ(kTests[i].expect_success, | 813 EXPECT_EQ(kTests[i].expect_success, |
814 extension_api->IsAvailable(kTests[i].permission_name, | 814 extension_api->IsAvailable(kTests[i].permission_name, |
815 extension.get(), | 815 extension.get(), |
816 Feature::BLESSED_EXTENSION_CONTEXT, | 816 Feature::BLESSED_EXTENSION_CONTEXT, |
817 GURL()).is_available()) | 817 GURL()).is_available()) |
818 << "Permission being tested: " << kTests[i].permission_name; | 818 << "Permission being tested: " << kTests[i].permission_name; |
819 } | 819 } |
820 } | 820 } |
821 | 821 |
822 // Tests that permissions that require manifest keys are available when those | 822 // Tests that permissions that require manifest keys are available when those |
823 // keys are present. | 823 // keys are present. |
824 TEST(ExtensionAPITest, ManifestKeys) { | 824 TEST(ExtensionAPITest, ManifestKeys) { |
825 scoped_ptr<ExtensionAPI> extension_api( | 825 scoped_ptr<ExtensionAPI> extension_api( |
826 ExtensionAPI::CreateWithDefaultConfiguration()); | 826 ExtensionAPI::CreateWithDefaultConfiguration()); |
827 | 827 |
828 scoped_refptr<Extension> extension = | 828 scoped_refptr<Extension> extension = |
829 BuildExtension(ExtensionBuilder().Pass()) | 829 BuildExtension(ExtensionBuilder()) |
830 .MergeManifest(DictionaryBuilder().Set("browser_action", | 830 .MergeManifest(DictionaryBuilder().Set("browser_action", |
831 DictionaryBuilder().Pass())) | 831 DictionaryBuilder().Pass())) |
832 .Build(); | 832 .Build(); |
833 | 833 |
834 EXPECT_TRUE(extension_api->IsAvailable("browserAction", | 834 EXPECT_TRUE(extension_api->IsAvailable("browserAction", |
835 extension.get(), | 835 extension.get(), |
836 Feature::BLESSED_EXTENSION_CONTEXT, | 836 Feature::BLESSED_EXTENSION_CONTEXT, |
837 GURL()).is_available()); | 837 GURL()).is_available()); |
838 EXPECT_FALSE(extension_api->IsAvailable("pageAction", | 838 EXPECT_FALSE(extension_api->IsAvailable("pageAction", |
839 extension.get(), | 839 extension.get(), |
840 Feature::BLESSED_EXTENSION_CONTEXT, | 840 Feature::BLESSED_EXTENSION_CONTEXT, |
841 GURL()).is_available()); | 841 GURL()).is_available()); |
842 } | 842 } |
843 | 843 |
844 } // namespace extensions | 844 } // namespace extensions |
OLD | NEW |