OLD | NEW |
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 // Defines the Chrome Extensions Proxy Settings API relevant classes to realize | 5 // Defines the Chrome Extensions Proxy Settings API relevant classes to realize |
6 // the API as specified in the extension API JSON. | 6 // the API as specified in the extension API JSON. |
7 | 7 |
8 #ifndef CHROME_BROWSER_EXTENSIONS_API_PROXY_PROXY_API_H_ | 8 #ifndef CHROME_BROWSER_EXTENSIONS_API_PROXY_PROXY_API_H_ |
9 #define CHROME_BROWSER_EXTENSIONS_API_PROXY_PROXY_API_H_ | 9 #define CHROME_BROWSER_EXTENSIONS_API_PROXY_PROXY_API_H_ |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
14 #include "base/string16.h" | 14 #include "base/string16.h" |
15 #include "chrome/browser/extensions/extension_preference_api.h" | 15 #include "chrome/browser/extensions/extension_preference_api.h" |
16 #include "chrome/browser/prefs/proxy_prefs.h" | 16 #include "chrome/browser/prefs/proxy_prefs.h" |
17 | 17 |
18 class ExtensionEventRouterForwarder; | |
19 | |
20 namespace base { | 18 namespace base { |
21 class Value; | 19 class Value; |
22 } | 20 } |
23 | 21 |
24 namespace extensions { | 22 namespace extensions { |
| 23 class EventRouterForwarder; |
25 | 24 |
26 // Class to convert between the representation of proxy settings used | 25 // Class to convert between the representation of proxy settings used |
27 // in the Proxy Settings API and the representation used in the PrefStores. | 26 // in the Proxy Settings API and the representation used in the PrefStores. |
28 // This plugs into the ExtensionPreferenceAPI to get and set proxy settings. | 27 // This plugs into the ExtensionPreferenceAPI to get and set proxy settings. |
29 class ProxyPrefTransformer : public PrefTransformerInterface { | 28 class ProxyPrefTransformer : public PrefTransformerInterface { |
30 public: | 29 public: |
31 ProxyPrefTransformer(); | 30 ProxyPrefTransformer(); |
32 virtual ~ProxyPrefTransformer(); | 31 virtual ~ProxyPrefTransformer(); |
33 | 32 |
34 // Implementation of PrefTransformerInterface. | 33 // Implementation of PrefTransformerInterface. |
35 virtual base::Value* ExtensionToBrowserPref(const base::Value* extension_pref, | 34 virtual base::Value* ExtensionToBrowserPref(const base::Value* extension_pref, |
36 std::string* error, | 35 std::string* error, |
37 bool* bad_message) OVERRIDE; | 36 bool* bad_message) OVERRIDE; |
38 virtual base::Value* BrowserToExtensionPref( | 37 virtual base::Value* BrowserToExtensionPref( |
39 const base::Value* browser_pref) OVERRIDE; | 38 const base::Value* browser_pref) OVERRIDE; |
40 | 39 |
41 private: | 40 private: |
42 DISALLOW_COPY_AND_ASSIGN(ProxyPrefTransformer); | 41 DISALLOW_COPY_AND_ASSIGN(ProxyPrefTransformer); |
43 }; | 42 }; |
44 | 43 |
45 // This class observes proxy error events and routes them to the appropriate | 44 // This class observes proxy error events and routes them to the appropriate |
46 // extensions listening to those events. All methods must be called on the IO | 45 // extensions listening to those events. All methods must be called on the IO |
47 // thread unless otherwise specified. | 46 // thread unless otherwise specified. |
48 class ProxyEventRouter { | 47 class ProxyEventRouter { |
49 public: | 48 public: |
50 static ProxyEventRouter* GetInstance(); | 49 static ProxyEventRouter* GetInstance(); |
51 | 50 |
52 void OnProxyError(ExtensionEventRouterForwarder* event_router, | 51 void OnProxyError(EventRouterForwarder* event_router, |
53 void* profile, | 52 void* profile, |
54 int error_code); | 53 int error_code); |
55 | 54 |
56 void OnPACScriptError(ExtensionEventRouterForwarder* event_router, | 55 void OnPACScriptError(EventRouterForwarder* event_router, |
57 void* profile, | 56 void* profile, |
58 int line_number, | 57 int line_number, |
59 const string16& error); | 58 const string16& error); |
60 | 59 |
61 private: | 60 private: |
62 friend struct DefaultSingletonTraits<ProxyEventRouter>; | 61 friend struct DefaultSingletonTraits<ProxyEventRouter>; |
63 | 62 |
64 ProxyEventRouter(); | 63 ProxyEventRouter(); |
65 ~ProxyEventRouter(); | 64 ~ProxyEventRouter(); |
66 | 65 |
67 DISALLOW_COPY_AND_ASSIGN(ProxyEventRouter); | 66 DISALLOW_COPY_AND_ASSIGN(ProxyEventRouter); |
68 }; | 67 }; |
69 | 68 |
70 } // namespace extensions | 69 } // namespace extensions |
71 | 70 |
72 #endif // CHROME_BROWSER_EXTENSIONS_API_PROXY_PROXY_API_H_ | 71 #endif // CHROME_BROWSER_EXTENSIONS_API_PROXY_PROXY_API_H_ |
OLD | NEW |