Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: chrome/browser/android/preferences/pref_service_bridge.cc

Issue 2671743002: Separate state of basic and advanced tab in CBD dialog (Closed)
Patch Set: fix .classpath file Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/pref_service_bridge.h" 5 #include "chrome/browser/android/preferences/pref_service_bridge.h"
6 6
7 #include <jni.h> 7 #include <jni.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 content_settings->GetDefaultContentSetting(content_settings_type, &source); 125 content_settings->GetDefaultContentSetting(content_settings_type, &source);
126 HostContentSettingsMap::ProviderType provider = 126 HostContentSettingsMap::ProviderType provider =
127 content_settings->GetProviderTypeFromSource(source); 127 content_settings->GetProviderTypeFromSource(source);
128 return provider >= HostContentSettingsMap::PREF_PROVIDER; 128 return provider >= HostContentSettingsMap::PREF_PROVIDER;
129 } 129 }
130 130
131 PrefService* GetPrefService() { 131 PrefService* GetPrefService() {
132 return GetOriginalProfile()->GetPrefs(); 132 return GetOriginalProfile()->GetPrefs();
133 } 133 }
134 134
135 browsing_data::ClearBrowsingDataPreferenceType ToPrefType(jint pref_type) {
136 DCHECK_GE(pref_type, 0);
137 DCHECK_LT(pref_type,
138 static_cast<int>(
139 browsing_data::ClearBrowsingDataPreferenceType::NUM_TYPES));
140
141 return static_cast<browsing_data::ClearBrowsingDataPreferenceType>(pref_type);
142 }
143
135 } // namespace 144 } // namespace
136 145
137 // ---------------------------------------------------------------------------- 146 // ----------------------------------------------------------------------------
138 // Native JNI methods 147 // Native JNI methods
139 // ---------------------------------------------------------------------------- 148 // ----------------------------------------------------------------------------
140 149
141 static jboolean IsContentSettingManaged(JNIEnv* env, 150 static jboolean IsContentSettingManaged(JNIEnv* env,
142 const JavaParamRef<jobject>& obj, 151 const JavaParamRef<jobject>& obj,
143 int content_settings_type) { 152 int content_settings_type) {
144 return IsContentSettingManaged( 153 return IsContentSettingManaged(
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 int task_count_; 541 int task_count_;
533 JavaObjectWeakGlobalRef weak_chrome_native_preferences_; 542 JavaObjectWeakGlobalRef weak_chrome_native_preferences_;
534 ScopedObserver<BrowsingDataRemover, BrowsingDataRemover::Observer> observer_; 543 ScopedObserver<BrowsingDataRemover, BrowsingDataRemover::Observer> observer_;
535 }; 544 };
536 545
537 } // namespace 546 } // namespace
538 547
539 static jboolean GetBrowsingDataDeletionPreference( 548 static jboolean GetBrowsingDataDeletionPreference(
540 JNIEnv* env, 549 JNIEnv* env,
541 const JavaParamRef<jobject>& obj, 550 const JavaParamRef<jobject>& obj,
542 jint data_type) { 551 jint data_type,
552 jint pref_type) {
543 DCHECK_GE(data_type, 0); 553 DCHECK_GE(data_type, 0);
544 DCHECK_LT(data_type, browsing_data::NUM_TYPES); 554 DCHECK_LT(data_type, browsing_data::NUM_TYPES);
545 555
546 // If there is no corresponding preference for this |data_type|, pretend 556 // If there is no corresponding preference for this |data_type|, pretend
547 // that it's set to false. 557 // that it's set to false.
548 // TODO(msramek): Consider defining native-side preferences for all Java UI 558 // TODO(msramek): Consider defining native-side preferences for all Java UI
549 // data types for consistency. 559 // data types for consistency.
550 std::string pref; 560 std::string pref;
551 if (!browsing_data::GetDeletionPreferenceFromDataType( 561 if (!browsing_data::GetDeletionPreferenceFromDataType(
552 static_cast<browsing_data::BrowsingDataType>(data_type), &pref)) { 562 static_cast<browsing_data::BrowsingDataType>(data_type),
563 ToPrefType(pref_type), &pref)) {
553 return false; 564 return false;
554 } 565 }
555 566
556 return GetOriginalProfile()->GetPrefs()->GetBoolean(pref); 567 return GetOriginalProfile()->GetPrefs()->GetBoolean(pref);
557 } 568 }
558 569
559 static void SetBrowsingDataDeletionPreference( 570 static void SetBrowsingDataDeletionPreference(JNIEnv* env,
560 JNIEnv* env, 571 const JavaParamRef<jobject>& obj,
561 const JavaParamRef<jobject>& obj, 572 jint data_type,
562 jint data_type, 573 jint pref_type,
563 jboolean value) { 574 jboolean value) {
564 DCHECK_GE(data_type, 0); 575 DCHECK_GE(data_type, 0);
565 DCHECK_LT(data_type, browsing_data::NUM_TYPES); 576 DCHECK_LT(data_type, browsing_data::NUM_TYPES);
566 577
567 std::string pref; 578 std::string pref;
568 if (!browsing_data::GetDeletionPreferenceFromDataType( 579 if (!browsing_data::GetDeletionPreferenceFromDataType(
569 static_cast<browsing_data::BrowsingDataType>(data_type), &pref)) { 580 static_cast<browsing_data::BrowsingDataType>(data_type),
581 ToPrefType(pref_type), &pref)) {
570 return; 582 return;
571 } 583 }
572 584
573 GetOriginalProfile()->GetPrefs()->SetBoolean(pref, value); 585 GetOriginalProfile()->GetPrefs()->SetBoolean(pref, value);
574 } 586 }
575 587
576 static jint GetBrowsingDataDeletionTimePeriod( 588 static jint GetBrowsingDataDeletionTimePeriod(JNIEnv* env,
577 JNIEnv* env, 589 const JavaParamRef<jobject>& obj,
578 const JavaParamRef<jobject>& obj) { 590 jint pref_type) {
579 return GetPrefService()->GetInteger(browsing_data::prefs::kDeleteTimePeriod); 591 return GetPrefService()->GetInteger(
592 browsing_data::GetTimePeriodPreferenceName(ToPrefType(pref_type)));
580 } 593 }
581 594
582 static void SetBrowsingDataDeletionTimePeriod( 595 static void SetBrowsingDataDeletionTimePeriod(JNIEnv* env,
583 JNIEnv* env, 596 const JavaParamRef<jobject>& obj,
584 const JavaParamRef<jobject>& obj, 597 jint pref_type,
585 jint time_period) { 598 jint time_period) {
586 DCHECK_GE(time_period, 0); 599 DCHECK_GE(time_period, 0);
587 DCHECK_LE(time_period, browsing_data::TIME_PERIOD_LAST); 600 DCHECK_LE(time_period, browsing_data::TIME_PERIOD_LAST);
588 GetPrefService()->SetInteger(browsing_data::prefs::kDeleteTimePeriod, 601 GetPrefService()->SetInteger(
589 time_period); 602 browsing_data::GetTimePeriodPreferenceName(ToPrefType(pref_type)),
603 time_period);
590 } 604 }
591 605
592 static jint GetLastClearBrowsingDataTab(JNIEnv* env, 606 static jint GetLastClearBrowsingDataTab(JNIEnv* env,
593 const JavaParamRef<jobject>& obj) { 607 const JavaParamRef<jobject>& obj) {
594 return GetPrefService()->GetInteger( 608 return GetPrefService()->GetInteger(
595 browsing_data::prefs::kLastClearBrowsingDataTab); 609 browsing_data::prefs::kLastClearBrowsingDataTab);
596 } 610 }
597 611
598 static void SetLastClearBrowsingDataTab(JNIEnv* env, 612 static void SetLastClearBrowsingDataTab(JNIEnv* env,
599 const JavaParamRef<jobject>& obj, 613 const JavaParamRef<jobject>& obj,
600 jint tab_index) { 614 jint tab_index) {
601 DCHECK_GE(tab_index, 0); 615 DCHECK_GE(tab_index, 0);
602 DCHECK_LT(tab_index, 2); 616 DCHECK_LT(tab_index, 2);
603 GetPrefService()->SetInteger(browsing_data::prefs::kLastClearBrowsingDataTab, 617 GetPrefService()->SetInteger(browsing_data::prefs::kLastClearBrowsingDataTab,
604 tab_index); 618 tab_index);
605 } 619 }
606 620
621 static void MigrateBrowsingDataPreferences(JNIEnv* env,
622 const JavaParamRef<jobject>& obj) {
623 browsing_data::MigratePreferencesToBasic(GetOriginalProfile()->GetPrefs());
624 }
625
607 static void ClearBrowsingData( 626 static void ClearBrowsingData(
608 JNIEnv* env, 627 JNIEnv* env,
609 const JavaParamRef<jobject>& obj, 628 const JavaParamRef<jobject>& obj,
610 const JavaParamRef<jintArray>& data_types, 629 const JavaParamRef<jintArray>& data_types,
611 jint time_period, 630 jint time_period,
612 const JavaParamRef<jobjectArray>& jexcluding_domains, 631 const JavaParamRef<jobjectArray>& jexcluding_domains,
613 const JavaParamRef<jintArray>& jexcluding_domain_reasons, 632 const JavaParamRef<jintArray>& jexcluding_domain_reasons,
614 const JavaParamRef<jobjectArray>& jignoring_domains, 633 const JavaParamRef<jobjectArray>& jignoring_domains,
615 const JavaParamRef<jintArray>& jignoring_domain_reasons) { 634 const JavaParamRef<jintArray>& jignoring_domain_reasons) {
616 BrowsingDataRemover* browsing_data_remover = 635 BrowsingDataRemover* browsing_data_remover =
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 1250
1232 return ConvertJavaStringToUTF8(android_permission); 1251 return ConvertJavaStringToUTF8(android_permission);
1233 } 1252 }
1234 1253
1235 static void SetSupervisedUserId(JNIEnv* env, 1254 static void SetSupervisedUserId(JNIEnv* env,
1236 const JavaParamRef<jobject>& obj, 1255 const JavaParamRef<jobject>& obj,
1237 const JavaParamRef<jstring>& pref) { 1256 const JavaParamRef<jstring>& pref) {
1238 GetPrefService()->SetString(prefs::kSupervisedUserId, 1257 GetPrefService()->SetString(prefs::kSupervisedUserId,
1239 ConvertJavaStringToUTF8(env, pref)); 1258 ConvertJavaStringToUTF8(env, pref));
1240 } 1259 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698