OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/android/webapps/webapp_registry.h" | 5 #include "chrome/browser/android/webapps/webapp_registry.h" |
6 | 6 |
7 #include <jni.h> | 7 #include <jni.h> |
8 | 8 |
9 #include "base/android/context_utils.h" | 9 #include "base/android/context_utils.h" |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "chrome/browser/io_thread.h" | 12 #include "chrome/browser/io_thread.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 #include "jni/WebappRegistry_jni.h" | 14 #include "jni/WebappRegistry_jni.h" |
15 | 15 |
16 // static | 16 // static |
17 void WebappRegistry::UnregisterWebapps( | 17 void WebappRegistry::UnregisterWebapps( |
18 const base::Closure& callback) { | 18 const base::Closure& callback) { |
19 JNIEnv* env = base::android::AttachCurrentThread(); | 19 JNIEnv* env = base::android::AttachCurrentThread(); |
20 uintptr_t callback_pointer = reinterpret_cast<uintptr_t>( | 20 uintptr_t callback_pointer = reinterpret_cast<uintptr_t>( |
21 new base::Closure(callback)); | 21 new base::Closure(callback)); |
22 | 22 |
23 Java_WebappRegistry_unregisterAllWebapps( | 23 Java_WebappRegistry_unregisterAllWebapps( |
24 env, | 24 env, |
25 base::android::GetApplicationContext(), | 25 base::android::GetApplicationContext(), |
26 callback_pointer); | 26 callback_pointer); |
27 } | 27 } |
28 | 28 |
| 29 // static |
| 30 void WebappRegistry::ClearWebappHistory(const base::Closure& callback) { |
| 31 JNIEnv* env = base::android::AttachCurrentThread(); |
| 32 uintptr_t callback_pointer = reinterpret_cast<uintptr_t>( |
| 33 new base::Closure(callback)); |
| 34 |
| 35 Java_WebappRegistry_clearWebappHistory( |
| 36 env, |
| 37 base::android::GetApplicationContext(), |
| 38 callback_pointer); |
| 39 } |
| 40 |
29 // Callback used by Java when all web apps have been unregistered. | 41 // Callback used by Java when all web apps have been unregistered. |
30 void OnWebappsUnregistered(JNIEnv* env, | 42 void OnWebappsUnregistered(JNIEnv* env, |
31 const JavaParamRef<jclass>& klass, | 43 const JavaParamRef<jclass>& klass, |
32 jlong jcallback) { | 44 jlong jcallback) { |
33 base::Closure* callback = reinterpret_cast<base::Closure*>(jcallback); | 45 base::Closure* callback = reinterpret_cast<base::Closure*>(jcallback); |
34 callback->Run(); | 46 callback->Run(); |
35 delete callback; | 47 delete callback; |
36 } | 48 } |
37 | 49 |
| 50 // Callback used by Java when all web app last used times have been cleared. |
| 51 void OnClearedWebappHistory(JNIEnv* env, |
| 52 const JavaParamRef<jclass>& klass, |
| 53 jlong jcallback) { |
| 54 base::Closure* callback = reinterpret_cast<base::Closure*>(jcallback); |
| 55 callback->Run(); |
| 56 delete callback; |
| 57 } |
| 58 |
38 // static | 59 // static |
39 bool WebappRegistry::RegisterWebappRegistry(JNIEnv* env) { | 60 bool WebappRegistry::RegisterWebappRegistry(JNIEnv* env) { |
40 return RegisterNativesImpl(env); | 61 return RegisterNativesImpl(env); |
41 } | 62 } |
OLD | NEW |