blob: 6eff69de2debaa4441817a2fb10fc5b3699fd72b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_PROXY_PROXY_JS_BINDINGS_H
#define NET_PROXY_PROXY_JS_BINDINGS_H
#include <string>
class MessageLoop;
namespace net {
class HostResolver;
// Interface for the javascript bindings.
class ProxyResolverJSBindings {
public:
virtual ~ProxyResolverJSBindings() {}
// Handler for "alert(message)"
virtual void Alert(const std::string& message) = 0;
// Handler for "myIpAddress()". Returns empty string on failure.
virtual std::string MyIpAddress() = 0;
// Handler for "dnsResolve(host)". Returns empty string on failure.
virtual std::string DnsResolve(const std::string& host) = 0;
// Handler for when an error is encountered. |line_number| may be -1
// if a line number is not applicable to this error.
virtual void OnError(int line_number, const std::string& error) = 0;
// Creates a default javascript bindings implementation that will:
// - Send script error messages to LOG(INFO)
// - Send script alert()s to LOG(INFO)
// - Use the provided host resolver to service dnsResolve().
//
// |host_resolver| will be used in async mode on |host_resolver_loop|. If
// |host_resolver_loop| is NULL, then |host_resolver| will be used in sync
// mode on the PAC thread.
static ProxyResolverJSBindings* CreateDefault(
HostResolver* host_resolver, MessageLoop* host_resolver_loop);
};
} // namespace net
#endif // NET_PROXY_PROXY_JS_BINDINGS_H
|