blob: b5912c4a3feb08335a02c5ed36bc60c96e129c0e [file] [log] [blame]
[email protected]90ae1fb2009-08-02 21:07:121// 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
[email protected]59872eb2010-06-22 18:56:125#ifndef NET_PROXY_PROXY_RESOLVER_JS_BINDINGS_H_
6#define NET_PROXY_PROXY_RESOLVER_JS_BINDINGS_H_
[email protected]90ae1fb2009-08-02 21:07:127
8#include <string>
9
[email protected]51e413c2010-06-23 00:15:5810#include "base/string16.h"
11
[email protected]90ae1fb2009-08-02 21:07:1212class MessageLoop;
13
14namespace net {
15
16class HostResolver;
[email protected]59872eb2010-06-22 18:56:1217struct ProxyResolverRequestContext;
[email protected]90ae1fb2009-08-02 21:07:1218
19// Interface for the javascript bindings.
20class ProxyResolverJSBindings {
21 public:
[email protected]59872eb2010-06-22 18:56:1222 ProxyResolverJSBindings() : current_request_context_(NULL) {}
23
[email protected]90ae1fb2009-08-02 21:07:1224 virtual ~ProxyResolverJSBindings() {}
25
26 // Handler for "alert(message)"
[email protected]51e413c2010-06-23 00:15:5827 virtual void Alert(const string16& message) = 0;
[email protected]90ae1fb2009-08-02 21:07:1228
[email protected]51e413c2010-06-23 00:15:5829 // Handler for "myIpAddress()". Returns true on success and fills
30 // |*first_ip_address| with the result.
31 virtual bool MyIpAddress(std::string* first_ip_address) = 0;
[email protected]90ae1fb2009-08-02 21:07:1232
[email protected]51e413c2010-06-23 00:15:5833 // Handler for "myIpAddressEx()". Returns true on success and fills
34 // |*ip_address_list| with the result.
[email protected]21f20c892009-10-26 23:51:2835 //
36 // This is a Microsoft extension to PAC for IPv6, see:
37 // http://blogs.msdn.com/wndp/articles/IPV6_PAC_Extensions_v0_9.aspx
[email protected]51e413c2010-06-23 00:15:5838 virtual bool MyIpAddressEx(std::string* ip_address_list) = 0;
[email protected]21f20c892009-10-26 23:51:2839
[email protected]51e413c2010-06-23 00:15:5840 // Handler for "dnsResolve(host)". Returns true on success and fills
41 // |*first_ip_address| with the result.
42 virtual bool DnsResolve(const std::string& host,
43 std::string* first_ip_address) = 0;
[email protected]90ae1fb2009-08-02 21:07:1244
[email protected]51e413c2010-06-23 00:15:5845 // Handler for "dnsResolveEx(host)". Returns true on success and fills
46 // |*ip_address_list| with the result.
[email protected]21f20c892009-10-26 23:51:2847 //
48 // This is a Microsoft extension to PAC for IPv6, see:
49 // http://blogs.msdn.com/wndp/articles/IPV6_PAC_Extensions_v0_9.aspx
[email protected]51e413c2010-06-23 00:15:5850 virtual bool DnsResolveEx(const std::string& host,
51 std::string* ip_address_list) = 0;
[email protected]21f20c892009-10-26 23:51:2852
[email protected]90ae1fb2009-08-02 21:07:1253 // Handler for when an error is encountered. |line_number| may be -1
54 // if a line number is not applicable to this error.
[email protected]51e413c2010-06-23 00:15:5855 virtual void OnError(int line_number, const string16& error) = 0;
[email protected]90ae1fb2009-08-02 21:07:1256
[email protected]61b84d52010-07-09 03:32:0057 // Called before the thread running the proxy resolver is stopped.
58 virtual void Shutdown() = 0;
59
[email protected]90ae1fb2009-08-02 21:07:1260 // Creates a default javascript bindings implementation that will:
61 // - Send script error messages to LOG(INFO)
62 // - Send script alert()s to LOG(INFO)
63 // - Use the provided host resolver to service dnsResolve().
64 //
[email protected]1ca2b452010-04-17 00:07:0465 // Note that |host_resolver| will be used in sync mode mode.
66 static ProxyResolverJSBindings* CreateDefault(HostResolver* host_resolver);
[email protected]59872eb2010-06-22 18:56:1267
68 // Sets details about the currently executing FindProxyForURL() request.
69 void set_current_request_context(
70 ProxyResolverRequestContext* current_request_context) {
71 current_request_context_ = current_request_context;
72 }
73
74 // Retrieves details about the currently executing FindProxyForURL() request.
75 ProxyResolverRequestContext* current_request_context() {
76 return current_request_context_;
77 }
78
79 private:
80 ProxyResolverRequestContext* current_request_context_;
[email protected]90ae1fb2009-08-02 21:07:1281};
82
83} // namespace net
84
[email protected]59872eb2010-06-22 18:56:1285#endif // NET_PROXY_PROXY_RESOLVER_JS_BINDINGS_H_