Clear webapp storage when site data is cleared
[chromium-blink-merge.git] / chrome / browser / android / webapps / webapp_registry.cc
blobe4466a3ea2e2973da33aa73c84de845e16925cc0
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.
5 #include "chrome/browser/android/webapps/webapp_registry.h"
7 #include <jni.h>
9 #include "base/android/jni_android.h"
10 #include "base/callback.h"
11 #include "chrome/browser/io_thread.h"
12 #include "content/public/browser/browser_thread.h"
13 #include "jni/WebappRegistry_jni.h"
15 // static
16 void WebappRegistry::UnregisterWebapps(
17 const base::Closure& callback) {
18 JNIEnv* env = base::android::AttachCurrentThread();
19 uintptr_t callback_pointer = reinterpret_cast<uintptr_t>(
20 new base::Closure(callback));
22 Java_WebappRegistry_unregisterAllWebapps(
23 env,
24 base::android::GetApplicationContext(),
25 callback_pointer);
28 // Callback used by Java when all web apps have been unregistered.
29 void OnWebappsUnregistered(JNIEnv* env,
30 const JavaParamRef<jclass>& klass,
31 jlong jcallback) {
32 base::Closure* callback = reinterpret_cast<base::Closure*>(jcallback);
33 callback->Run();
34 delete callback;
37 // static
38 bool WebappRegistry::RegisterWebappRegistry(JNIEnv* env) {
39 return RegisterNativesImpl(env);