OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 package org.chromium.android_webview; | 5 package org.chromium.android_webview; |
6 | 6 |
7 import android.os.Handler; | 7 import android.os.Handler; |
8 import android.os.Looper; | 8 import android.os.Looper; |
9 import android.webkit.ValueCallback; | 9 import android.webkit.ValueCallback; |
10 | 10 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 */ | 183 */ |
184 private static class CookieCallback<T> { | 184 private static class CookieCallback<T> { |
185 ValueCallback<T> mCallback; | 185 ValueCallback<T> mCallback; |
186 Handler mHandler; | 186 Handler mHandler; |
187 | 187 |
188 public CookieCallback(ValueCallback<T> callback, Handler handler) { | 188 public CookieCallback(ValueCallback<T> callback, Handler handler) { |
189 mCallback = callback; | 189 mCallback = callback; |
190 mHandler = handler; | 190 mHandler = handler; |
191 } | 191 } |
192 | 192 |
193 public static<T> CookieCallback<T> convert(ValueCallback<T> callback) thr
ows | 193 public static<T> CookieCallback<T> convert(ValueCallback<T> callback) th
rows |
194 IllegalStateException { | 194 IllegalStateException { |
195 if (callback == null) { | 195 if (callback == null) return null; |
196 return null; | |
197 } | |
198 if (Looper.myLooper() == null) { | 196 if (Looper.myLooper() == null) { |
199 throw new IllegalStateException( | 197 throw new IllegalStateException("CookieCallback.convert should b
e called on " + |
200 "CookieCallback.convert should be called on a thread with a ru
nning Looper."); | 198 "a thread with a running Looper."); |
201 } | 199 } |
202 return new CookieCallback<T>(callback, new Handler()); | 200 return new CookieCallback<T>(callback, new Handler()); |
203 } | 201 } |
204 | 202 |
205 public void onReceiveValue(final T t) { | 203 public void onReceiveValue(final T t) { |
206 mHandler.post(new Runnable() { | 204 mHandler.post(new Runnable() { |
207 @Override | 205 @Override |
208 public void run() { | 206 public void run() { |
209 mCallback.onReceiveValue(t); | 207 mCallback.onReceiveValue(t); |
210 } | 208 } |
(...skipping 14 matching lines...) Expand all Loading... |
225 private native void nativeRemoveAllCookies(CookieCallback<Boolean> callback)
; | 223 private native void nativeRemoveAllCookies(CookieCallback<Boolean> callback)
; |
226 private native void nativeRemoveAllCookiesSync(); | 224 private native void nativeRemoveAllCookiesSync(); |
227 private native void nativeRemoveExpiredCookies(); | 225 private native void nativeRemoveExpiredCookies(); |
228 private native void nativeFlushCookieStore(); | 226 private native void nativeFlushCookieStore(); |
229 | 227 |
230 private native boolean nativeHasCookies(); | 228 private native boolean nativeHasCookies(); |
231 | 229 |
232 private native boolean nativeAllowFileSchemeCookies(); | 230 private native boolean nativeAllowFileSchemeCookies(); |
233 private native void nativeSetAcceptFileSchemeCookies(boolean accept); | 231 private native void nativeSetAcceptFileSchemeCookies(boolean accept); |
234 } | 232 } |
OLD | NEW |