OLD | NEW |
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 "content/browser/geolocation/location_api_adapter_android.h" | 5 #include "content/browser/geolocation/location_api_adapter_android.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 jstring message) { | 127 jstring message) { |
128 Geoposition position_error; | 128 Geoposition position_error; |
129 position_error.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE; | 129 position_error.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE; |
130 position_error.error_message = | 130 position_error.error_message = |
131 base::android::ConvertJavaStringToUTF8(env, message); | 131 base::android::ConvertJavaStringToUTF8(env, message); |
132 GetInstance()->OnNewGeopositionInternal(position_error); | 132 GetInstance()->OnNewGeopositionInternal(position_error); |
133 } | 133 } |
134 | 134 |
135 // static | 135 // static |
136 AndroidLocationApiAdapter* AndroidLocationApiAdapter::GetInstance() { | 136 AndroidLocationApiAdapter* AndroidLocationApiAdapter::GetInstance() { |
137 return Singleton<AndroidLocationApiAdapter>::get(); | 137 return base::Singleton<AndroidLocationApiAdapter>::get(); |
138 } | 138 } |
139 | 139 |
140 // static | 140 // static |
141 bool AndroidLocationApiAdapter::RegisterGeolocationService(JNIEnv* env) { | 141 bool AndroidLocationApiAdapter::RegisterGeolocationService(JNIEnv* env) { |
142 return RegisterNativesImpl(env); | 142 return RegisterNativesImpl(env); |
143 } | 143 } |
144 | 144 |
145 void AndroidLocationApiAdapter::CreateJavaObject(JNIEnv* env) { | 145 void AndroidLocationApiAdapter::CreateJavaObject(JNIEnv* env) { |
146 // Create the Java AndroidLocationProvider object. | 146 // Create the Java AndroidLocationProvider object. |
147 java_location_provider_android_object_.Reset( | 147 java_location_provider_android_object_.Reset( |
148 Java_LocationProviderAdapter_create(env, | 148 Java_LocationProviderAdapter_create(env, |
149 base::android::GetApplicationContext())); | 149 base::android::GetApplicationContext())); |
150 CHECK(!java_location_provider_android_object_.is_null()); | 150 CHECK(!java_location_provider_android_object_.is_null()); |
151 } | 151 } |
152 | 152 |
153 void AndroidLocationApiAdapter::OnNewGeopositionInternal( | 153 void AndroidLocationApiAdapter::OnNewGeopositionInternal( |
154 const Geoposition& geoposition) { | 154 const Geoposition& geoposition) { |
155 base::AutoLock lock(lock_); | 155 base::AutoLock lock(lock_); |
156 if (!task_runner_.get()) | 156 if (!task_runner_.get()) |
157 return; | 157 return; |
158 task_runner_->PostTask( | 158 task_runner_->PostTask( |
159 FROM_HERE, | 159 FROM_HERE, |
160 base::Bind(&AndroidLocationApiAdapter::NotifyProviderNewGeoposition, | 160 base::Bind(&AndroidLocationApiAdapter::NotifyProviderNewGeoposition, |
161 geoposition)); | 161 geoposition)); |
162 } | 162 } |
163 | 163 |
164 } // namespace content | 164 } // namespace content |
OLD | NEW |