[email protected] | 6d2d55b | 2012-05-05 21:33:43 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 637bf32 | 2011-10-01 20:46:32 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ | ||||
6 | #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ | ||||
[email protected] | 637bf32 | 2011-10-01 20:46:32 | [diff] [blame] | 7 | |
8 | #include <string> | ||||
9 | |||||
10 | #include "base/memory/ref_counted.h" | ||||
Alex Turner | 9e78e50 | 2021-08-18 20:09:40 | [diff] [blame] | 11 | #include "base/values.h" |
Devlin Cronin | 35252c2b | 2018-02-14 00:03:53 | [diff] [blame] | 12 | #include "extensions/browser/api_test_utils.h" |
[email protected] | d42c1115 | 2013-08-22 19:36:32 | [diff] [blame] | 13 | #include "extensions/common/manifest.h" |
Alex Turner | 9e78e50 | 2021-08-18 20:09:40 | [diff] [blame] | 14 | #include "third_party/abseil-cpp/absl/types/optional.h" |
[email protected] | 4e3ce3b | 2011-10-14 23:25:17 | [diff] [blame] | 15 | |
16 | class Browser; | ||||
Clark DuVall | fd4db3d | 2019-07-30 19:10:43 | [diff] [blame] | 17 | class ExtensionFunction; |
[email protected] | 637bf32 | 2011-10-01 20:46:32 | [diff] [blame] | 18 | |
19 | namespace base { | ||||
20 | class Value; | ||||
[email protected] | 637bf32 | 2011-10-01 20:46:32 | [diff] [blame] | 21 | class ListValue; |
22 | } | ||||
23 | |||||
dcheng | c963c714 | 2016-04-08 03:55:22 | [diff] [blame] | 24 | // TODO(ckehoe): Accept args as std::unique_ptr<base::Value>, |
[email protected] | fc672e1 | 2014-08-16 08:16:15 | [diff] [blame] | 25 | // and migrate existing users to the new API. |
yoz | b6272ef | 2014-08-28 02:23:05 | [diff] [blame] | 26 | // This file is DEPRECATED. New tests should use the versions in |
27 | // extensions/browser/api_test_utils.h. | ||||
[email protected] | 637bf32 | 2011-10-01 20:46:32 | [diff] [blame] | 28 | namespace extension_function_test_utils { |
29 | |||||
Alex Turner | 9e78e50 | 2021-08-18 20:09:40 | [diff] [blame] | 30 | // Parse JSON and return as a list Value, or nullopt if invalid. |
31 | absl::optional<base::Value> ParseList(const std::string& data); | ||||
[email protected] | 637bf32 | 2011-10-01 20:46:32 | [diff] [blame] | 32 | |
Stefano Duo | 70c17b95 | 2022-01-21 10:56:04 | [diff] [blame] | 33 | // If |val| is a dictionary, return it as one, otherwise create an empty one. |
34 | base::Value::DictStorage ToDictionary(std::unique_ptr<base::Value> val); | ||||
35 | base::Value::DictStorage ToDictionary(const base::Value& val); | ||||
[email protected] | 637bf32 | 2011-10-01 20:46:32 | [diff] [blame] | 36 | |
[email protected] | 008ff7fb | 2011-12-19 08:51:17 | [diff] [blame] | 37 | // If |val| is a list, return it as one, otherwise NULL. |
Istiaque Ahmed | ea58b45 | 2021-11-03 17:33:47 | [diff] [blame] | 38 | std::unique_ptr<base::ListValue> ToList(std::unique_ptr<base::Value> val); |
[email protected] | 008ff7fb | 2011-12-19 08:51:17 | [diff] [blame] | 39 | |
Tim Judkins | 92389f75 | 2019-09-20 21:04:14 | [diff] [blame] | 40 | // Returns true if |val| contains any privacy information, e.g. url, |
41 | // pendingUrl, title or faviconUrl. | ||||
Stefano Duo | 70c17b95 | 2022-01-21 10:56:04 | [diff] [blame] | 42 | bool HasAnyPrivacySensitiveFields(const base::Value::DictStorage& dict); |
[email protected] | 37bb582 | 2012-09-10 15:09:57 | [diff] [blame] | 43 | |
[email protected] | 637bf32 | 2011-10-01 20:46:32 | [diff] [blame] | 44 | // Run |function| with |args| and return the resulting error. Adds an error to |