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