blob: e8a4604f4a642e505fc67df8f8e1ffb8d93ddb3d [file] [log] [blame]
[email protected]6d2d55b2012-05-05 21:33:431// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]637bf322011-10-01 20:46:322// 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]637bf322011-10-01 20:46:327
8#include <string>
9
10#include "base/memory/ref_counted.h"
Alex Turner9e78e502021-08-18 20:09:4011#include "base/values.h"
Devlin Cronin35252c2b2018-02-14 00:03:5312#include "extensions/browser/api_test_utils.h"
[email protected]d42c11152013-08-22 19:36:3213#include "extensions/common/manifest.h"
Alex Turner9e78e502021-08-18 20:09:4014#include "third_party/abseil-cpp/absl/types/optional.h"
[email protected]4e3ce3b2011-10-14 23:25:1715
16class Browser;
Clark DuVallfd4db3d2019-07-30 19:10:4317class ExtensionFunction;
[email protected]637bf322011-10-01 20:46:3218
19namespace base {
20class Value;
[email protected]637bf322011-10-01 20:46:3221class ListValue;
22}
23
dchengc963c7142016-04-08 03:55:2224// TODO(ckehoe): Accept args as std::unique_ptr<base::Value>,
[email protected]fc672e12014-08-16 08:16:1525// and migrate existing users to the new API.
yozb6272ef2014-08-28 02:23:0526// This file is DEPRECATED. New tests should use the versions in
27// extensions/browser/api_test_utils.h.
[email protected]637bf322011-10-01 20:46:3228namespace extension_function_test_utils {
29
Alex Turner9e78e502021-08-18 20:09:4030// Parse JSON and return as a list Value, or nullopt if invalid.
31absl::optional<base::Value> ParseList(const std::string& data);
[email protected]637bf322011-10-01 20:46:3232
Stefano Duo70c17b952022-01-21 10:56:0433// If |val| is a dictionary, return it as one, otherwise create an empty one.
34base::Value::DictStorage ToDictionary(std::unique_ptr<base::Value> val);
35base::Value::DictStorage ToDictionary(const base::Value& val);
[email protected]637bf322011-10-01 20:46:3236
[email protected]008ff7fb2011-12-19 08:51:1737// If |val| is a list, return it as one, otherwise NULL.
Istiaque Ahmedea58b452021-11-03 17:33:4738std::unique_ptr<base::ListValue> ToList(std::unique_ptr<base::Value> val);
[email protected]008ff7fb2011-12-19 08:51:1739
Tim Judkins92389f752019-09-20 21:04:1440// Returns true if |val| contains any privacy information, e.g. url,
41// pendingUrl, title or faviconUrl.
Stefano Duo70c17b952022-01-21 10:56:0442bool HasAnyPrivacySensitiveFields(const base::Value::DictStorage& dict);
[email protected]37bb5822012-09-10 15:09:5743
[email protected]637bf322011-10-01 20:46:3244// Run |function| with |args| and return the resulting error. Adds an error to