1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Defines the Chrome Extensions Proxy Settings API relevant classes to realize 6 // the API as specified in chrome/common/extensions/api/extension_api.json. 7 8 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PROXY_API_H_ 9 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROXY_API_H_ 10 11 #include <string> 12 13 #include "base/memory/singleton.h" 14 #include "chrome/browser/extensions/extension_preference_api.h" 15 #include "chrome/browser/prefs/proxy_prefs.h" 16 #include "chrome/browser/profiles/profile.h" 17 18 class Value; 19 class ExtensionEventRouterForwarder; 20 21 // Class to convert between the representation of proxy settings used 22 // in the Proxy Settings API and the representation used in the PrefStores. 23 // This plugs into the ExtensionPreferenceAPI to get and set proxy settings. 24 class ProxyPrefTransformer : public PrefTransformerInterface { 25 public: 26 ProxyPrefTransformer(); 27 virtual ~ProxyPrefTransformer(); 28 29 // Implementation of PrefTransformerInterface. 30 virtual Value* ExtensionToBrowserPref(const Value* extension_pref, 31 std::string* error) OVERRIDE; 32 virtual Value* BrowserToExtensionPref(const Value* browser_pref) OVERRIDE; 33 34 private: 35 DISALLOW_COPY_AND_ASSIGN(ProxyPrefTransformer); 36 }; 37 38 // This class observes proxy error events and routes them to the appropriate 39 // extensions listening to those events. All methods must be called on the IO 40 // thread unless otherwise specified. 41 class ExtensionProxyEventRouter { 42 public: 43 static ExtensionProxyEventRouter* GetInstance(); 44 45 void OnProxyError(ExtensionEventRouterForwarder* event_router, 46 ProfileId profile_id, 47 int error_code); 48 49 private: 50 friend struct DefaultSingletonTraits<ExtensionProxyEventRouter>; 51 52 ExtensionProxyEventRouter(); 53 ~ExtensionProxyEventRouter(); 54 55 DISALLOW_COPY_AND_ASSIGN(ExtensionProxyEventRouter); 56 }; 57 58 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROXY_API_H_ 59