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