From 0942685d61d6a040a82bffd24728b5ac12b94e27 Mon Sep 17 00:00:00 2001 From: "miket@chromium.org" Date: Tue, 11 Sep 2012 22:39:07 +0000 Subject: 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 --- .../extensions/extension_function_test_utils.cc | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'chrome/browser/extensions/extension_function_test_utils.cc') 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 CreateEmptyExtensionWithLocation( Extension::Location location) { scoped_ptr 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 CreateEmptyExtension( + const std::string& id_input) { + scoped_ptr test_extension_value( + ParseDictionary("{\"name\": \"Test\", \"version\": \"1.0\"}")); + return CreateExtension(Extension::INTERNAL, test_extension_value.get(), + id_input); } scoped_refptr CreateExtension( base::DictionaryValue* test_extension_value) { - return CreateExtension(Extension::INTERNAL, test_extension_value); + return CreateExtension(Extension::INTERNAL, test_extension_value, + std::string()); } scoped_refptr 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::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; -- cgit v1.1