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 10 matching lines...) Expand all Loading... |
21 const char* pref_path, Value* pref_value, bool incognito); | 21 const char* pref_path, Value* pref_value, bool incognito); |
22 void RemovePreference(const char* pref_path, bool incognito); | 22 void RemovePreference(const char* pref_path, bool incognito); |
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 | |
32 private: | |
33 // Temporary data container to pass structured elements between functions. | |
34 struct ProxyServer { | |
35 enum { | |
36 INVALID_PORT = -1 | |
37 }; | |
38 ProxyServer() : scheme("http"), host(""), port(INVALID_PORT) {} | |
39 | |
40 // The scheme of the proxy URI itself. | |
41 std::string scheme; | |
42 std::string host; | |
43 int port; | |
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. | |
49 bool GetProxyServer(const DictionaryValue* dict, ProxyServer* proxy_server); | |
50 | |
51 // Converts a proxy "rules" element passed by the API caller into a proxy | |
52 // configuration string that can be used by the proxy subsystem (see | |
53 // proxy_config.h). Returns true if successful. | |
54 bool GetProxyRules(DictionaryValue* proxy_rules, std::string* out); | |
55 }; | 31 }; |
56 | 32 |
57 class RemoveCustomProxySettingsFunction : public ProxySettingsFunction { | 33 class RemoveCustomProxySettingsFunction : public ProxySettingsFunction { |
58 public: | 34 public: |
59 virtual ~RemoveCustomProxySettingsFunction() {} | 35 virtual ~RemoveCustomProxySettingsFunction() {} |
60 virtual bool RunImpl(); | 36 virtual bool RunImpl(); |
61 | 37 |
62 DECLARE_EXTENSION_FUNCTION_NAME( | 38 DECLARE_EXTENSION_FUNCTION_NAME( |
63 "experimental.proxy.removeCustomProxySettings") | 39 "experimental.proxy.removeCustomProxySettings") |
64 }; | 40 }; |
65 | 41 |
66 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROXY_API_H_ | 42 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROXY_API_H_ |
OLD | NEW |