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

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

Issue 1694063002: Use GURLS instead of patterns in SetCookieSetting() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scoping_set_content_setting
Patch Set: remove unused patterns Created 4 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/browsing_data/cookies_tree_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 embedder, false); 455 embedder, false);
456 } 456 }
457 457
458 static void SetCookieSettingForOrigin(JNIEnv* env, 458 static void SetCookieSettingForOrigin(JNIEnv* env,
459 const JavaParamRef<jclass>& clazz, 459 const JavaParamRef<jclass>& clazz,
460 const JavaParamRef<jstring>& origin, 460 const JavaParamRef<jstring>& origin,
461 const JavaParamRef<jstring>& embedder, 461 const JavaParamRef<jstring>& embedder,
462 jint value, 462 jint value,
463 jboolean is_incognito) { 463 jboolean is_incognito) {
464 GURL url(ConvertJavaStringToUTF8(env, origin)); 464 GURL url(ConvertJavaStringToUTF8(env, origin));
465 ContentSettingsPattern primary_pattern( 465 ContentSetting setting = static_cast<ContentSetting>(value);
466 ContentSettingsPattern::FromURLNoWildcard(url)); 466 if (setting == CONTENT_SETTING_DEFAULT) {
467 ContentSettingsPattern secondary_pattern(ContentSettingsPattern::Wildcard());
468 ContentSetting setting = CONTENT_SETTING_DEFAULT;
469 if (value == -1) {
470 GetCookieSettings()->ResetCookieSetting(url); 467 GetCookieSettings()->ResetCookieSetting(url);
471 } else { 468 } else {
472 setting = value ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; 469 GetCookieSettings()->SetCookieSetting(url, setting);
473 GetCookieSettings()->SetCookieSetting(primary_pattern, secondary_pattern,
474 setting);
475 } 470 }
476 WebSiteSettingsUmaUtil::LogPermissionChange( 471 WebSiteSettingsUmaUtil::LogPermissionChange(CONTENT_SETTINGS_TYPE_COOKIES,
477 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, setting); 472 setting);
478 } 473 }
479 474
480 static jboolean IsContentSettingsPatternValid( 475 static jboolean IsContentSettingsPatternValid(
481 JNIEnv* env, 476 JNIEnv* env,
482 const JavaParamRef<jclass>& clazz, 477 const JavaParamRef<jclass>& clazz,
483 const JavaParamRef<jstring>& pattern) { 478 const JavaParamRef<jstring>& pattern) {
484 return ContentSettingsPattern::FromString( 479 return ContentSettingsPattern::FromString(
485 ConvertJavaStringToUTF8(env, pattern)).IsValid(); 480 ConvertJavaStringToUTF8(env, pattern)).IsValid();
486 } 481 }
487 482
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 GURL url(ConvertJavaStringToUTF8(env, jorigin)); 759 GURL url(ConvertJavaStringToUTF8(env, jorigin));
765 scoped_refptr<SiteDataDeleteHelper> site_data_deleter( 760 scoped_refptr<SiteDataDeleteHelper> site_data_deleter(
766 new SiteDataDeleteHelper(profile, url)); 761 new SiteDataDeleteHelper(profile, url));
767 site_data_deleter->Run(); 762 site_data_deleter->Run();
768 } 763 }
769 764
770 // Register native methods 765 // Register native methods
771 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { 766 bool RegisterWebsitePreferenceBridge(JNIEnv* env) {
772 return RegisterNativesImpl(env); 767 return RegisterNativesImpl(env);
773 } 768 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/browsing_data/cookies_tree_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698