| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PROXY_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PROXY_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROXY_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROXY_API_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/browser/extensions/extension_function.h" | 10 #include "chrome/browser/extensions/extension_function.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 class UseCustomProxySettingsFunction : public ProxySettingsFunction { | 25 class UseCustomProxySettingsFunction : public ProxySettingsFunction { |
| 26 public: | 26 public: |
| 27 virtual ~UseCustomProxySettingsFunction() {} | 27 virtual ~UseCustomProxySettingsFunction() {} |
| 28 virtual bool RunImpl(); | 28 virtual bool RunImpl(); |
| 29 | 29 |
| 30 DECLARE_EXTENSION_FUNCTION_NAME("experimental.proxy.useCustomProxySettings") | 30 DECLARE_EXTENSION_FUNCTION_NAME("experimental.proxy.useCustomProxySettings") |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 // Temporary data container to pass structured elements between functions. |
| 33 struct ProxyServer { | 34 struct ProxyServer { |
| 34 enum { | 35 enum { |
| 35 INVALID_PORT = -1 | 36 INVALID_PORT = -1 |
| 36 }; | 37 }; |
| 37 ProxyServer() : scheme("http"), host(""), port(INVALID_PORT) {} | 38 ProxyServer() : scheme("http"), host(""), port(INVALID_PORT) {} |
| 38 | 39 |
| 39 // The scheme of the proxy URI itself. | 40 // The scheme of the proxy URI itself. |
| 40 std::string scheme; | 41 std::string scheme; |
| 41 std::string host; | 42 std::string host; |
| 42 int port; | 43 int port; |
| 43 }; | 44 }; |
| 44 | 45 |
| 46 // Converts a proxy server description |dict| as passed by the API caller |
| 47 // (e.g. for the http proxy in the rules element) and converts it to a |
| 48 // ProxyServer. Returns true if successful. |
| 45 bool GetProxyServer(const DictionaryValue* dict, ProxyServer* proxy_server); | 49 bool GetProxyServer(const DictionaryValue* dict, ProxyServer* proxy_server); |
| 46 | 50 |
| 47 bool ApplyMode(const std::string& mode, bool incognito); | 51 // Converts a proxy "rules" element passed by the API caller into a proxy |
| 48 bool ApplyPacScript(DictionaryValue* pac_dict, bool incognito); | 52 // configuration string that can be used by the proxy subsystem (see |
| 49 bool ApplyProxyRules(DictionaryValue* proxy_rules, bool incognito); | 53 // proxy_config.h). Returns true if successful. |
| 54 bool GetProxyRules(DictionaryValue* proxy_rules, std::string* out); |
| 50 }; | 55 }; |
| 51 | 56 |
| 52 class RemoveCustomProxySettingsFunction : public ProxySettingsFunction { | 57 class RemoveCustomProxySettingsFunction : public ProxySettingsFunction { |
| 53 public: | 58 public: |
| 54 virtual ~RemoveCustomProxySettingsFunction() {} | 59 virtual ~RemoveCustomProxySettingsFunction() {} |
| 55 virtual bool RunImpl(); | 60 virtual bool RunImpl(); |
| 56 | 61 |
| 57 DECLARE_EXTENSION_FUNCTION_NAME( | 62 DECLARE_EXTENSION_FUNCTION_NAME( |
| 58 "experimental.proxy.removeCustomProxySettings") | 63 "experimental.proxy.removeCustomProxySettings") |
| 59 }; | 64 }; |
| 60 | 65 |
| 61 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROXY_API_H_ | 66 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROXY_API_H_ |
| OLD | NEW |