[email protected] | c454fe67 | 2012-03-12 21:18:01 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | a9c23a5 | 2010-08-04 09:13:44 | [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 | |||||
[email protected] | 365c724e | 2011-03-31 15:21:02 | [diff] [blame] | 5 | // Defines the Chrome Extensions Proxy Settings API relevant classes to realize |
[email protected] | 2fc2962 | 2011-12-09 23:00:36 | [diff] [blame] | 6 | // the API as specified in the extension API JSON. |
[email protected] | 365c724e | 2011-03-31 15:21:02 | [diff] [blame] | 7 | |
[email protected] | c454fe67 | 2012-03-12 21:18:01 | [diff] [blame] | 8 | #ifndef CHROME_BROWSER_EXTENSIONS_API_PROXY_PROXY_API_H_ |
9 | #define CHROME_BROWSER_EXTENSIONS_API_PROXY_PROXY_API_H_ | ||||
[email protected] | a9c23a5 | 2010-08-04 09:13:44 | [diff] [blame] | 10 | |
11 | #include <string> | ||||
12 | |||||
avi | a2f4804a | 2015-12-24 23:11:13 | [diff] [blame] | 13 | #include "base/macros.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 14 | #include "base/memory/singleton.h" |
[email protected] | 135e478 | 2012-09-19 20:36:52 | [diff] [blame] | 15 | #include "chrome/browser/extensions/api/preference/preference_api.h" |
stevenjb | b237e2ae | 2015-07-02 22:02:11 | [diff] [blame] | 16 | #include "components/proxy_config/proxy_prefs.h" |
[email protected] | 18f4ea5 | 2011-02-14 12:00:46 | [diff] [blame] | 17 | |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 18 | namespace base { |
19 | class Value; | ||||
20 | } | ||||
21 | |||||
[email protected] | c454fe67 | 2012-03-12 21:18:01 | [diff] [blame] | 22 | namespace extensions { |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 23 | class EventRouterForwarder; |
[email protected] | c454fe67 | 2012-03-12 21:18:01 | [diff] [blame] | 24 | |
[email protected] | 16a3549 | 2011-03-25 14:19:37 | [diff] [blame] | 25 | // 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] | 365c724e | 2011-03-31 15:21:02 | [diff] [blame] | 27 | // This plugs into the ExtensionPreferenceAPI to get and set proxy settings. |
[email protected] | 3e334269 | 2011-03-15 12:03:27 | [diff] [blame] | 28 | class ProxyPrefTransformer : public PrefTransformerInterface { |
[email protected] | 14cc3d3 | 2011-03-14 14:50:51 | [diff] [blame] | 29 | public: |
[email protected] | 3e334269 | 2011-03-15 12:03:27 | [diff] [blame] | 30 | ProxyPrefTransformer(); |
Peter Boström | 53c6c595 | 2021-09-17 09:41:26 | [diff] [blame^] | 31 | |
32 | ProxyPrefTransformer(const ProxyPrefTransformer&) = delete; | ||||
33 | ProxyPrefTransformer& operator=(const ProxyPrefTransformer&) = delete; | ||||
34 | |||||
dcheng | ae36a4a | 2014-10-21 12:36:36 | [diff] [blame] | 35 | ~ProxyPrefTransformer() override; |
[email protected] | 14cc3d3 | 2011-03-14 14:50:51 | [diff] [blame] | 36 | |
[email protected] | 3e334269 | 2011-03-15 12:03:27 | [diff] [blame] | 37 | // Implementation of PrefTransformerInterface. |
vabr | 9984ea6 | 2017-04-10 11:33:49 | [diff] [blame] | 38 | 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 Dullweber | 331bc51 | 2020-08-31 17:13:47 | [diff] [blame] | 43 | const base::Value* browser_pref, |
44 | bool is_incognito_profile) override; | ||||
[email protected] | 14cc3d3 | 2011-03-14 14:50:51 | [diff] [blame] | 45 | }; |
46 | |||||
[email protected] | 8339da46 | 2011-02-22 13:23:47 | [diff] [blame] | 47 | // 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] | c454fe67 | 2012-03-12 21:18:01 | [diff] [blame] | 50 | class ProxyEventRouter { |
[email protected] | 8339da46 | 2011-02-22 13:23:47 | [diff] [blame] | 51 | public: |
[email protected] | c454fe67 | 2012-03-12 21:18:01 | [diff] [blame] | 52 | static ProxyEventRouter* GetInstance(); |
[email protected] | 8339da46 | 2011-02-22 13:23:47 | [diff] [blame] | 53 | |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 54 | void OnProxyError(EventRouterForwarder* event_router, |
[email protected] | 67351452 | 2011-07-13 18:17:18 | [diff] [blame] | 55 | void* profile, |
[email protected] | 8339da46 | 2011-02-22 13:23:47 | [diff] [blame] | 56 | int error_code); |
57 | |||||
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 58 | void OnPACScriptError(EventRouterForwarder* event_router, |
[email protected] | 67351452 | 2011-07-13 18:17:18 | [diff] [blame] | 59 | void* profile, |
[email protected] | 3daf9230 | 2011-05-05 15:04:31 | [diff] [blame] | 60 | int line_number, |
Jan Wilken Dörrie | f27844b | 2021-03-11 23:18:48 | [diff] [blame] | 61 | const std::u16string& error); |
[email protected] | 3daf9230 | 2011-05-05 15:04:31 | [diff] [blame] | 62 | |
[email protected] | 8339da46 | 2011-02-22 13:23:47 | [diff] [blame] | 63 | private: |
olli.raula | 36aa8be | 2015-09-10 11:14:22 | [diff] [blame] | 64 | friend struct base::DefaultSingletonTraits<ProxyEventRouter>; |
[email protected] | 8339da46 | 2011-02-22 13:23:47 | [diff] [blame] | 65 | |
[email protected] | c454fe67 | 2012-03-12 21:18:01 | [diff] [blame] | 66 | ProxyEventRouter(); |
67 | ~ProxyEventRouter(); | ||||
[email protected] | 8339da46 | 2011-02-22 13:23:47 | [diff] [blame] | 68 | |
[email protected] | c454fe67 | 2012-03-12 21:18:01 | [diff] [blame] | 69 | DISALLOW_COPY_AND_ASSIGN(ProxyEventRouter); |
[email protected] | 8339da46 | 2011-02-22 13:23:47 | [diff] [blame] | 70 | }; |
[email protected] | a9c23a5 | 2010-08-04 09:13:44 | [diff] [blame] | 71 | |
[email protected] | c454fe67 | 2012-03-12 21:18:01 | [diff] [blame] | 72 | } // namespace extensions |
73 | |||||
74 | #endif // CHROME_BROWSER_EXTENSIONS_API_PROXY_PROXY_API_H_ |