[email protected] | 82a3767 | 2011-05-03 12:02:41 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 90ae1fb | 2009-08-02 21:07:12 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 59872eb | 2010-06-22 18:56:12 | [diff] [blame] | 5 | #ifndef NET_PROXY_PROXY_RESOLVER_JS_BINDINGS_H_ |
6 | #define NET_PROXY_PROXY_RESOLVER_JS_BINDINGS_H_ | ||||
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 7 | #pragma once |
[email protected] | 90ae1fb | 2009-08-02 21:07:12 | [diff] [blame] | 8 | |
9 | #include <string> | ||||
10 | |||||
[email protected] | 51e413c | 2010-06-23 00:15:58 | [diff] [blame] | 11 | #include "base/string16.h" |
[email protected] | 172da1b | 2011-08-12 15:52:26 | [diff] [blame^] | 12 | #include "net/base/net_export.h" |
[email protected] | 51e413c | 2010-06-23 00:15:58 | [diff] [blame] | 13 | |
[email protected] | 90ae1fb | 2009-08-02 21:07:12 | [diff] [blame] | 14 | namespace net { |
15 | |||||
16 | class HostResolver; | ||||
[email protected] | 72b4a77 | 2010-07-14 01:29:30 | [diff] [blame] | 17 | class NetLog; |
[email protected] | 82a3767 | 2011-05-03 12:02:41 | [diff] [blame] | 18 | class ProxyResolverErrorObserver; |
[email protected] | 59872eb | 2010-06-22 18:56:12 | [diff] [blame] | 19 | struct ProxyResolverRequestContext; |
[email protected] | 9ef6e9e | 2011-06-15 12:16:48 | [diff] [blame] | 20 | class SyncHostResolver; |
[email protected] | 90ae1fb | 2009-08-02 21:07:12 | [diff] [blame] | 21 | |
22 | // Interface for the javascript bindings. | ||||
[email protected] | 172da1b | 2011-08-12 15:52:26 | [diff] [blame^] | 23 | class NET_EXPORT_PRIVATE ProxyResolverJSBindings { |
[email protected] | 90ae1fb | 2009-08-02 21:07:12 | [diff] [blame] | 24 | public: |
[email protected] | 59872eb | 2010-06-22 18:56:12 | [diff] [blame] | 25 | ProxyResolverJSBindings() : current_request_context_(NULL) {} |
26 | |||||
[email protected] | 90ae1fb | 2009-08-02 21:07:12 | [diff] [blame] | 27 | virtual ~ProxyResolverJSBindings() {} |
28 | |||||
29 | // Handler for "alert(message)" | ||||
[email protected] | 51e413c | 2010-06-23 00:15:58 | [diff] [blame] | 30 | virtual void Alert(const string16& message) = 0; |
[email protected] | 90ae1fb | 2009-08-02 21:07:12 | [diff] [blame] | 31 | |
[email protected] | 51e413c | 2010-06-23 00:15:58 | [diff] [blame] | 32 | // Handler for "myIpAddress()". Returns true on success and fills |
33 | // |*first_ip_address| with the result. | ||||
34 | virtual bool MyIpAddress(std::string* first_ip_address) = 0; | ||||
[email protected] | 90ae1fb | 2009-08-02 21:07:12 | [diff] [blame] | 35 | |
[email protected] | 51e413c | 2010-06-23 00:15:58 | [diff] [blame] | 36 | // Handler for "myIpAddressEx()". Returns true on success and fills |
37 | // |*ip_address_list| with the result. | ||||
[email protected] | 21f20c89 | 2009-10-26 23:51:28 | [diff] [blame] | 38 | // |
39 | // This is a Microsoft extension to PAC for IPv6, see: | ||||
[email protected] | a37b8bb | 2010-08-26 23:31:00 | [diff] [blame] | 40 | // http://blogs.msdn.com/b/wndp/archive/2006/07/13/ipv6-pac-extensions-v0-9.aspx |
41 | |||||
[email protected] | 51e413c | 2010-06-23 00:15:58 | [diff] [blame] | 42 | virtual bool MyIpAddressEx(std::string* ip_address_list) = 0; |
[email protected] | 21f20c89 | 2009-10-26 23:51:28 | [diff] [blame] | 43 | |
[email protected] | 51e413c | 2010-06-23 00:15:58 | [diff] [blame] | 44 | // Handler for "dnsResolve(host)". Returns true on success and fills |
45 | // |*first_ip_address| with the result. | ||||
46 | virtual bool DnsResolve(const std::string& host, | ||||
47 | std::string* first_ip_address) = 0; | ||||
[email protected] | 90ae1fb | 2009-08-02 21:07:12 | [diff] [blame] | 48 | |
[email protected] | 51e413c | 2010-06-23 00:15:58 | [diff] [blame] | 49 | // Handler for "dnsResolveEx(host)". Returns true on success and fills |
50 | // |*ip_address_list| with the result. | ||||
[email protected] | 21f20c89 | 2009-10-26 23:51:28 | [diff] [blame] | 51 | // |
52 | // This is a Microsoft extension to PAC for IPv6, see: | ||||
[email protected] | a37b8bb | 2010-08-26 23:31:00 | [diff] [blame] | 53 | // http://blogs.msdn.com/b/wndp/archive/2006/07/13/ipv6-pac-extensions-v0-9.aspx |
[email protected] | 51e413c | 2010-06-23 00:15:58 | [diff] [blame] | 54 | virtual bool DnsResolveEx(const std::string& host, |
55 | std::string* ip_address_list) = 0; | ||||
[email protected] | 21f20c89 | 2009-10-26 23:51:28 | [diff] [blame] | 56 | |
[email protected] | 90ae1fb | 2009-08-02 21:07:12 | [diff] [blame] | 57 | // Handler for when an error is encountered. |line_number| may be -1 |
58 | // if a line number is not applicable to this error. | ||||
[email protected] | 51e413c | 2010-06-23 00:15:58 | [diff] [blame] | 59 | virtual void OnError(int line_number, const string16& error) = 0; |
[email protected] | 90ae1fb | 2009-08-02 21:07:12 | [diff] [blame] | 60 | |
[email protected] | 61b84d5 | 2010-07-09 03:32:00 | [diff] [blame] | 61 | // Called before the thread running the proxy resolver is stopped. |
62 | virtual void Shutdown() = 0; | ||||
63 | |||||
[email protected] | 90ae1fb | 2009-08-02 21:07:12 | [diff] [blame] | 64 | // Creates a default javascript bindings implementation that will: |
[email protected] | b30a3f5 | 2010-10-16 01:05:46 | [diff] [blame] | 65 | // - Send script error messages to both VLOG(1) and the NetLog. |
66 | // - Send script alert()s to both VLOG(1) and the NetLog. | ||||
[email protected] | 90ae1fb | 2009-08-02 21:07:12 | [diff] [blame] | 67 | // - Use the provided host resolver to service dnsResolve(). |
68 | // | ||||
[email protected] | 9ef6e9e | 2011-06-15 12:16:48 | [diff] [blame] | 69 | // Takes ownership of |host_resolver| and |error_observer| (the latter can |
70 | // be NULL). | ||||
[email protected] | 82a3767 | 2011-05-03 12:02:41 | [diff] [blame] | 71 | static ProxyResolverJSBindings* CreateDefault( |
[email protected] | 9ef6e9e | 2011-06-15 12:16:48 | [diff] [blame] | 72 | SyncHostResolver* host_resolver, |
[email protected] | 82a3767 | 2011-05-03 12:02:41 | [diff] [blame] | 73 | NetLog* net_log, |
74 | ProxyResolverErrorObserver* error_observer); | ||||
[email protected] | 59872eb | 2010-06-22 18:56:12 | [diff] [blame] | 75 | |
76 | // Sets details about the currently executing FindProxyForURL() request. | ||||
77 | void set_current_request_context( | ||||
78 | ProxyResolverRequestContext* current_request_context) { | ||||
79 | current_request_context_ = current_request_context; | ||||
80 | } | ||||
81 | |||||
82 | // Retrieves details about the currently executing FindProxyForURL() request. | ||||
83 | ProxyResolverRequestContext* current_request_context() { | ||||
84 | return current_request_context_; | ||||
85 | } | ||||
86 | |||||
87 | private: | ||||
88 | ProxyResolverRequestContext* current_request_context_; | ||||
[email protected] | 90ae1fb | 2009-08-02 21:07:12 | [diff] [blame] | 89 | }; |
90 | |||||
91 | } // namespace net | ||||
92 | |||||
[email protected] | 59872eb | 2010-06-22 18:56:12 | [diff] [blame] | 93 | #endif // NET_PROXY_PROXY_RESOLVER_JS_BINDINGS_H_ |