Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: net/proxy/proxy_config_service_android.cc

Issue 1283543003: [Android] Add a java.lang.System wrapper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/dns/dns_config_service_posix.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/proxy/proxy_config_service_android.h" 5 #include "net/proxy/proxy_config_service_android.h"
6 6
7 #include <sys/system_properties.h> 7 #include "base/android/java_system.h"
8
9 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
10 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
11 #include "base/basictypes.h" 10 #include "base/basictypes.h"
12 #include "base/bind.h" 11 #include "base/bind.h"
13 #include "base/callback.h" 12 #include "base/callback.h"
14 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
15 #include "base/location.h" 14 #include "base/location.h"
16 #include "base/logging.h" 15 #include "base/logging.h"
17 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
18 #include "base/observer_list.h" 17 #include "base/observer_list.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 rules->fallback_proxies.IsEmpty()); 148 rules->fallback_proxies.IsEmpty());
150 }; 149 };
151 150
152 void GetLatestProxyConfigInternal(const GetPropertyCallback& get_property, 151 void GetLatestProxyConfigInternal(const GetPropertyCallback& get_property,
153 ProxyConfig* config) { 152 ProxyConfig* config) {
154 if (!GetProxyRules(get_property, &config->proxy_rules())) 153 if (!GetProxyRules(get_property, &config->proxy_rules()))
155 *config = ProxyConfig::CreateDirect(); 154 *config = ProxyConfig::CreateDirect();
156 } 155 }
157 156
158 std::string GetJavaProperty(const std::string& property) { 157 std::string GetJavaProperty(const std::string& property) {
159 // Use Java System.getProperty to get configuration information.
160 // TODO(pliard): Conversion to/from UTF8 ok here? 158 // TODO(pliard): Conversion to/from UTF8 ok here?
161 JNIEnv* env = AttachCurrentThread(); 159 return base::android::JavaSystem::GetProperty(property);
162 ScopedJavaLocalRef<jstring> str = ConvertUTF8ToJavaString(env, property);
163 ScopedJavaLocalRef<jstring> result =
164 Java_ProxyChangeListener_getProperty(env, str.obj());
165 return result.is_null() ?
166 std::string() : ConvertJavaStringToUTF8(env, result.obj());
167 } 160 }
168 161
169 void CreateStaticProxyConfig(const std::string& host, 162 void CreateStaticProxyConfig(const std::string& host,
170 int port, 163 int port,
171 const std::string& pac_url, 164 const std::string& pac_url,
172 const std::vector<std::string>& exclusion_list, 165 const std::vector<std::string>& exclusion_list,
173 ProxyConfig* config) { 166 ProxyConfig* config) {
174 if (!pac_url.empty()) { 167 if (!pac_url.empty()) {
175 config->set_pac_url(GURL(pac_url)); 168 config->set_pac_url(GURL(pac_url));
176 config->set_pac_mandatory(false); 169 config->set_pac_mandatory(false);
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 network_task_runner, jni_task_runner, get_property_callback)) { 401 network_task_runner, jni_task_runner, get_property_callback)) {
409 delegate_->SetupJNI(); 402 delegate_->SetupJNI();
410 delegate_->FetchInitialConfig(); 403 delegate_->FetchInitialConfig();
411 } 404 }
412 405
413 void ProxyConfigServiceAndroid::ProxySettingsChanged() { 406 void ProxyConfigServiceAndroid::ProxySettingsChanged() {
414 delegate_->ProxySettingsChanged(); 407 delegate_->ProxySettingsChanged();
415 } 408 }
416 409
417 } // namespace net 410 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/dns_config_service_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698