Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: chrome/browser/extensions/extension_function_test_utils.cc

Issue 10919201: Make sure that a given app/extension requests only its own resources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_function_test_utils.h" 5 #include "chrome/browser/extensions/extension_function_test_utils.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 EXPECT_EQ(base::Value::TYPE_LIST, val->GetType()); 98 EXPECT_EQ(base::Value::TYPE_LIST, val->GetType());
99 return static_cast<base::ListValue*>(val); 99 return static_cast<base::ListValue*>(val);
100 } 100 }
101 101
102 scoped_refptr<Extension> CreateEmptyExtension() { 102 scoped_refptr<Extension> CreateEmptyExtension() {
103 return CreateEmptyExtensionWithLocation(Extension::INTERNAL); 103 return CreateEmptyExtensionWithLocation(Extension::INTERNAL);
104 } 104 }
105 105
106 scoped_refptr<Extension> CreateEmptyExtensionWithLocation( 106 scoped_refptr<Extension> CreateEmptyExtensionWithLocation(
107 Extension::Location location) { 107 Extension::Location location) {
108 return CreateEmptyExtension(location, std::string());
109 }
110
111 scoped_refptr<Extension> CreateEmptyExtension(Extension::Location location,
112 const std::string& id_input) {
108 std::string error; 113 std::string error;
109 const FilePath test_extension_path; 114 const FilePath test_extension_path;
110 scoped_ptr<base::DictionaryValue> test_extension_value( 115 scoped_ptr<base::DictionaryValue> test_extension_value(
111 ParseDictionary("{\"name\": \"Test\", \"version\": \"1.0\"}")); 116 ParseDictionary("{\"name\": \"Test\", \"version\": \"1.0\"}"));
117 std::string id;
118 if (!id_input.empty())
119 CHECK(Extension::GenerateId(id_input, &id));
112 scoped_refptr<Extension> extension(Extension::Create( 120 scoped_refptr<Extension> extension(Extension::Create(
113 test_extension_path, 121 test_extension_path,
114 location, 122 location,
115 *test_extension_value.get(), 123 *test_extension_value.get(),
116 Extension::NO_FLAGS, 124 Extension::NO_FLAGS,
125 id,
117 &error)); 126 &error));
118 EXPECT_TRUE(error.empty()) << "Could not parse test extension " << error; 127 EXPECT_TRUE(error.empty()) << "Could not parse test extension " << error;
119 return extension; 128 return extension;
120 } 129 }
121 130
122 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, 131 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function,
123 const std::string& args, 132 const std::string& args,
124 Browser* browser) { 133 Browser* browser) {
125 return RunFunctionAndReturnError(function, args, browser, NONE); 134 return RunFunctionAndReturnError(function, args, browser, NONE);
126 } 135 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 if (!response_delegate.HasResponse()) { 234 if (!response_delegate.HasResponse()) {
226 response_delegate.set_should_post_quit(true); 235 response_delegate.set_should_post_quit(true);
227 content::RunMessageLoop(); 236 content::RunMessageLoop();
228 } 237 }
229 238
230 EXPECT_TRUE(response_delegate.HasResponse()); 239 EXPECT_TRUE(response_delegate.HasResponse());
231 return response_delegate.GetResponse(); 240 return response_delegate.GetResponse();
232 } 241 }
233 242
234 } // namespace extension_function_test_utils 243 } // namespace extension_function_test_utils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698