| Index: chrome/browser/android/preferences/pref_service_bridge.cc
|
| diff --git a/chrome/browser/android/preferences/pref_service_bridge.cc b/chrome/browser/android/preferences/pref_service_bridge.cc
|
| index 773f47444f9bb8394aaf715b810446734d02f20f..feeda70b55aa8de0c65df3dc6d1240451d2668f3 100644
|
| --- a/chrome/browser/android/preferences/pref_service_bridge.cc
|
| +++ b/chrome/browser/android/preferences/pref_service_bridge.cc
|
| @@ -5,6 +5,7 @@
|
| #include "chrome/browser/android/preferences/pref_service_bridge.h"
|
|
|
| #include <jni.h>
|
| +#include <vector>
|
|
|
| #include "base/android/build_info.h"
|
| #include "base/android/jni_android.h"
|
| @@ -17,6 +18,8 @@
|
| #include "base/strings/string_util.h"
|
| #include "base/values.h"
|
| #include "chrome/browser/browser_process.h"
|
| +#include "chrome/browser/browsing_data/browsing_data_counter.h"
|
| +#include "chrome/browser/browsing_data/browsing_data_counter_utils.h"
|
| #include "chrome/browser/browsing_data/browsing_data_helper.h"
|
| #include "chrome/browser/browsing_data/browsing_data_remover.h"
|
| #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
|
| @@ -480,8 +483,42 @@ class ClearBrowsingDataObserver : public BrowsingDataRemover::Observer {
|
| private:
|
| JavaObjectWeakGlobalRef weak_chrome_native_preferences_;
|
| };
|
| +
|
| +static const char* GetDeletionPreferenceFromCheckboxIndex(int index) {
|
| + // This enumeration of preferences must match the data types we offer for
|
| + // deletion in ClearBrowsingDataDialogFragment.
|
| + static const char* pref_names[] = {
|
| + prefs::kDeleteBrowsingHistory,
|
| + prefs::kDeleteCache,
|
| + prefs::kDeleteCookies,
|
| + prefs::kDeletePasswords,
|
| + prefs::kDeleteFormData
|
| + };
|
| + DCHECK_GE(index, 0);
|
| + DCHECK_LT(index, (int)arraysize(pref_names));
|
| +
|
| + return pref_names[index];
|
| +}
|
| +
|
| } // namespace
|
|
|
| +static jboolean GetBrowsingDataDeletionPreference(
|
| + JNIEnv* env,
|
| + const JavaParamRef<jobject>& obj,
|
| + jint index) {
|
| + return GetOriginalProfile()->GetPrefs()->GetBoolean(
|
| + GetDeletionPreferenceFromCheckboxIndex(index));
|
| +}
|
| +
|
| +static void SetBrowsingDataDeletionPreference(
|
| + JNIEnv* env,
|
| + const JavaParamRef<jobject>& obj,
|
| + jint index,
|
| + jboolean value) {
|
| + GetOriginalProfile()->GetPrefs()->SetBoolean(
|
| + GetDeletionPreferenceFromCheckboxIndex(index), value);
|
| +}
|
| +
|
| static void ClearBrowsingData(JNIEnv* env,
|
| const JavaParamRef<jobject>& obj,
|
| jboolean history,
|
| @@ -519,6 +556,50 @@ static jboolean CanDeleteBrowsingHistory(JNIEnv* env,
|
| return GetPrefService()->GetBoolean(prefs::kAllowDeletingBrowserHistory);
|
| }
|
|
|
| +static void BrowsingDataCounterCallback(
|
| + JavaObjectWeakGlobalRef caller,
|
| + JavaObjectWeakGlobalRef owner,
|
| + scoped_ptr<BrowsingDataCounter::Result> result) {
|
| + JNIEnv* env = AttachCurrentThread();
|
| + if (caller.get(env).is_null())
|
| + return;
|
| +
|
| + ScopedJavaLocalRef<jstring> resultString =
|
| + base::android::ConvertUTF16ToJavaString(
|
| + env, browsing_data::GetCounterTextFromResult(result.get()));
|
| + Java_PrefServiceBridge_onBrowsingDataCounterFinished(
|
| + env, caller.get(env).obj(), owner.get(env).obj(), resultString.obj());
|
| +}
|
| +
|
| +static jlong CreateBrowsingDataCounter(JNIEnv* env,
|
| + const JavaParamRef<jobject>& obj,
|
| + const JavaParamRef<jobject>& owner,
|
| + jint index) {
|
| + BrowsingDataCounter* counter =
|
| + browsing_data::CreateCounterForPreference(
|
| + GetDeletionPreferenceFromCheckboxIndex(index));
|
| + if (!counter)
|
| + return reinterpret_cast<intptr_t>(nullptr);
|
| +
|
| + JavaObjectWeakGlobalRef caller_ref(env, obj);
|
| + JavaObjectWeakGlobalRef owner_ref(env, owner);
|
| +
|
| + counter->Init(
|
| + GetOriginalProfile(),
|
| + base::Bind(&BrowsingDataCounterCallback,
|
| + caller_ref,
|
| + owner_ref));
|
| + counter->Restart();
|
| + return reinterpret_cast<intptr_t>(counter);
|
| +}
|
| +
|
| +static void DestroyBrowsingDataCounter(JNIEnv* env,
|
| + const JavaParamRef<jobject>& obj,
|
| + jlong counter) {
|
| + scoped_ptr<BrowsingDataCounter> to_destroy(
|
| + reinterpret_cast<BrowsingDataCounter*>(counter));
|
| +}
|
| +
|
| static void SetAllowCookiesEnabled(JNIEnv* env,
|
| const JavaParamRef<jobject>& obj,
|
| jboolean allow) {
|
|
|