| 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 "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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } | 102 } |
| 103 | 103 |
| 104 scoped_refptr<Extension> CreateEmptyExtension() { | 104 scoped_refptr<Extension> CreateEmptyExtension() { |
| 105 return CreateEmptyExtensionWithLocation(Extension::INTERNAL); | 105 return CreateEmptyExtensionWithLocation(Extension::INTERNAL); |
| 106 } | 106 } |
| 107 | 107 |
| 108 scoped_refptr<Extension> CreateEmptyExtensionWithLocation( | 108 scoped_refptr<Extension> CreateEmptyExtensionWithLocation( |
| 109 Extension::Location location) { | 109 Extension::Location location) { |
| 110 scoped_ptr<base::DictionaryValue> test_extension_value( | 110 scoped_ptr<base::DictionaryValue> test_extension_value( |
| 111 ParseDictionary("{\"name\": \"Test\", \"version\": \"1.0\"}")); | 111 ParseDictionary("{\"name\": \"Test\", \"version\": \"1.0\"}")); |
| 112 return CreateExtension(location, test_extension_value.get()); | 112 return CreateExtension(location, test_extension_value.get(), std::string()); |
| 113 } |
| 114 |
| 115 scoped_refptr<Extension> CreateEmptyExtension( |
| 116 const std::string& id_input) { |
| 117 scoped_ptr<base::DictionaryValue> test_extension_value( |
| 118 ParseDictionary("{\"name\": \"Test\", \"version\": \"1.0\"}")); |
| 119 return CreateExtension(Extension::INTERNAL, test_extension_value.get(), |
| 120 id_input); |
| 113 } | 121 } |
| 114 | 122 |
| 115 scoped_refptr<Extension> CreateExtension( | 123 scoped_refptr<Extension> CreateExtension( |
| 116 base::DictionaryValue* test_extension_value) { | 124 base::DictionaryValue* test_extension_value) { |
| 117 return CreateExtension(Extension::INTERNAL, test_extension_value); | 125 return CreateExtension(Extension::INTERNAL, test_extension_value, |
| 126 std::string()); |
| 118 } | 127 } |
| 119 | 128 |
| 120 scoped_refptr<Extension> CreateExtension( | 129 scoped_refptr<Extension> CreateExtension( |
| 121 Extension::Location location, | 130 Extension::Location location, |
| 122 base::DictionaryValue* test_extension_value) { | 131 base::DictionaryValue* test_extension_value, |
| 132 const std::string& id_input) { |
| 123 std::string error; | 133 std::string error; |
| 124 const FilePath test_extension_path; | 134 const FilePath test_extension_path; |
| 135 std::string id; |
| 136 if (!id_input.empty()) |
| 137 CHECK(Extension::GenerateId(id_input, &id)); |
| 125 scoped_refptr<Extension> extension(Extension::Create( | 138 scoped_refptr<Extension> extension(Extension::Create( |
| 126 test_extension_path, | 139 test_extension_path, |
| 127 location, | 140 location, |
| 128 *test_extension_value, | 141 *test_extension_value, |
| 129 Extension::NO_FLAGS, | 142 Extension::NO_FLAGS, |
| 143 id, |
| 130 &error)); | 144 &error)); |
| 131 EXPECT_TRUE(error.empty()) << "Could not parse test extension " << error; | 145 EXPECT_TRUE(error.empty()) << "Could not parse test extension " << error; |
| 132 return extension; | 146 return extension; |
| 133 } | 147 } |
| 134 | 148 |
| 135 bool HasPrivacySensitiveFields(base::DictionaryValue* val) { | 149 bool HasPrivacySensitiveFields(base::DictionaryValue* val) { |
| 136 std::string result; | 150 std::string result; |
| 137 if (val->GetString(keys::kUrlKey, &result) || | 151 if (val->GetString(keys::kUrlKey, &result) || |
| 138 val->GetString(keys::kTitleKey, &result) || | 152 val->GetString(keys::kTitleKey, &result) || |
| 139 val->GetString(keys::kFaviconUrlKey, &result)) | 153 val->GetString(keys::kFaviconUrlKey, &result)) |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 if (!response_delegate.HasResponse()) { | 261 if (!response_delegate.HasResponse()) { |
| 248 response_delegate.set_should_post_quit(true); | 262 response_delegate.set_should_post_quit(true); |
| 249 content::RunMessageLoop(); | 263 content::RunMessageLoop(); |
| 250 } | 264 } |
| 251 | 265 |
| 252 EXPECT_TRUE(response_delegate.HasResponse()); | 266 EXPECT_TRUE(response_delegate.HasResponse()); |
| 253 return response_delegate.GetResponse(); | 267 return response_delegate.GetResponse(); |
| 254 } | 268 } |
| 255 | 269 |
| 256 } // namespace extension_function_test_utils | 270 } // namespace extension_function_test_utils |
| OLD | NEW |