| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 i != permissions.end(); ++i) { | 518 i != permissions.end(); ++i) { |
| 519 permissions_list->AppendString(*i); | 519 permissions_list->AppendString(*i); |
| 520 } | 520 } |
| 521 values.Set("permissions", permissions_list.release()); | 521 values.Set("permissions", permissions_list.release()); |
| 522 } | 522 } |
| 523 | 523 |
| 524 std::string error; | 524 std::string error; |
| 525 scoped_refptr<Extension> extension(Extension::Create( | 525 scoped_refptr<Extension> extension(Extension::Create( |
| 526 base::FilePath(), Manifest::INTERNAL, values, Extension::NO_FLAGS, | 526 base::FilePath(), Manifest::INTERNAL, values, Extension::NO_FLAGS, |
| 527 &error)); | 527 &error)); |
| 528 CHECK(extension.get()) << error; | 528 CHECK(extension.get()); |
| 529 return extension; | 529 return extension; |
| 530 } | 530 } |
| 531 | 531 |
| 532 TEST(ExtensionAPITest, HostedAppPermissions) { | 532 TEST(ExtensionAPITest, HostedAppPermissions) { |
| 533 scoped_refptr<Extension> extension = CreateHostedApp(); | 533 scoped_refptr<Extension> extension = CreateHostedApp(); |
| 534 | 534 |
| 535 std::unique_ptr<ExtensionAPI> extension_api( | 535 std::unique_ptr<ExtensionAPI> extension_api( |
| 536 ExtensionAPI::CreateWithDefaultConfiguration()); | 536 ExtensionAPI::CreateWithDefaultConfiguration()); |
| 537 | 537 |
| 538 // "runtime" and "tabs" should not be available in hosted apps. | 538 // "runtime" and "tabs" should not be available in hosted apps. |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 EXPECT_TRUE(feature->platforms().empty()); | 747 EXPECT_TRUE(feature->platforms().empty()); |
| 748 EXPECT_EQ(0, feature->min_manifest_version()); | 748 EXPECT_EQ(0, feature->min_manifest_version()); |
| 749 EXPECT_EQ(0, feature->max_manifest_version()); | 749 EXPECT_EQ(0, feature->max_manifest_version()); |
| 750 } | 750 } |
| 751 } | 751 } |
| 752 | 752 |
| 753 static const base::DictionaryValue* GetDictChecked( | 753 static const base::DictionaryValue* GetDictChecked( |
| 754 const base::DictionaryValue* dict, | 754 const base::DictionaryValue* dict, |
| 755 const std::string& key) { | 755 const std::string& key) { |
| 756 const base::DictionaryValue* out = nullptr; | 756 const base::DictionaryValue* out = nullptr; |
| 757 CHECK(dict->GetDictionary(key, &out)) << key; | 757 CHECK(dict->GetDictionary(key, &out)); |
| 758 return out; | 758 return out; |
| 759 } | 759 } |
| 760 | 760 |
| 761 static std::string GetStringChecked(const base::DictionaryValue* dict, | 761 static std::string GetStringChecked(const base::DictionaryValue* dict, |
| 762 const std::string& key) { | 762 const std::string& key) { |
| 763 std::string out; | 763 std::string out; |
| 764 CHECK(dict->GetString(key, &out)) << key; | 764 CHECK(dict->GetString(key, &out)); |
| 765 return out; | 765 return out; |
| 766 } | 766 } |
| 767 | 767 |
| 768 TEST(ExtensionAPITest, TypesHaveNamespace) { | 768 TEST(ExtensionAPITest, TypesHaveNamespace) { |
| 769 std::unique_ptr<ExtensionAPI> api( | 769 std::unique_ptr<ExtensionAPI> api( |
| 770 ExtensionAPI::CreateWithDefaultConfiguration()); | 770 ExtensionAPI::CreateWithDefaultConfiguration()); |
| 771 | 771 |
| 772 // Returns the dictionary that has |key|: |value|. | 772 // Returns the dictionary that has |key|: |value|. |
| 773 auto get_dict_from_list = []( | 773 auto get_dict_from_list = []( |
| 774 const base::ListValue* list, const std::string& key, | 774 const base::ListValue* list, const std::string& key, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 CheckAliasStatus::NOT_ALLOWED) | 920 CheckAliasStatus::NOT_ALLOWED) |
| 921 .is_available()); | 921 .is_available()); |
| 922 EXPECT_FALSE(extension_api | 922 EXPECT_FALSE(extension_api |
| 923 ->IsAvailable("pageAction", extension.get(), | 923 ->IsAvailable("pageAction", extension.get(), |
| 924 Feature::BLESSED_EXTENSION_CONTEXT, GURL(), | 924 Feature::BLESSED_EXTENSION_CONTEXT, GURL(), |
| 925 CheckAliasStatus::NOT_ALLOWED) | 925 CheckAliasStatus::NOT_ALLOWED) |
| 926 .is_available()); | 926 .is_available()); |
| 927 } | 927 } |
| 928 | 928 |
| 929 } // namespace extensions | 929 } // namespace extensions |
| OLD | NEW |