Make GetSecurityLevel available from the java ToolbarModel.
[chromium-blink-merge.git] / net / proxy / proxy_config_service_android.h
blobd642d37c73e4f8312f3a17eb7136527b498f4aa0
1 // Copyright (c) 2012 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_CONFIG_SERVICE_ANDROID_H_
6 #define NET_PROXY_PROXY_CONFIG_SERVICE_ANDROID_H_
8 #include <string>
10 #include "base/android/jni_android.h"
11 #include "base/basictypes.h"
12 #include "base/callback_forward.h"
13 #include "base/compiler_specific.h"
14 #include "base/memory/ref_counted.h"
15 #include "net/base/net_export.h"
16 #include "net/proxy/proxy_config_service.h"
18 namespace base {
19 class SequencedTaskRunner;
22 namespace net {
24 class ProxyConfig;
26 class NET_EXPORT ProxyConfigServiceAndroid : public ProxyConfigService {
27 public:
28 // Callback that returns the value of the property identified by the provided
29 // key. If it was not found, an empty string is returned. Note that this
30 // interface does not let you distinguish an empty property from a
31 // non-existing property. This callback is invoked on the JNI thread.
32 typedef base::Callback<std::string (const std::string& property)>
33 GetPropertyCallback;
35 // Separate class whose instance is owned by the Delegate class implemented in
36 // the .cc file.
37 class JNIDelegate {
38 public:
39 virtual ~JNIDelegate() {}
41 // Called from Java (on JNI thread) to signal that the proxy settings have
42 // changed. The string and int arguments (the host/port pair for the proxy)
43 // are either a host/port pair or ("", 0) to indicate "no proxy".
44 // The third argument indicates the PAC url.
45 // The fourth argument is the proxy exclusion list.
46 virtual void ProxySettingsChangedTo(JNIEnv*,
47 jobject,
48 jstring,
49 jint,
50 jstring,
51 jobjectArray) = 0;
53 // Called from Java (on JNI thread) to signal that the proxy settings have
54 // changed. New proxy settings are fetched from the system property store.
55 virtual void ProxySettingsChanged(JNIEnv*, jobject) = 0;
58 ProxyConfigServiceAndroid(
59 const scoped_refptr<base::SequencedTaskRunner>& network_task_runner,
60 const scoped_refptr<base::SequencedTaskRunner>& jni_task_runner);
62 virtual ~ProxyConfigServiceAndroid();
64 // Register JNI bindings.
65 static bool Register(JNIEnv* env);
67 // ProxyConfigService:
68 // Called only on the network thread.
69 virtual void AddObserver(Observer* observer) override;
70 virtual void RemoveObserver(Observer* observer) override;
71 virtual ConfigAvailability GetLatestProxyConfig(ProxyConfig* config) override;
73 private:
74 friend class ProxyConfigServiceAndroidTestBase;
75 class Delegate;
77 // For tests.
78 ProxyConfigServiceAndroid(
79 const scoped_refptr<base::SequencedTaskRunner>& network_task_runner,
80 const scoped_refptr<base::SequencedTaskRunner>& jni_task_runner,
81 GetPropertyCallback get_property_callback);
83 // For tests.
84 void ProxySettingsChanged();
86 scoped_refptr<Delegate> delegate_;
88 DISALLOW_COPY_AND_ASSIGN(ProxyConfigServiceAndroid);
91 } // namespace net
93 #endif // NET_PROXY_PROXY_CONFIG_SERVICE_ANDROID_H_