[email protected] | 90ae1fb | 2009-08-02 21:07:12 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef NET_PROXY_PROXY_JS_BINDINGS_H |
| 6 | #define NET_PROXY_PROXY_JS_BINDINGS_H |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | class MessageLoop; |
| 11 | |
| 12 | namespace net { |
| 13 | |
| 14 | class HostResolver; |
| 15 | |
| 16 | // Interface for the javascript bindings. |
| 17 | class ProxyResolverJSBindings { |
| 18 | public: |
| 19 | virtual ~ProxyResolverJSBindings() {} |
| 20 | |
| 21 | // Handler for "alert(message)" |
| 22 | virtual void Alert(const std::string& message) = 0; |
| 23 | |
| 24 | // Handler for "myIpAddress()". Returns empty string on failure. |
| 25 | virtual std::string MyIpAddress() = 0; |
| 26 | |
[email protected] | 21f20c89 | 2009-10-26 23:51:28 | [diff] [blame^] | 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 | |
[email protected] | 90ae1fb | 2009-08-02 21:07:12 | [diff] [blame] | 33 | // Handler for "dnsResolve(host)". Returns empty string on failure. |
| 34 | virtual std::string DnsResolve(const std::string& host) = 0; |
| 35 | |
[email protected] | 21f20c89 | 2009-10-26 23:51:28 | [diff] [blame^] | 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 | |
[email protected] | 90ae1fb | 2009-08-02 21:07:12 | [diff] [blame] | 42 | // Handler for when an error is encountered. |line_number| may be -1 |
| 43 | // if a line number is not applicable to this error. |
| 44 | virtual void OnError(int line_number, const std::string& error) = 0; |
| 45 | |
| 46 | // Creates a default javascript bindings implementation that will: |
| 47 | // - Send script error messages to LOG(INFO) |
| 48 | // - Send script alert()s to LOG(INFO) |
| 49 | // - Use the provided host resolver to service dnsResolve(). |
| 50 | // |
| 51 | // |host_resolver| will be used in async mode on |host_resolver_loop|. If |
| 52 | // |host_resolver_loop| is NULL, then |host_resolver| will be used in sync |
| 53 | // mode on the PAC thread. |
| 54 | static ProxyResolverJSBindings* CreateDefault( |
| 55 | HostResolver* host_resolver, MessageLoop* host_resolver_loop); |
| 56 | }; |
| 57 | |
| 58 | } // namespace net |
| 59 | |
| 60 | #endif // NET_PROXY_PROXY_JS_BINDINGS_H |