| 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "chrome/common/extensions/extension.h" | 11 #include "chrome/common/extensions/manifest.h" |
| 12 | 12 |
| 13 class AsyncExtensionFunction; | 13 class AsyncExtensionFunction; |
| 14 class Browser; | 14 class Browser; |
| 15 class UIThreadExtensionFunction; | 15 class UIThreadExtensionFunction; |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 class Value; | 18 class Value; |
| 19 class DictionaryValue; | 19 class DictionaryValue; |
| 20 class ListValue; | 20 class ListValue; |
| 21 } | 21 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 45 // If |val| is a list, return it as one, otherwise NULL. | 45 // If |val| is a list, return it as one, otherwise NULL. |
| 46 base::ListValue* ToList(base::Value* val); | 46 base::ListValue* ToList(base::Value* val); |
| 47 | 47 |
| 48 // Creates an extension instance that can be attached to an ExtensionFunction | 48 // Creates an extension instance that can be attached to an ExtensionFunction |
| 49 // before running it. | 49 // before running it. |
| 50 scoped_refptr<extensions::Extension> CreateEmptyExtension(); | 50 scoped_refptr<extensions::Extension> CreateEmptyExtension(); |
| 51 | 51 |
| 52 // Creates an extension instance with a specified location that can be attached | 52 // Creates an extension instance with a specified location that can be attached |
| 53 // to an ExtensionFunction before running. | 53 // to an ExtensionFunction before running. |
| 54 scoped_refptr<extensions::Extension> CreateEmptyExtensionWithLocation( | 54 scoped_refptr<extensions::Extension> CreateEmptyExtensionWithLocation( |
| 55 extensions::Extension::Location location); | 55 extensions::Manifest::Location location); |
| 56 | 56 |
| 57 // Creates an empty extension with a variable ID, for tests that require | 57 // Creates an empty extension with a variable ID, for tests that require |
| 58 // multiple extensions side-by-side having distinct IDs. If not empty, then | 58 // multiple extensions side-by-side having distinct IDs. If not empty, then |
| 59 // id_input is passed directly to Extension::CreateId() and thus has the same | 59 // id_input is passed directly to Extension::CreateId() and thus has the same |
| 60 // behavior as that method. If id_input is empty, then Extension::Create() | 60 // behavior as that method. If id_input is empty, then Extension::Create() |
| 61 // receives an empty explicit ID and generates an appropriate ID for a blank | 61 // receives an empty explicit ID and generates an appropriate ID for a blank |
| 62 // extension. | 62 // extension. |
| 63 scoped_refptr<extensions::Extension> CreateEmptyExtension( | 63 scoped_refptr<extensions::Extension> CreateEmptyExtension( |
| 64 const std::string& id_input); | 64 const std::string& id_input); |
| 65 | 65 |
| 66 scoped_refptr<extensions::Extension> CreateExtension( | 66 scoped_refptr<extensions::Extension> CreateExtension( |
| 67 extensions::Extension::Location location, | 67 extensions::Manifest::Location location, |
| 68 base::DictionaryValue* test_extension_value, | 68 base::DictionaryValue* test_extension_value, |
| 69 const std::string& id_input); | 69 const std::string& id_input); |
| 70 | 70 |
| 71 // Creates an extension instance with a specified extension value that can be | 71 // Creates an extension instance with a specified extension value that can be |
| 72 // attached to an ExtensionFunction before running. | 72 // attached to an ExtensionFunction before running. |
| 73 scoped_refptr<extensions::Extension> CreateExtension( | 73 scoped_refptr<extensions::Extension> CreateExtension( |
| 74 base::DictionaryValue* test_extension_value); | 74 base::DictionaryValue* test_extension_value); |
| 75 | 75 |
| 76 scoped_refptr<extensions::Extension> CreateExtension( | 76 scoped_refptr<extensions::Extension> CreateExtension( |
| 77 extensions::Extension::Location location, | 77 extensions::Manifest::Location location, |
| 78 base::DictionaryValue* test_extension_value); | 78 base::DictionaryValue* test_extension_value); |
| 79 | 79 |
| 80 // Returns true if |val| contains privacy information, e.g. url, | 80 // Returns true if |val| contains privacy information, e.g. url, |
| 81 // title, and faviconUrl. | 81 // title, and faviconUrl. |
| 82 bool HasPrivacySensitiveFields(base::DictionaryValue* val); | 82 bool HasPrivacySensitiveFields(base::DictionaryValue* val); |
| 83 | 83 |
| 84 enum RunFunctionFlags { | 84 enum RunFunctionFlags { |
| 85 NONE = 0, | 85 NONE = 0, |
| 86 INCLUDE_INCOGNITO = 1 << 0 | 86 INCLUDE_INCOGNITO = 1 << 0 |
| 87 }; | 87 }; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // we're going to need to frob for all the different extension functions. But | 120 // we're going to need to frob for all the different extension functions. But |
| 121 // we can refactor when we see what is needed. | 121 // we can refactor when we see what is needed. |
| 122 bool RunFunction(UIThreadExtensionFunction* function, | 122 bool RunFunction(UIThreadExtensionFunction* function, |
| 123 const std::string& args, | 123 const std::string& args, |
| 124 Browser* browser, | 124 Browser* browser, |
| 125 RunFunctionFlags flags); | 125 RunFunctionFlags flags); |
| 126 | 126 |
| 127 } // namespace extension_function_test_utils | 127 } // namespace extension_function_test_utils |
| 128 | 128 |
| 129 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ | 129 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ |
| OLD | NEW |