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

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

Issue 12093036: Move Extension Location and Type enums to Manifest, and move InstallWarning to its own file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 #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/extension.h"
12 #include "chrome/common/extensions/manifest.h"
12 13
13 class AsyncExtensionFunction; 14 class AsyncExtensionFunction;
14 class Browser; 15 class Browser;
15 class UIThreadExtensionFunction; 16 class UIThreadExtensionFunction;
16 17
17 namespace base { 18 namespace base {
18 class Value; 19 class Value;
19 class DictionaryValue; 20 class DictionaryValue;
20 class ListValue; 21 class ListValue;
21 } 22 }
22 23
23 namespace extensions {
24 class Extension;
25 }
26
27 namespace extension_function_test_utils { 24 namespace extension_function_test_utils {
28 25
29 // Parse JSON and return as the specified type, or NULL if the JSON is invalid 26 // Parse JSON and return as the specified type, or NULL if the JSON is invalid
30 // or not the specified type. 27 // or not the specified type.
31 base::Value* ParseJSON(const std::string& data); 28 base::Value* ParseJSON(const std::string& data);
32 base::ListValue* ParseList(const std::string& data); 29 base::ListValue* ParseList(const std::string& data);
33 base::DictionaryValue* ParseDictionary(const std::string& data); 30 base::DictionaryValue* ParseDictionary(const std::string& data);
34 31
35 // Get |key| from |val| as the specified type. If |key| does not exist, or is 32 // Get |key| from |val| as the specified type. If |key| does not exist, or is
36 // not of the specified type, adds a failure to the current test and returns 33 // not of the specified type, adds a failure to the current test and returns
37 // false, 0, empty string, etc. 34 // false, 0, empty string, etc.
38 bool GetBoolean(base::DictionaryValue* val, const std::string& key); 35 bool GetBoolean(base::DictionaryValue* val, const std::string& key);
39 int GetInteger(base::DictionaryValue* val, const std::string& key); 36 int GetInteger(base::DictionaryValue* val, const std::string& key);
40 std::string GetString(base::DictionaryValue* val, const std::string& key); 37 std::string GetString(base::DictionaryValue* val, const std::string& key);
41 38
42 // If |val| is a dictionary, return it as one, otherwise NULL. 39 // If |val| is a dictionary, return it as one, otherwise NULL.
43 base::DictionaryValue* ToDictionary(base::Value* val); 40 base::DictionaryValue* ToDictionary(base::Value* val);
44 41
45 // If |val| is a list, return it as one, otherwise NULL. 42 // If |val| is a list, return it as one, otherwise NULL.
46 base::ListValue* ToList(base::Value* val); 43 base::ListValue* ToList(base::Value* val);
47 44
48 // Creates an extension instance that can be attached to an ExtensionFunction 45 // Creates an extension instance that can be attached to an ExtensionFunction
49 // before running it. 46 // before running it.
50 scoped_refptr<extensions::Extension> CreateEmptyExtension(); 47 scoped_refptr<extensions::Extension> CreateEmptyExtension();
51 48
52 // Creates an extension instance with a specified location that can be attached 49 // Creates an extension instance with a specified location that can be attached
53 // to an ExtensionFunction before running. 50 // to an ExtensionFunction before running.
54 scoped_refptr<extensions::Extension> CreateEmptyExtensionWithLocation( 51 scoped_refptr<extensions::Extension> CreateEmptyExtensionWithLocation(
55 extensions::Extension::Location location); 52 extensions::Manifest::Location location);
56 53
57 // Creates an empty extension with a variable ID, for tests that require 54 // 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 55 // 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 56 // 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() 57 // 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 58 // receives an empty explicit ID and generates an appropriate ID for a blank
62 // extension. 59 // extension.
63 scoped_refptr<extensions::Extension> CreateEmptyExtension( 60 scoped_refptr<extensions::Extension> CreateEmptyExtension(
64 const std::string& id_input); 61 const std::string& id_input);
65 62
66 scoped_refptr<extensions::Extension> CreateExtension( 63 scoped_refptr<extensions::Extension> CreateExtension(
67 extensions::Extension::Location location, 64 extensions::Manifest::Location location,
68 base::DictionaryValue* test_extension_value, 65 base::DictionaryValue* test_extension_value,
69 const std::string& id_input); 66 const std::string& id_input);
70 67
71 // Creates an extension instance with a specified extension value that can be 68 // Creates an extension instance with a specified extension value that can be
72 // attached to an ExtensionFunction before running. 69 // attached to an ExtensionFunction before running.
73 scoped_refptr<extensions::Extension> CreateExtension( 70 scoped_refptr<extensions::Extension> CreateExtension(
74 base::DictionaryValue* test_extension_value); 71 base::DictionaryValue* test_extension_value);
75 72
76 scoped_refptr<extensions::Extension> CreateExtension( 73 scoped_refptr<extensions::Extension> CreateExtension(
77 extensions::Extension::Location location, 74 extensions::Manifest::Location location,
78 base::DictionaryValue* test_extension_value); 75 base::DictionaryValue* test_extension_value);
79 76
80 // Returns true if |val| contains privacy information, e.g. url, 77 // Returns true if |val| contains privacy information, e.g. url,
81 // title, and faviconUrl. 78 // title, and faviconUrl.
82 bool HasPrivacySensitiveFields(base::DictionaryValue* val); 79 bool HasPrivacySensitiveFields(base::DictionaryValue* val);
83 80
84 enum RunFunctionFlags { 81 enum RunFunctionFlags {
85 NONE = 0, 82 NONE = 0,
86 INCLUDE_INCOGNITO = 1 << 0 83 INCLUDE_INCOGNITO = 1 << 0
87 }; 84 };
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // we're going to need to frob for all the different extension functions. But 117 // we're going to need to frob for all the different extension functions. But
121 // we can refactor when we see what is needed. 118 // we can refactor when we see what is needed.
122 bool RunFunction(UIThreadExtensionFunction* function, 119 bool RunFunction(UIThreadExtensionFunction* function,
123 const std::string& args, 120 const std::string& args,
124 Browser* browser, 121 Browser* browser,
125 RunFunctionFlags flags); 122 RunFunctionFlags flags);
126 123
127 } // namespace extension_function_test_utils 124 } // namespace extension_function_test_utils
128 125
129 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ 126 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698