Chromium Code Reviews| 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/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 jboolean is_incognito) { | 464 jboolean is_incognito) { |
| 465 GURL url(ConvertJavaStringToUTF8(env, origin)); | 465 GURL url(ConvertJavaStringToUTF8(env, origin)); |
| 466 ContentSettingsPattern primary_pattern( | 466 ContentSettingsPattern primary_pattern( |
| 467 ContentSettingsPattern::FromURLNoWildcard(url)); | 467 ContentSettingsPattern::FromURLNoWildcard(url)); |
| 468 ContentSettingsPattern secondary_pattern(ContentSettingsPattern::Wildcard()); | 468 ContentSettingsPattern secondary_pattern(ContentSettingsPattern::Wildcard()); |
| 469 ContentSetting setting = CONTENT_SETTING_DEFAULT; | 469 ContentSetting setting = CONTENT_SETTING_DEFAULT; |
| 470 if (value == -1) { | 470 if (value == -1) { |
| 471 GetCookieSettings()->ResetCookieSetting(primary_pattern, secondary_pattern); | 471 GetCookieSettings()->ResetCookieSetting(primary_pattern, secondary_pattern); |
| 472 } else { | 472 } else { |
| 473 setting = value ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; | 473 setting = value ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; |
| 474 GetCookieSettings()->SetCookieSetting(primary_pattern, secondary_pattern, | 474 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 475 setting); | 475 HostContentSettingsMapFactory::GetForProfile(profile)->SetContentSetting( |
| 476 primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_COOKIES, | |
| 477 std::string(), setting); | |
|
raymes
2016/03/16 03:24:11
I wonder if we should add a function to GetCookieS
lshang
2016/03/17 01:53:59
Done.
| |
| 476 } | 478 } |
| 477 WebSiteSettingsUmaUtil::LogPermissionChange( | 479 WebSiteSettingsUmaUtil::LogPermissionChange( |
| 478 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, setting); | 480 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, setting); |
|
raymes
2016/03/16 03:24:11
nit: this looks wrong!
lshang
2016/03/17 01:53:59
Done.⊙▂⊙
| |
| 479 } | 481 } |
| 480 | 482 |
| 481 static jboolean IsContentSettingsPatternValid( | 483 static jboolean IsContentSettingsPatternValid( |
| 482 JNIEnv* env, | 484 JNIEnv* env, |
| 483 const JavaParamRef<jclass>& clazz, | 485 const JavaParamRef<jclass>& clazz, |
| 484 const JavaParamRef<jstring>& pattern) { | 486 const JavaParamRef<jstring>& pattern) { |
| 485 return ContentSettingsPattern::FromString( | 487 return ContentSettingsPattern::FromString( |
| 486 ConvertJavaStringToUTF8(env, pattern)).IsValid(); | 488 ConvertJavaStringToUTF8(env, pattern)).IsValid(); |
| 487 } | 489 } |
| 488 | 490 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 765 GURL url(ConvertJavaStringToUTF8(env, jorigin)); | 767 GURL url(ConvertJavaStringToUTF8(env, jorigin)); |
| 766 scoped_refptr<SiteDataDeleteHelper> site_data_deleter( | 768 scoped_refptr<SiteDataDeleteHelper> site_data_deleter( |
| 767 new SiteDataDeleteHelper(profile, url)); | 769 new SiteDataDeleteHelper(profile, url)); |
| 768 site_data_deleter->Run(); | 770 site_data_deleter->Run(); |
| 769 } | 771 } |
| 770 | 772 |
| 771 // Register native methods | 773 // Register native methods |
| 772 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { | 774 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { |
| 773 return RegisterNativesImpl(env); | 775 return RegisterNativesImpl(env); |
| 774 } | 776 } |
| OLD | NEW |