diff options
author | miket@chromium.org <miket@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-11 22:39:07 +0000 |
---|---|---|
committer | miket@chromium.org <miket@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-11 22:39:07 +0000 |
commit | 0942685d61d6a040a82bffd24728b5ac12b94e27 (patch) | |
tree | 582becb1a972155217e5d08e4afde171e3e3992f /chrome/browser/extensions/extension_function_test_utils.cc | |
parent | 26dae7de0ce12e5ada8bdc2c956e46de9c13d80a (diff) | |
download | chromium_src-0942685d61d6a040a82bffd24728b5ac12b94e27.zip chromium_src-0942685d61d6a040a82bffd24728b5ac12b94e27.tar.gz chromium_src-0942685d61d6a040a82bffd24728b5ac12b94e27.tar.bz2 |
Make sure that a given app/extension requests only its own resources.
All ApiResources of a given type live in a single pool. Until now, one
app could send arbitrary resource IDs in and get another app's resources
if it were lucky. Now we check that an app is getting back only its own
resources.
Note that this CL could have been shorter if I hadn't decided to break
out the owner_extension_id in ApiResource's constructor. I decided to
do this anyway because the other way to get that information (asking
ApiResourceEventNotifier) violated the Law of Demeter, or even if it
was a technical non-violation, I didn't feel good about relying on
the incidental fact that AREN knew the extension ID.
Ben for OWNERS
TBR=ben@chromium.org
BUG=142521
TEST=added
Review URL: https://chromiumcodereview.appspot.com/10919201
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156149 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_function_test_utils.cc')
-rw-r--r-- | chrome/browser/extensions/extension_function_test_utils.cc | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/chrome/browser/extensions/extension_function_test_utils.cc b/chrome/browser/extensions/extension_function_test_utils.cc index 2f8bfc6..d352966 100644 --- a/chrome/browser/extensions/extension_function_test_utils.cc +++ b/chrome/browser/extensions/extension_function_test_utils.cc @@ -109,24 +109,38 @@ scoped_refptr<Extension> CreateEmptyExtensionWithLocation( Extension::Location location) { scoped_ptr<base::DictionaryValue> test_extension_value( ParseDictionary("{\"name\": \"Test\", \"version\": \"1.0\"}")); - return CreateExtension(location, test_extension_value.get()); + return CreateExtension(location, test_extension_value.get(), std::string()); +} + +scoped_refptr<Extension> CreateEmptyExtension( + const std::string& id_input) { + scoped_ptr<base::DictionaryValue> test_extension_value( + ParseDictionary("{\"name\": \"Test\", \"version\": \"1.0\"}")); + return CreateExtension(Extension::INTERNAL, test_extension_value.get(), + id_input); } scoped_refptr<Extension> CreateExtension( base::DictionaryValue* test_extension_value) { - return CreateExtension(Extension::INTERNAL, test_extension_value); + return CreateExtension(Extension::INTERNAL, test_extension_value, + std::string()); } scoped_refptr<Extension> CreateExtension( Extension::Location location, - base::DictionaryValue* test_extension_value) { + base::DictionaryValue* test_extension_value, + const std::string& id_input) { std::string error; const FilePath test_extension_path; + std::string id; + if (!id_input.empty()) + CHECK(Extension::GenerateId(id_input, &id)); scoped_refptr<Extension> extension(Extension::Create( test_extension_path, location, *test_extension_value, Extension::NO_FLAGS, + id, &error)); EXPECT_TRUE(error.empty()) << "Could not parse test extension " << error; return extension; |