| OLD | NEW |
| 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 | 8 |
| 9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| 11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
| 12 #include "base/android/jni_weak_ref.h" | 12 #include "base/android/jni_weak_ref.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 20 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 21 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 21 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 22 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 22 #include "chrome/browser/net/prediction_options.h" | 23 #include "chrome/browser/net/prediction_options.h" |
| 23 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 24 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 24 #include "chrome/browser/profiles/profile_manager.h" | 25 #include "chrome/browser/profiles/profile_manager.h" |
| 25 #include "chrome/browser/translate/chrome_translate_client.h" | 26 #include "chrome/browser/translate/chrome_translate_client.h" |
| 26 #include "chrome/browser/ui/android/android_about_app_info.h" | 27 #include "chrome/browser/ui/android/android_about_app_info.h" |
| 27 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 28 #include "chrome/grit/locale_settings.h" | 29 #include "chrome/grit/locale_settings.h" |
| 29 #include "components/content_settings/core/browser/host_content_settings_map.h" | 30 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 30 #include "components/content_settings/core/common/content_settings.h" | 31 #include "components/content_settings/core/common/content_settings.h" |
| 31 #include "components/content_settings/core/common/content_settings_pattern.h" | 32 #include "components/content_settings/core/common/content_settings_pattern.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 55 NETWORK_PREDICTION_WIFI_ONLY, | 56 NETWORK_PREDICTION_WIFI_ONLY, |
| 56 NETWORK_PREDICTION_NEVER, | 57 NETWORK_PREDICTION_NEVER, |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 Profile* GetOriginalProfile() { | 60 Profile* GetOriginalProfile() { |
| 60 return ProfileManager::GetActiveUserProfile()->GetOriginalProfile(); | 61 return ProfileManager::GetActiveUserProfile()->GetOriginalProfile(); |
| 61 } | 62 } |
| 62 | 63 |
| 63 bool GetBooleanForContentSetting(ContentSettingsType type) { | 64 bool GetBooleanForContentSetting(ContentSettingsType type) { |
| 64 HostContentSettingsMap* content_settings = | 65 HostContentSettingsMap* content_settings = |
| 65 GetOriginalProfile()->GetHostContentSettingsMap(); | 66 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 66 switch (content_settings->GetDefaultContentSetting(type, NULL)) { | 67 switch (content_settings->GetDefaultContentSetting(type, NULL)) { |
| 67 case CONTENT_SETTING_BLOCK: | 68 case CONTENT_SETTING_BLOCK: |
| 68 return false; | 69 return false; |
| 69 case CONTENT_SETTING_ALLOW: | 70 case CONTENT_SETTING_ALLOW: |
| 70 return true; | 71 return true; |
| 71 case CONTENT_SETTING_ASK: | 72 case CONTENT_SETTING_ASK: |
| 72 default: | 73 default: |
| 73 return true; | 74 return true; |
| 74 } | 75 } |
| 75 } | 76 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 91 return "num_settings"; | 92 return "num_settings"; |
| 92 case CONTENT_SETTING_DEFAULT: | 93 case CONTENT_SETTING_DEFAULT: |
| 93 default: | 94 default: |
| 94 return "default"; | 95 return "default"; |
| 95 } | 96 } |
| 96 } | 97 } |
| 97 | 98 |
| 98 bool IsContentSettingManaged(ContentSettingsType content_settings_type) { | 99 bool IsContentSettingManaged(ContentSettingsType content_settings_type) { |
| 99 std::string source; | 100 std::string source; |
| 100 HostContentSettingsMap* content_settings = | 101 HostContentSettingsMap* content_settings = |
| 101 GetOriginalProfile()->GetHostContentSettingsMap(); | 102 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 102 content_settings->GetDefaultContentSetting(content_settings_type, &source); | 103 content_settings->GetDefaultContentSetting(content_settings_type, &source); |
| 103 HostContentSettingsMap::ProviderType provider = | 104 HostContentSettingsMap::ProviderType provider = |
| 104 content_settings->GetProviderTypeFromSource(source); | 105 content_settings->GetProviderTypeFromSource(source); |
| 105 return provider == HostContentSettingsMap::POLICY_PROVIDER; | 106 return provider == HostContentSettingsMap::POLICY_PROVIDER; |
| 106 } | 107 } |
| 107 | 108 |
| 108 bool IsContentSettingManagedByCustodian( | 109 bool IsContentSettingManagedByCustodian( |
| 109 ContentSettingsType content_settings_type) { | 110 ContentSettingsType content_settings_type) { |
| 110 std::string source; | 111 std::string source; |
| 111 HostContentSettingsMap* content_settings = | 112 HostContentSettingsMap* content_settings = |
| 112 GetOriginalProfile()->GetHostContentSettingsMap(); | 113 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 113 content_settings->GetDefaultContentSetting(content_settings_type, &source); | 114 content_settings->GetDefaultContentSetting(content_settings_type, &source); |
| 114 HostContentSettingsMap::ProviderType provider = | 115 HostContentSettingsMap::ProviderType provider = |
| 115 content_settings->GetProviderTypeFromSource(source); | 116 content_settings->GetProviderTypeFromSource(source); |
| 116 return provider == HostContentSettingsMap::SUPERVISED_PROVIDER; | 117 return provider == HostContentSettingsMap::SUPERVISED_PROVIDER; |
| 117 } | 118 } |
| 118 | 119 |
| 119 bool IsContentSettingUserModifiable(ContentSettingsType content_settings_type) { | 120 bool IsContentSettingUserModifiable(ContentSettingsType content_settings_type) { |
| 120 std::string source; | 121 std::string source; |
| 121 HostContentSettingsMap* content_settings = | 122 HostContentSettingsMap* content_settings = |
| 122 GetOriginalProfile()->GetHostContentSettingsMap(); | 123 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 123 content_settings->GetDefaultContentSetting(content_settings_type, &source); | 124 content_settings->GetDefaultContentSetting(content_settings_type, &source); |
| 124 HostContentSettingsMap::ProviderType provider = | 125 HostContentSettingsMap::ProviderType provider = |
| 125 content_settings->GetProviderTypeFromSource(source); | 126 content_settings->GetProviderTypeFromSource(source); |
| 126 return provider >= HostContentSettingsMap::PREF_PROVIDER; | 127 return provider >= HostContentSettingsMap::PREF_PROVIDER; |
| 127 } | 128 } |
| 128 | 129 |
| 129 PrefService* GetPrefService() { | 130 PrefService* GetPrefService() { |
| 130 return GetOriginalProfile()->GetPrefs(); | 131 return GetOriginalProfile()->GetPrefs(); |
| 131 } | 132 } |
| 132 | 133 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 151 DCHECK(content_settings_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || | 152 DCHECK(content_settings_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || |
| 152 content_settings_type == CONTENT_SETTINGS_TYPE_IMAGES || | 153 content_settings_type == CONTENT_SETTINGS_TYPE_IMAGES || |
| 153 content_settings_type == CONTENT_SETTINGS_TYPE_POPUPS); | 154 content_settings_type == CONTENT_SETTINGS_TYPE_POPUPS); |
| 154 ContentSettingsType type = | 155 ContentSettingsType type = |
| 155 static_cast<ContentSettingsType>(content_settings_type); | 156 static_cast<ContentSettingsType>(content_settings_type); |
| 156 if (type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || | 157 if (type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || |
| 157 type == CONTENT_SETTINGS_TYPE_POPUPS) | 158 type == CONTENT_SETTINGS_TYPE_POPUPS) |
| 158 return GetBooleanForContentSetting(type); | 159 return GetBooleanForContentSetting(type); |
| 159 | 160 |
| 160 HostContentSettingsMap* content_settings = | 161 HostContentSettingsMap* content_settings = |
| 161 GetOriginalProfile()->GetHostContentSettingsMap(); | 162 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 162 return content_settings->GetDefaultContentSetting( | 163 return content_settings->GetDefaultContentSetting( |
| 163 type, nullptr) == CONTENT_SETTING_ALLOW; | 164 type, nullptr) == CONTENT_SETTING_ALLOW; |
| 164 } | 165 } |
| 165 | 166 |
| 166 static void SetContentSettingEnabled(JNIEnv* env, | 167 static void SetContentSettingEnabled(JNIEnv* env, |
| 167 const JavaParamRef<jobject>& obj, | 168 const JavaParamRef<jobject>& obj, |
| 168 int content_settings_type, | 169 int content_settings_type, |
| 169 jboolean allow) { | 170 jboolean allow) { |
| 170 // Before we migrate functions over to this central function, we must verify | 171 // Before we migrate functions over to this central function, we must verify |
| 171 // that the new category supports ALLOW/BLOCK pairs and, if not, handle them. | 172 // that the new category supports ALLOW/BLOCK pairs and, if not, handle them. |
| 172 DCHECK(content_settings_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || | 173 DCHECK(content_settings_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || |
| 173 content_settings_type == CONTENT_SETTINGS_TYPE_IMAGES || | 174 content_settings_type == CONTENT_SETTINGS_TYPE_IMAGES || |
| 174 content_settings_type == CONTENT_SETTINGS_TYPE_POPUPS); | 175 content_settings_type == CONTENT_SETTINGS_TYPE_POPUPS); |
| 175 HostContentSettingsMap* host_content_settings_map = | 176 HostContentSettingsMap* host_content_settings_map = |
| 176 GetOriginalProfile()->GetHostContentSettingsMap(); | 177 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 177 host_content_settings_map->SetDefaultContentSetting( | 178 host_content_settings_map->SetDefaultContentSetting( |
| 178 static_cast<ContentSettingsType>(content_settings_type), | 179 static_cast<ContentSettingsType>(content_settings_type), |
| 179 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); | 180 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); |
| 180 } | 181 } |
| 181 | 182 |
| 182 static void SetContentSettingForPattern(JNIEnv* env, | 183 static void SetContentSettingForPattern(JNIEnv* env, |
| 183 const JavaParamRef<jobject>& obj, | 184 const JavaParamRef<jobject>& obj, |
| 184 int content_settings_type, | 185 int content_settings_type, |
| 185 const JavaParamRef<jstring>& pattern, | 186 const JavaParamRef<jstring>& pattern, |
| 186 int setting) { | 187 int setting) { |
| 187 HostContentSettingsMap* host_content_settings_map = | 188 HostContentSettingsMap* host_content_settings_map = |
| 188 GetOriginalProfile()->GetHostContentSettingsMap(); | 189 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 189 host_content_settings_map->SetContentSetting( | 190 host_content_settings_map->SetContentSetting( |
| 190 ContentSettingsPattern::FromString(ConvertJavaStringToUTF8(env, pattern)), | 191 ContentSettingsPattern::FromString(ConvertJavaStringToUTF8(env, pattern)), |
| 191 ContentSettingsPattern::Wildcard(), | 192 ContentSettingsPattern::Wildcard(), |
| 192 static_cast<ContentSettingsType>(content_settings_type), | 193 static_cast<ContentSettingsType>(content_settings_type), |
| 193 "", | 194 "", |
| 194 static_cast<ContentSetting>(setting)); | 195 static_cast<ContentSetting>(setting)); |
| 195 } | 196 } |
| 196 | 197 |
| 197 static void GetContentSettingsExceptions(JNIEnv* env, | 198 static void GetContentSettingsExceptions(JNIEnv* env, |
| 198 const JavaParamRef<jobject>& obj, | 199 const JavaParamRef<jobject>& obj, |
| 199 int content_settings_type, | 200 int content_settings_type, |
| 200 const JavaParamRef<jobject>& list) { | 201 const JavaParamRef<jobject>& list) { |
| 201 HostContentSettingsMap* host_content_settings_map = | 202 HostContentSettingsMap* host_content_settings_map = |
| 202 GetOriginalProfile()->GetHostContentSettingsMap(); | 203 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 203 ContentSettingsForOneType entries; | 204 ContentSettingsForOneType entries; |
| 204 host_content_settings_map->GetSettingsForOneType( | 205 host_content_settings_map->GetSettingsForOneType( |
| 205 static_cast<ContentSettingsType>(content_settings_type), "", &entries); | 206 static_cast<ContentSettingsType>(content_settings_type), "", &entries); |
| 206 for (size_t i = 0; i < entries.size(); ++i) { | 207 for (size_t i = 0; i < entries.size(); ++i) { |
| 207 Java_PrefServiceBridge_addContentSettingExceptionToList( | 208 Java_PrefServiceBridge_addContentSettingExceptionToList( |
| 208 env, list, | 209 env, list, |
| 209 content_settings_type, | 210 content_settings_type, |
| 210 ConvertUTF8ToJavaString( | 211 ConvertUTF8ToJavaString( |
| 211 env, entries[i].primary_pattern.ToString()).obj(), | 212 env, entries[i].primary_pattern.ToString()).obj(), |
| 212 ConvertUTF8ToJavaString( | 213 ConvertUTF8ToJavaString( |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 static jboolean GetAllowLocationEnabled(JNIEnv* env, | 373 static jboolean GetAllowLocationEnabled(JNIEnv* env, |
| 373 const JavaParamRef<jobject>& obj) { | 374 const JavaParamRef<jobject>& obj) { |
| 374 return GetBooleanForContentSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION); | 375 return GetBooleanForContentSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION); |
| 375 } | 376 } |
| 376 | 377 |
| 377 static jboolean GetLocationAllowedByPolicy(JNIEnv* env, | 378 static jboolean GetLocationAllowedByPolicy(JNIEnv* env, |
| 378 const JavaParamRef<jobject>& obj) { | 379 const JavaParamRef<jobject>& obj) { |
| 379 if (!IsContentSettingManaged(CONTENT_SETTINGS_TYPE_GEOLOCATION)) | 380 if (!IsContentSettingManaged(CONTENT_SETTINGS_TYPE_GEOLOCATION)) |
| 380 return false; | 381 return false; |
| 381 HostContentSettingsMap* content_settings = | 382 HostContentSettingsMap* content_settings = |
| 382 GetOriginalProfile()->GetHostContentSettingsMap(); | 383 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 383 return content_settings->GetDefaultContentSetting( | 384 return content_settings->GetDefaultContentSetting( |
| 384 CONTENT_SETTINGS_TYPE_GEOLOCATION, nullptr) == | 385 CONTENT_SETTINGS_TYPE_GEOLOCATION, nullptr) == |
| 385 CONTENT_SETTING_ALLOW; | 386 CONTENT_SETTING_ALLOW; |
| 386 } | 387 } |
| 387 | 388 |
| 388 static jboolean GetAllowLocationUserModifiable( | 389 static jboolean GetAllowLocationUserModifiable( |
| 389 JNIEnv* env, | 390 JNIEnv* env, |
| 390 const JavaParamRef<jobject>& obj) { | 391 const JavaParamRef<jobject>& obj) { |
| 391 return IsContentSettingUserModifiable(CONTENT_SETTINGS_TYPE_GEOLOCATION); | 392 return IsContentSettingUserModifiable(CONTENT_SETTINGS_TYPE_GEOLOCATION); |
| 392 } | 393 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 } | 447 } |
| 447 | 448 |
| 448 static jboolean GetFullscreenManaged(JNIEnv* env, | 449 static jboolean GetFullscreenManaged(JNIEnv* env, |
| 449 const JavaParamRef<jobject>& obj) { | 450 const JavaParamRef<jobject>& obj) { |
| 450 return IsContentSettingManaged(CONTENT_SETTINGS_TYPE_FULLSCREEN); | 451 return IsContentSettingManaged(CONTENT_SETTINGS_TYPE_FULLSCREEN); |
| 451 } | 452 } |
| 452 | 453 |
| 453 static jboolean GetFullscreenAllowed(JNIEnv* env, | 454 static jboolean GetFullscreenAllowed(JNIEnv* env, |
| 454 const JavaParamRef<jobject>& obj) { | 455 const JavaParamRef<jobject>& obj) { |
| 455 HostContentSettingsMap* content_settings = | 456 HostContentSettingsMap* content_settings = |
| 456 GetOriginalProfile()->GetHostContentSettingsMap(); | 457 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 457 return content_settings->GetDefaultContentSetting( | 458 return content_settings->GetDefaultContentSetting( |
| 458 CONTENT_SETTINGS_TYPE_FULLSCREEN, NULL) == CONTENT_SETTING_ALLOW; | 459 CONTENT_SETTINGS_TYPE_FULLSCREEN, NULL) == CONTENT_SETTING_ALLOW; |
| 459 } | 460 } |
| 460 | 461 |
| 461 static jboolean GetMetricsReportingEnabled(JNIEnv* env, | 462 static jboolean GetMetricsReportingEnabled(JNIEnv* env, |
| 462 const JavaParamRef<jobject>& obj) { | 463 const JavaParamRef<jobject>& obj) { |
| 463 PrefService* local_state = g_browser_process->local_state(); | 464 PrefService* local_state = g_browser_process->local_state(); |
| 464 return local_state->GetBoolean(prefs::kMetricsReportingEnabled); | 465 return local_state->GetBoolean(prefs::kMetricsReportingEnabled); |
| 465 } | 466 } |
| 466 | 467 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 | 542 |
| 542 static jboolean CanDeleteBrowsingHistory(JNIEnv* env, | 543 static jboolean CanDeleteBrowsingHistory(JNIEnv* env, |
| 543 const JavaParamRef<jobject>& obj) { | 544 const JavaParamRef<jobject>& obj) { |
| 544 return GetPrefService()->GetBoolean(prefs::kAllowDeletingBrowserHistory); | 545 return GetPrefService()->GetBoolean(prefs::kAllowDeletingBrowserHistory); |
| 545 } | 546 } |
| 546 | 547 |
| 547 static void SetAllowCookiesEnabled(JNIEnv* env, | 548 static void SetAllowCookiesEnabled(JNIEnv* env, |
| 548 const JavaParamRef<jobject>& obj, | 549 const JavaParamRef<jobject>& obj, |
| 549 jboolean allow) { | 550 jboolean allow) { |
| 550 HostContentSettingsMap* host_content_settings_map = | 551 HostContentSettingsMap* host_content_settings_map = |
| 551 GetOriginalProfile()->GetHostContentSettingsMap(); | 552 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 552 host_content_settings_map->SetDefaultContentSetting( | 553 host_content_settings_map->SetDefaultContentSetting( |
| 553 CONTENT_SETTINGS_TYPE_COOKIES, | 554 CONTENT_SETTINGS_TYPE_COOKIES, |
| 554 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); | 555 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); |
| 555 } | 556 } |
| 556 | 557 |
| 557 static void SetBlockThirdPartyCookiesEnabled(JNIEnv* env, | 558 static void SetBlockThirdPartyCookiesEnabled(JNIEnv* env, |
| 558 const JavaParamRef<jobject>& obj, | 559 const JavaParamRef<jobject>& obj, |
| 559 jboolean enabled) { | 560 jboolean enabled) { |
| 560 GetPrefService()->SetBoolean(prefs::kBlockThirdPartyCookies, enabled); | 561 GetPrefService()->SetBoolean(prefs::kBlockThirdPartyCookies, enabled); |
| 561 } | 562 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 572 const JavaParamRef<jobject>& obj, | 573 const JavaParamRef<jobject>& obj, |
| 573 jboolean enabled) { | 574 jboolean enabled) { |
| 574 GetPrefService()->SetBoolean( | 575 GetPrefService()->SetBoolean( |
| 575 password_manager::prefs::kPasswordManagerAutoSignin, enabled); | 576 password_manager::prefs::kPasswordManagerAutoSignin, enabled); |
| 576 } | 577 } |
| 577 | 578 |
| 578 static void SetProtectedMediaIdentifierEnabled(JNIEnv* env, | 579 static void SetProtectedMediaIdentifierEnabled(JNIEnv* env, |
| 579 const JavaParamRef<jobject>& obj, | 580 const JavaParamRef<jobject>& obj, |
| 580 jboolean is_enabled) { | 581 jboolean is_enabled) { |
| 581 HostContentSettingsMap* host_content_settings_map = | 582 HostContentSettingsMap* host_content_settings_map = |
| 582 GetOriginalProfile()->GetHostContentSettingsMap(); | 583 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 583 host_content_settings_map->SetDefaultContentSetting( | 584 host_content_settings_map->SetDefaultContentSetting( |
| 584 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, | 585 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, |
| 585 is_enabled ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); | 586 is_enabled ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); |
| 586 } | 587 } |
| 587 | 588 |
| 588 static void SetAllowLocationEnabled(JNIEnv* env, | 589 static void SetAllowLocationEnabled(JNIEnv* env, |
| 589 const JavaParamRef<jobject>& obj, | 590 const JavaParamRef<jobject>& obj, |
| 590 jboolean is_enabled) { | 591 jboolean is_enabled) { |
| 591 HostContentSettingsMap* host_content_settings_map = | 592 HostContentSettingsMap* host_content_settings_map = |
| 592 GetOriginalProfile()->GetHostContentSettingsMap(); | 593 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 593 host_content_settings_map->SetDefaultContentSetting( | 594 host_content_settings_map->SetDefaultContentSetting( |
| 594 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 595 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 595 is_enabled ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); | 596 is_enabled ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); |
| 596 } | 597 } |
| 597 | 598 |
| 598 static void SetCameraEnabled(JNIEnv* env, | 599 static void SetCameraEnabled(JNIEnv* env, |
| 599 const JavaParamRef<jobject>& obj, | 600 const JavaParamRef<jobject>& obj, |
| 600 jboolean allow) { | 601 jboolean allow) { |
| 601 HostContentSettingsMap* host_content_settings_map = | 602 HostContentSettingsMap* host_content_settings_map = |
| 602 GetOriginalProfile()->GetHostContentSettingsMap(); | 603 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 603 host_content_settings_map->SetDefaultContentSetting( | 604 host_content_settings_map->SetDefaultContentSetting( |
| 604 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, | 605 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, |
| 605 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); | 606 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); |
| 606 } | 607 } |
| 607 | 608 |
| 608 static void SetMicEnabled(JNIEnv* env, | 609 static void SetMicEnabled(JNIEnv* env, |
| 609 const JavaParamRef<jobject>& obj, | 610 const JavaParamRef<jobject>& obj, |
| 610 jboolean allow) { | 611 jboolean allow) { |
| 611 HostContentSettingsMap* host_content_settings_map = | 612 HostContentSettingsMap* host_content_settings_map = |
| 612 GetOriginalProfile()->GetHostContentSettingsMap(); | 613 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 613 host_content_settings_map->SetDefaultContentSetting( | 614 host_content_settings_map->SetDefaultContentSetting( |
| 614 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, | 615 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
| 615 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); | 616 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); |
| 616 } | 617 } |
| 617 | 618 |
| 618 static void SetFullscreenAllowed(JNIEnv* env, | 619 static void SetFullscreenAllowed(JNIEnv* env, |
| 619 const JavaParamRef<jobject>& obj, | 620 const JavaParamRef<jobject>& obj, |
| 620 jboolean allow) { | 621 jboolean allow) { |
| 621 HostContentSettingsMap* host_content_settings_map = | 622 HostContentSettingsMap* host_content_settings_map = |
| 622 GetOriginalProfile()->GetHostContentSettingsMap(); | 623 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 623 host_content_settings_map->SetDefaultContentSetting( | 624 host_content_settings_map->SetDefaultContentSetting( |
| 624 CONTENT_SETTINGS_TYPE_FULLSCREEN, | 625 CONTENT_SETTINGS_TYPE_FULLSCREEN, |
| 625 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_ASK); | 626 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_ASK); |
| 626 } | 627 } |
| 627 | 628 |
| 628 static void SetPushNotificationsEnabled(JNIEnv* env, | 629 static void SetPushNotificationsEnabled(JNIEnv* env, |
| 629 const JavaParamRef<jobject>& obj, | 630 const JavaParamRef<jobject>& obj, |
| 630 jboolean allow) { | 631 jboolean allow) { |
| 631 HostContentSettingsMap* host_content_settings_map = | 632 HostContentSettingsMap* host_content_settings_map = |
| 632 GetOriginalProfile()->GetHostContentSettingsMap(); | 633 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 633 host_content_settings_map->SetDefaultContentSetting( | 634 host_content_settings_map->SetDefaultContentSetting( |
| 634 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 635 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| 635 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); | 636 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); |
| 636 } | 637 } |
| 637 | 638 |
| 638 static void SetCrashReporting(JNIEnv* env, | 639 static void SetCrashReporting(JNIEnv* env, |
| 639 const JavaParamRef<jobject>& obj, | 640 const JavaParamRef<jobject>& obj, |
| 640 jboolean reporting) { | 641 jboolean reporting) { |
| 641 PrefService* local_state = g_browser_process->local_state(); | 642 PrefService* local_state = g_browser_process->local_state(); |
| 642 local_state->SetBoolean(prefs::kCrashReportingEnabled, reporting); | 643 local_state->SetBoolean(prefs::kCrashReportingEnabled, reporting); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 const JavaParamRef<jobject>& obj) { | 767 const JavaParamRef<jobject>& obj) { |
| 767 return IsContentSettingManagedByCustodian( | 768 return IsContentSettingManagedByCustodian( |
| 768 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 769 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
| 769 } | 770 } |
| 770 | 771 |
| 771 static void SetJavaScriptAllowed(JNIEnv* env, | 772 static void SetJavaScriptAllowed(JNIEnv* env, |
| 772 const JavaParamRef<jobject>& obj, | 773 const JavaParamRef<jobject>& obj, |
| 773 const JavaParamRef<jstring>& pattern, | 774 const JavaParamRef<jstring>& pattern, |
| 774 int setting) { | 775 int setting) { |
| 775 HostContentSettingsMap* host_content_settings_map = | 776 HostContentSettingsMap* host_content_settings_map = |
| 776 GetOriginalProfile()->GetHostContentSettingsMap(); | 777 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 777 host_content_settings_map->SetContentSetting( | 778 host_content_settings_map->SetContentSetting( |
| 778 ContentSettingsPattern::FromString(ConvertJavaStringToUTF8(env, pattern)), | 779 ContentSettingsPattern::FromString(ConvertJavaStringToUTF8(env, pattern)), |
| 779 ContentSettingsPattern::Wildcard(), | 780 ContentSettingsPattern::Wildcard(), |
| 780 CONTENT_SETTINGS_TYPE_JAVASCRIPT, | 781 CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
| 781 "", | 782 "", |
| 782 static_cast<ContentSetting>(setting)); | 783 static_cast<ContentSetting>(setting)); |
| 783 } | 784 } |
| 784 | 785 |
| 785 static void SetPopupException(JNIEnv* env, | 786 static void SetPopupException(JNIEnv* env, |
| 786 const JavaParamRef<jobject>& obj, | 787 const JavaParamRef<jobject>& obj, |
| 787 const JavaParamRef<jstring>& pattern, | 788 const JavaParamRef<jstring>& pattern, |
| 788 int setting) { | 789 int setting) { |
| 789 HostContentSettingsMap* host_content_settings_map = | 790 HostContentSettingsMap* host_content_settings_map = |
| 790 GetOriginalProfile()->GetHostContentSettingsMap(); | 791 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 791 host_content_settings_map->SetContentSetting( | 792 host_content_settings_map->SetContentSetting( |
| 792 ContentSettingsPattern::FromString(ConvertJavaStringToUTF8(env, pattern)), | 793 ContentSettingsPattern::FromString(ConvertJavaStringToUTF8(env, pattern)), |
| 793 ContentSettingsPattern::Wildcard(), | 794 ContentSettingsPattern::Wildcard(), |
| 794 CONTENT_SETTINGS_TYPE_POPUPS, | 795 CONTENT_SETTINGS_TYPE_POPUPS, |
| 795 "", | 796 "", |
| 796 static_cast<ContentSetting>(setting)); | 797 static_cast<ContentSetting>(setting)); |
| 797 } | 798 } |
| 798 | 799 |
| 799 static void SetSearchSuggestEnabled(JNIEnv* env, | 800 static void SetSearchSuggestEnabled(JNIEnv* env, |
| 800 const JavaParamRef<jobject>& obj, | 801 const JavaParamRef<jobject>& obj, |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 ContentSettingsType content_type) { | 967 ContentSettingsType content_type) { |
| 967 JNIEnv* env = AttachCurrentThread(); | 968 JNIEnv* env = AttachCurrentThread(); |
| 968 base::android::ScopedJavaLocalRef<jstring> android_permission = | 969 base::android::ScopedJavaLocalRef<jstring> android_permission = |
| 969 Java_PrefServiceBridge_getAndroidPermissionForContentSetting( | 970 Java_PrefServiceBridge_getAndroidPermissionForContentSetting( |
| 970 env, content_type); | 971 env, content_type); |
| 971 if (android_permission.is_null()) | 972 if (android_permission.is_null()) |
| 972 return std::string(); | 973 return std::string(); |
| 973 | 974 |
| 974 return ConvertJavaStringToUTF8(android_permission); | 975 return ConvertJavaStringToUTF8(android_permission); |
| 975 } | 976 } |
| OLD | NEW |