blob: a5033067118111852c26f586eb74ec21274d183b [file] [log] [blame]
[email protected]82a37672011-05-03 12:02:411// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]90ae1fb2009-08-02 21:07:122// 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]32b76ef2010-07-26 23:08:247#pragma once
[email protected]90ae1fb2009-08-02 21:07:128
9#include <string>
10
[email protected]51e413c2010-06-23 00:15:5811#include "base/string16.h"
[email protected]172da1b2011-08-12 15:52:2612#include "net/base/net_export.h"
[email protected]51e413c2010-06-23 00:15:5813
[email protected]90ae1fb2009-08-02 21:07:1214namespace net {
15
16class HostResolver;
[email protected]72b4a772010-07-14 01:29:3017class NetLog;
[email protected]82a37672011-05-03 12:02:4118class ProxyResolverErrorObserver;
[email protected]59872eb2010-06-22 18:56:1219struct ProxyResolverRequestContext;
[email protected]9ef6e9e2011-06-15 12:16:4820class SyncHostResolver;
[email protected]90ae1fb2009-08-02 21:07:1221
22// Interface for the javascript bindings.
[email protected]172da1b2011-08-12 15:52:2623class NET_EXPORT_PRIVATE ProxyResolverJSBindings {
[email protected]90ae1fb2009-08-02 21:07:1224 public:
[email protected]59872eb2010-06-22 18:56:1225 ProxyResolverJSBindings() : current_request_context_(NULL) {}
26
[email protected]90ae1fb2009-08-02 21:07:1227 virtual ~ProxyResolverJSBindings() {}
28
29 // Handler for "alert(message)"
[email protected]51e413c2010-06-23 00:15:5830 virtual void Alert(const string16& message) = 0;
[email protected]90ae1fb2009-08-02 21:07:1231
[email protected]51e413c2010-06-23 00:15:5832 // 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]90ae1fb2009-08-02 21:07:1235
[email protected]51e413c2010-06-23 00:15:5836 // Handler for "myIpAddressEx()". Returns true on success and fills
37 // |*ip_address_list| with the result.
[email protected]21f20c892009-10-26 23:51:2838 //
39 // This is a Microsoft extension to PAC for IPv6, see:
[email protected]a37b8bb2010-08-26 23:31:0040 // http://blogs.msdn.com/b/wndp/archive/2006/07/13/ipv6-pac-extensions-v0-9.aspx
41
[email protected]51e413c2010-06-23 00:15:5842 virtual bool MyIpAddressEx(std::string* ip_address_list) = 0;
[email protected]21f20c892009-10-26 23:51:2843
[email protected]51e413c2010-06-23 00:15:5844 // 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]90ae1fb2009-08-02 21:07:1248
[email protected]51e413c2010-06-23 00:15:5849 // Handler for "dnsResolveEx(host)". Returns true on success and fills
50 // |*ip_address_list| with the result.
[email protected]21f20c892009-10-26 23:51:2851 //
52 // This is a Microsoft extension to PAC for IPv6, see:
[email protected]a37b8bb2010-08-26 23:31:0053 // http://blogs.msdn.com/b/wndp/archive/2006/07/13/ipv6-pac-extensions-v0-9.aspx
[email protected]51e413c2010-06-23 00:15:5854 virtual bool DnsResolveEx(const std::string& host,
55 std::string* ip_address_list) = 0;
[email protected]21f20c892009-10-26 23:51:2856
[email protected]90ae1fb2009-08-02 21:07:1257 // 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]51e413c2010-06-23 00:15:5859 virtual void OnError(int line_number, const string16& error) = 0;
[email protected]90ae1fb2009-08-02 21:07:1260
[email protected]61b84d52010-07-09 03:32:0061 // Called before the thread running the proxy resolver is stopped.
62 virtual void Shutdown() = 0;
63
[email protected]90ae1fb2009-08-02 21:07:1264 // Creates a default javascript bindings implementation that will:
[email protected]b30a3f52010-10-16 01:05:4665 // - 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]90ae1fb2009-08-02 21:07:1267 // - Use the provided host resolver to service dnsResolve().
68 //
[email protected]9ef6e9e2011-06-15 12:16:4869 // Takes ownership of |host_resolver| and |error_observer| (the latter can
70 // be NULL).
[email protected]82a37672011-05-03 12:02:4171 static ProxyResolverJSBindings* CreateDefault(
[email protected]9ef6e9e2011-06-15 12:16:4872 SyncHostResolver* host_resolver,
[email protected]82a37672011-05-03 12:02:4173 NetLog* net_log,
74 ProxyResolverErrorObserver* error_observer);
[email protected]59872eb2010-06-22 18:56:1275
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]90ae1fb2009-08-02 21:07:1289};
90
91} // namespace net
92
[email protected]59872eb2010-06-22 18:56:1293#endif // NET_PROXY_PROXY_RESOLVER_JS_BINDINGS_H_