| 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/preferences/website_preference_bridge.h" | 5 #include "chrome/browser/android/preferences/website_preference_bridge.h" |
| 6 | 6 |
| 7 #include "base/android/callback_android.h" |
| 7 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 9 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| 10 #include "base/bind.h" | 11 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 15 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
| 15 #include "chrome/browser/browsing_data/browsing_data_quota_helper.h" | 16 #include "chrome/browser/browsing_data/browsing_data_quota_helper.h" |
| 16 #include "chrome/browser/browsing_data/cookies_tree_model.h" | 17 #include "chrome/browser/browsing_data/cookies_tree_model.h" |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 storage::UsageInfoEntries::const_iterator i; | 538 storage::UsageInfoEntries::const_iterator i; |
| 538 for (i = entries.begin(); i != entries.end(); ++i) { | 539 for (i = entries.begin(); i != entries.end(); ++i) { |
| 539 if (i->usage <= 0) continue; | 540 if (i->usage <= 0) continue; |
| 540 ScopedJavaLocalRef<jstring> host = | 541 ScopedJavaLocalRef<jstring> host = |
| 541 ConvertUTF8ToJavaString(env_, i->host); | 542 ConvertUTF8ToJavaString(env_, i->host); |
| 542 | 543 |
| 543 Java_WebsitePreferenceBridge_insertStorageInfoIntoList( | 544 Java_WebsitePreferenceBridge_insertStorageInfoIntoList( |
| 544 env_, list.obj(), host.obj(), i->type, i->usage); | 545 env_, list.obj(), host.obj(), i->type, i->usage); |
| 545 } | 546 } |
| 546 | 547 |
| 547 Java_StorageInfoReadyCallback_onStorageInfoReady( | 548 base::android::RunCallbackAndroid(java_callback_, list); |
| 548 env_, java_callback_.obj(), list.obj()); | |
| 549 | |
| 550 delete this; | 549 delete this; |
| 551 } | 550 } |
| 552 | 551 |
| 553 private: | 552 private: |
| 554 JNIEnv* env_; | 553 JNIEnv* env_; |
| 555 ScopedJavaGlobalRef<jobject> java_callback_; | 554 ScopedJavaGlobalRef<jobject> java_callback_; |
| 556 }; | 555 }; |
| 557 | 556 |
| 558 class StorageInfoClearedCallback { | 557 class StorageInfoClearedCallback { |
| 559 public: | 558 public: |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 // SingleWebsitePreferences.mergePermissionInfoForTopLevelOrigin. | 597 // SingleWebsitePreferences.mergePermissionInfoForTopLevelOrigin. |
| 599 std::string origin_str = i->origin_url.GetOrigin().spec(); | 598 std::string origin_str = i->origin_url.GetOrigin().spec(); |
| 600 DCHECK(origin_str[origin_str.size() - 1] == '/'); | 599 DCHECK(origin_str[origin_str.size() - 1] == '/'); |
| 601 origin_str = origin_str.substr(0, origin_str.size() - 1); | 600 origin_str = origin_str.substr(0, origin_str.size() - 1); |
| 602 ScopedJavaLocalRef<jstring> origin = | 601 ScopedJavaLocalRef<jstring> origin = |
| 603 ConvertUTF8ToJavaString(env_, origin_str); | 602 ConvertUTF8ToJavaString(env_, origin_str); |
| 604 Java_WebsitePreferenceBridge_insertLocalStorageInfoIntoMap( | 603 Java_WebsitePreferenceBridge_insertLocalStorageInfoIntoMap( |
| 605 env_, map.obj(), origin.obj(), full_origin.obj(), i->size); | 604 env_, map.obj(), origin.obj(), full_origin.obj(), i->size); |
| 606 } | 605 } |
| 607 | 606 |
| 608 Java_LocalStorageInfoReadyCallback_onLocalStorageInfoReady( | 607 base::android::RunCallbackAndroid(java_callback_, map); |
| 609 env_, java_callback_.obj(), map.obj()); | |
| 610 delete this; | 608 delete this; |
| 611 } | 609 } |
| 612 | 610 |
| 613 private: | 611 private: |
| 614 JNIEnv* env_; | 612 JNIEnv* env_; |
| 615 ScopedJavaGlobalRef<jobject> java_callback_; | 613 ScopedJavaGlobalRef<jobject> java_callback_; |
| 616 }; | 614 }; |
| 617 | 615 |
| 618 } // anonymous namespace | 616 } // anonymous namespace |
| 619 | 617 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 GURL url(ConvertJavaStringToUTF8(env, jorigin)); | 691 GURL url(ConvertJavaStringToUTF8(env, jorigin)); |
| 694 scoped_refptr<SiteDataDeleteHelper> site_data_deleter( | 692 scoped_refptr<SiteDataDeleteHelper> site_data_deleter( |
| 695 new SiteDataDeleteHelper(profile, url)); | 693 new SiteDataDeleteHelper(profile, url)); |
| 696 site_data_deleter->Run(); | 694 site_data_deleter->Run(); |
| 697 } | 695 } |
| 698 | 696 |
| 699 // Register native methods | 697 // Register native methods |
| 700 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { | 698 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { |
| 701 return RegisterNativesImpl(env); | 699 return RegisterNativesImpl(env); |
| 702 } | 700 } |
| OLD | NEW |