OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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_RESOLVER_JS_BINDINGS_H_ | |
6 #define NET_PROXY_PROXY_RESOLVER_JS_BINDINGS_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/string16.h" | |
11 #include "net/base/net_export.h" | |
12 | |
13 namespace net { | |
14 | |
15 class HostResolver; | |
16 class NetLog; | |
17 class ProxyResolverErrorObserver; | |
18 struct ProxyResolverRequestContext; | |
19 class SyncHostResolver; | |
20 | |
21 // Interface for the javascript bindings. | |
22 class NET_EXPORT_PRIVATE ProxyResolverJSBindings { | |
23 public: | |
24 ProxyResolverJSBindings() : current_request_context_(NULL) {} | |
25 | |
26 virtual ~ProxyResolverJSBindings() {} | |
27 | |
28 // Handler for "alert(message)" | |
29 virtual void Alert(const string16& message) = 0; | |
30 | |
31 // Handler for "myIpAddress()". Returns true on success and fills | |
32 // |*first_ip_address| with the result. | |
33 virtual bool MyIpAddress(std::string* first_ip_address) = 0; | |
34 | |
35 // Handler for "myIpAddressEx()". Returns true on success and fills | |
36 // |*ip_address_list| with the result. | |
37 // | |
38 // This is a Microsoft extension to PAC for IPv6, see: | |
39 // http://blogs.msdn.com/b/wndp/archive/2006/07/13/ipv6-pac-extensions-v0-9.as
px | |
40 | |
41 virtual bool MyIpAddressEx(std::string* ip_address_list) = 0; | |
42 | |
43 // Handler for "dnsResolve(host)". Returns true on success and fills | |
44 // |*first_ip_address| with the result. | |
45 virtual bool DnsResolve(const std::string& host, | |
46 std::string* first_ip_address) = 0; | |
47 | |
48 // Handler for "dnsResolveEx(host)". Returns true on success and fills | |
49 // |*ip_address_list| with the result. | |
50 // | |
51 // This is a Microsoft extension to PAC for IPv6, see: | |
52 // http://blogs.msdn.com/b/wndp/archive/2006/07/13/ipv6-pac-extensions-v0-9.as
px | |
53 virtual bool DnsResolveEx(const std::string& host, | |
54 std::string* ip_address_list) = 0; | |
55 | |
56 // Handler for when an error is encountered. |line_number| may be -1 | |
57 // if a line number is not applicable to this error. | |
58 virtual void OnError(int line_number, const string16& error) = 0; | |
59 | |
60 // Called before the thread running the proxy resolver is stopped. | |
61 virtual void Shutdown() = 0; | |
62 | |
63 // Creates a default javascript bindings implementation that will: | |
64 // - Send script error messages to both VLOG(1) and the NetLog. | |
65 // - Send script alert()s to both VLOG(1) and the NetLog. | |
66 // - Use the provided host resolver to service dnsResolve(). | |
67 // | |
68 // Takes ownership of |host_resolver| and |error_observer| (the latter can | |
69 // be NULL). | |
70 static ProxyResolverJSBindings* CreateDefault( | |
71 SyncHostResolver* host_resolver, | |
72 NetLog* net_log, | |
73 ProxyResolverErrorObserver* error_observer); | |
74 | |
75 // Sets details about the currently executing FindProxyForURL() request. | |
76 void set_current_request_context( | |
77 ProxyResolverRequestContext* current_request_context) { | |
78 current_request_context_ = current_request_context; | |
79 } | |
80 | |
81 // Retrieves details about the currently executing FindProxyForURL() request. | |
82 ProxyResolverRequestContext* current_request_context() { | |
83 return current_request_context_; | |
84 } | |
85 | |
86 private: | |
87 ProxyResolverRequestContext* current_request_context_; | |
88 }; | |
89 | |
90 } // namespace net | |
91 | |
92 #endif // NET_PROXY_PROXY_RESOLVER_JS_BINDINGS_H_ | |
OLD | NEW |