Enables compositing support for webview.
[chromium-blink-merge.git] / net / proxy / proxy_resolver_js_bindings.h
blobf201707f5e304ef07b50cb8b6e0f804884a9cf2c
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.
5 #ifndef NET_PROXY_PROXY_RESOLVER_JS_BINDINGS_H_
6 #define NET_PROXY_PROXY_RESOLVER_JS_BINDINGS_H_
8 #include <string>
10 #include "base/string16.h"
11 #include "net/base/net_export.h"
13 namespace net {
15 class HostResolver;
16 class NetLog;
17 class ProxyResolverErrorObserver;
18 struct ProxyResolverRequestContext;
19 class SyncHostResolver;
21 // Interface for the javascript bindings.
22 class NET_EXPORT_PRIVATE ProxyResolverJSBindings {
23 public:
24 ProxyResolverJSBindings() : current_request_context_(NULL) {}
26 virtual ~ProxyResolverJSBindings() {}
28 // Handler for "alert(message)"
29 virtual void Alert(const string16& message) = 0;
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;
35 // Handler for "myIpAddressEx()". Returns true on success and fills
36 // |*ip_address_list| with the result.
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.aspx
41 virtual bool MyIpAddressEx(std::string* ip_address_list) = 0;
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;
48 // Handler for "dnsResolveEx(host)". Returns true on success and fills
49 // |*ip_address_list| with the result.
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.aspx
53 virtual bool DnsResolveEx(const std::string& host,
54 std::string* ip_address_list) = 0;
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;
60 // Called before the thread running the proxy resolver is stopped.
61 virtual void Shutdown() = 0;
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().
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);
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;
81 // Retrieves details about the currently executing FindProxyForURL() request.
82 ProxyResolverRequestContext* current_request_context() {
83 return current_request_context_;
86 private:
87 ProxyResolverRequestContext* current_request_context_;
90 } // namespace net
92 #endif // NET_PROXY_PROXY_RESOLVER_JS_BINDINGS_H_