blob: d014e5ba9133474a0b63b27fc7ded03cc062c743 [file] [log] [blame]
[email protected]c454fe672012-03-12 21:18:011// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]a9c23a52010-08-04 09:13:442// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]365c724e2011-03-31 15:21:025// Defines the Chrome Extensions Proxy Settings API relevant classes to realize
[email protected]2fc29622011-12-09 23:00:366// the API as specified in the extension API JSON.
[email protected]365c724e2011-03-31 15:21:027
[email protected]c454fe672012-03-12 21:18:018#ifndef CHROME_BROWSER_EXTENSIONS_API_PROXY_PROXY_API_H_
9#define CHROME_BROWSER_EXTENSIONS_API_PROXY_PROXY_API_H_
[email protected]a9c23a52010-08-04 09:13:4410
11#include <string>
12
avia2f4804a2015-12-24 23:11:1313#include "base/macros.h"
[email protected]3b63f8f42011-03-28 01:54:1514#include "base/memory/singleton.h"
[email protected]135e4782012-09-19 20:36:5215#include "chrome/browser/extensions/api/preference/preference_api.h"
stevenjbb237e2ae2015-07-02 22:02:1116#include "components/proxy_config/proxy_prefs.h"
[email protected]18f4ea52011-02-14 12:00:4617
[email protected]f3a1c642011-07-12 19:15:0318namespace base {
19class Value;
20}
21
[email protected]c454fe672012-03-12 21:18:0122namespace extensions {
[email protected]5a38dfd2012-07-23 23:22:1023class EventRouterForwarder;
[email protected]c454fe672012-03-12 21:18:0124
[email protected]16a35492011-03-25 14:19:3725// Class to convert between the representation of proxy settings used
26// in the Proxy Settings API and the representation used in the PrefStores.
[email protected]365c724e2011-03-31 15:21:0227// This plugs into the ExtensionPreferenceAPI to get and set proxy settings.
[email protected]3e3342692011-03-15 12:03:2728class ProxyPrefTransformer : public PrefTransformerInterface {
[email protected]14cc3d32011-03-14 14:50:5129 public:
[email protected]3e3342692011-03-15 12:03:2730 ProxyPrefTransformer();
Peter Boström53c6c5952021-09-17 09:41:2631
32 ProxyPrefTransformer(const ProxyPrefTransformer&) = delete;
33 ProxyPrefTransformer& operator=(const ProxyPrefTransformer&) = delete;
34
dchengae36a4a2014-10-21 12:36:3635 ~ProxyPrefTransformer() override;
[email protected]14cc3d32011-03-14 14:50:5136
[email protected]3e3342692011-03-15 12:03:2737 // Implementation of PrefTransformerInterface.
vabr9984ea62017-04-10 11:33:4938 std::unique_ptr<base::Value> ExtensionToBrowserPref(
39 const base::Value* extension_pref,
40 std::string* error,
41 bool* bad_message) override;
42 std::unique_ptr<base::Value> BrowserToExtensionPref(
Christian Dullweber331bc512020-08-31 17:13:4743 const base::Value* browser_pref,
44 bool is_incognito_profile) override;
[email protected]14cc3d32011-03-14 14:50:5145};
46
[email protected]8339da462011-02-22 13:23:4747// This class observes proxy error events and routes them to the appropriate
48// extensions listening to those events. All methods must be called on the IO
49// thread unless otherwise specified.
[email protected]c454fe672012-03-12 21:18:0150class ProxyEventRouter {
[email protected]8339da462011-02-22 13:23:4751 public:
[email protected]c454fe672012-03-12 21:18:0152 static ProxyEventRouter* GetInstance();
[email protected]8339da462011-02-22 13:23:4753
[email protected]5a38dfd2012-07-23 23:22:1054 void OnProxyError(EventRouterForwarder* event_router,
[email protected]673514522011-07-13 18:17:1855 void* profile,
[email protected]8339da462011-02-22 13:23:4756 int error_code);
57
[email protected]5a38dfd2012-07-23 23:22:1058 void OnPACScriptError(EventRouterForwarder* event_router,
[email protected]673514522011-07-13 18:17:1859 void* profile,
[email protected]3daf92302011-05-05 15:04:3160 int line_number,
Jan Wilken Dörrief27844b2021-03-11 23:18:4861 const std::u16string& error);
[email protected]3daf92302011-05-05 15:04:3162
[email protected]8339da462011-02-22 13:23:4763 private:
olli.raula36aa8be2015-09-10 11:14:2264 friend struct base::DefaultSingletonTraits<ProxyEventRouter>;
[email protected]8339da462011-02-22 13:23:4765
[email protected]c454fe672012-03-12 21:18:0166 ProxyEventRouter();
67 ~ProxyEventRouter();
[email protected]8339da462011-02-22 13:23:4768
[email protected]c454fe672012-03-12 21:18:0169 DISALLOW_COPY_AND_ASSIGN(ProxyEventRouter);
[email protected]8339da462011-02-22 13:23:4770};
[email protected]a9c23a52010-08-04 09:13:4471
[email protected]c454fe672012-03-12 21:18:0172} // namespace extensions
73
74#endif // CHROME_BROWSER_EXTENSIONS_API_PROXY_PROXY_API_H_