| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 NET_PROXY_PROXY_JS_BINDINGS_H | 5 #ifndef NET_PROXY_PROXY_JS_BINDINGS_H |
| 6 #define NET_PROXY_PROXY_JS_BINDINGS_H | 6 #define NET_PROXY_PROXY_JS_BINDINGS_H |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 class MessageLoop; | 10 class MessageLoop; |
| 11 | 11 |
| 12 namespace net { | 12 namespace net { |
| 13 | 13 |
| 14 class HostResolver; | 14 class HostResolver; |
| 15 | 15 |
| 16 // Interface for the javascript bindings. | 16 // Interface for the javascript bindings. |
| 17 class ProxyResolverJSBindings { | 17 class ProxyResolverJSBindings { |
| 18 public: | 18 public: |
| 19 virtual ~ProxyResolverJSBindings() {} | 19 virtual ~ProxyResolverJSBindings() {} |
| 20 | 20 |
| 21 // Handler for "alert(message)" | 21 // Handler for "alert(message)" |
| 22 virtual void Alert(const std::string& message) = 0; | 22 virtual void Alert(const std::string& message) = 0; |
| 23 | 23 |
| 24 // Handler for "myIpAddress()". Returns empty string on failure. | 24 // Handler for "myIpAddress()". Returns empty string on failure. |
| 25 virtual std::string MyIpAddress() = 0; | 25 virtual std::string MyIpAddress() = 0; |
| 26 | 26 |
| 27 // Handler for "myIpAddressEx()". Returns empty string on failure. |
| 28 // |
| 29 // This is a Microsoft extension to PAC for IPv6, see: |
| 30 // http://blogs.msdn.com/wndp/articles/IPV6_PAC_Extensions_v0_9.aspx |
| 31 virtual std::string MyIpAddressEx() = 0; |
| 32 |
| 27 // Handler for "dnsResolve(host)". Returns empty string on failure. | 33 // Handler for "dnsResolve(host)". Returns empty string on failure. |
| 28 virtual std::string DnsResolve(const std::string& host) = 0; | 34 virtual std::string DnsResolve(const std::string& host) = 0; |
| 29 | 35 |
| 36 // Handler for "dnsResolveEx(host)". Returns empty string on failure. |
| 37 // |
| 38 // This is a Microsoft extension to PAC for IPv6, see: |
| 39 // http://blogs.msdn.com/wndp/articles/IPV6_PAC_Extensions_v0_9.aspx |
| 40 virtual std::string DnsResolveEx(const std::string& host) = 0; |
| 41 |
| 30 // Handler for when an error is encountered. |line_number| may be -1 | 42 // Handler for when an error is encountered. |line_number| may be -1 |
| 31 // if a line number is not applicable to this error. | 43 // if a line number is not applicable to this error. |
| 32 virtual void OnError(int line_number, const std::string& error) = 0; | 44 virtual void OnError(int line_number, const std::string& error) = 0; |
| 33 | 45 |
| 34 // Creates a default javascript bindings implementation that will: | 46 // Creates a default javascript bindings implementation that will: |
| 35 // - Send script error messages to LOG(INFO) | 47 // - Send script error messages to LOG(INFO) |
| 36 // - Send script alert()s to LOG(INFO) | 48 // - Send script alert()s to LOG(INFO) |
| 37 // - Use the provided host resolver to service dnsResolve(). | 49 // - Use the provided host resolver to service dnsResolve(). |
| 38 // | 50 // |
| 39 // |host_resolver| will be used in async mode on |host_resolver_loop|. If | 51 // |host_resolver| will be used in async mode on |host_resolver_loop|. If |
| 40 // |host_resolver_loop| is NULL, then |host_resolver| will be used in sync | 52 // |host_resolver_loop| is NULL, then |host_resolver| will be used in sync |
| 41 // mode on the PAC thread. | 53 // mode on the PAC thread. |
| 42 static ProxyResolverJSBindings* CreateDefault( | 54 static ProxyResolverJSBindings* CreateDefault( |
| 43 HostResolver* host_resolver, MessageLoop* host_resolver_loop); | 55 HostResolver* host_resolver, MessageLoop* host_resolver_loop); |
| 44 }; | 56 }; |
| 45 | 57 |
| 46 } // namespace net | 58 } // namespace net |
| 47 | 59 |
| 48 #endif // NET_PROXY_PROXY_JS_BINDINGS_H | 60 #endif // NET_PROXY_PROXY_JS_BINDINGS_H |
| OLD | NEW |