| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // for HTTPS sites and :80 for HTTP sites). | 68 // for HTTPS sites and :80 for HTTP sites). |
| 69 // TODO(sashab,lgarron): Find out which settings are being saved with the | 69 // TODO(sashab,lgarron): Find out which settings are being saved with the |
| 70 // port and omit it if it's the standard port. | 70 // port and omit it if it's the standard port. |
| 71 // TODO(mvanouwerkerk): Remove all this logic and take two passes through | 71 // TODO(mvanouwerkerk): Remove all this logic and take two passes through |
| 72 // HostContentSettingsMap: once to get all the 'interesting' hosts, and once | 72 // HostContentSettingsMap: once to get all the 'interesting' hosts, and once |
| 73 // (on SingleWebsitePreferences) to find permission patterns which match | 73 // (on SingleWebsitePreferences) to find permission patterns which match |
| 74 // each of these hosts. | 74 // each of these hosts. |
| 75 const char* kHttpPortSuffix = ":80"; | 75 const char* kHttpPortSuffix = ":80"; |
| 76 const char* kHttpsPortSuffix = ":443"; | 76 const char* kHttpsPortSuffix = ":443"; |
| 77 ScopedJavaLocalRef<jstring> jorigin; | 77 ScopedJavaLocalRef<jstring> jorigin; |
| 78 if (base::StartsWithASCII(origin, url::kHttpsScheme, false) && | 78 if (base::StartsWith(origin, url::kHttpsScheme, |
| 79 base::EndsWith(origin, kHttpsPortSuffix, false)) { | 79 base::CompareCase::INSENSITIVE_ASCII) && |
| 80 base::EndsWith(origin, kHttpsPortSuffix, |
| 81 base::CompareCase::INSENSITIVE_ASCII)) { |
| 80 jorigin = ConvertUTF8ToJavaString( | 82 jorigin = ConvertUTF8ToJavaString( |
| 81 env, origin.substr(0, origin.size() - strlen(kHttpsPortSuffix))); | 83 env, origin.substr(0, origin.size() - strlen(kHttpsPortSuffix))); |
| 82 } else if (base::StartsWithASCII(origin, url::kHttpScheme, false) && | 84 } else if (base::StartsWith(origin, url::kHttpScheme, |
| 83 base::EndsWith(origin, kHttpPortSuffix, false)) { | 85 base::CompareCase::INSENSITIVE_ASCII) && |
| 86 base::EndsWith(origin, kHttpPortSuffix, |
| 87 base::CompareCase::INSENSITIVE_ASCII)) { |
| 84 jorigin = ConvertUTF8ToJavaString( | 88 jorigin = ConvertUTF8ToJavaString( |
| 85 env, origin.substr(0, origin.size() - strlen(kHttpPortSuffix))); | 89 env, origin.substr(0, origin.size() - strlen(kHttpPortSuffix))); |
| 86 } else { | 90 } else { |
| 87 jorigin = ConvertUTF8ToJavaString(env, origin); | 91 jorigin = ConvertUTF8ToJavaString(env, origin); |
| 88 } | 92 } |
| 89 | 93 |
| 90 ScopedJavaLocalRef<jstring> jembedder; | 94 ScopedJavaLocalRef<jstring> jembedder; |
| 91 if (embedder != origin) | 95 if (embedder != origin) |
| 92 jembedder = ConvertUTF8ToJavaString(env, embedder); | 96 jembedder = ConvertUTF8ToJavaString(env, embedder); |
| 93 switch (content_type) { | 97 switch (content_type) { |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 GURL url(ConvertJavaStringToUTF8(env, jorigin)); | 706 GURL url(ConvertJavaStringToUTF8(env, jorigin)); |
| 703 scoped_refptr<SiteDataDeleteHelper> site_data_deleter( | 707 scoped_refptr<SiteDataDeleteHelper> site_data_deleter( |
| 704 new SiteDataDeleteHelper(profile, url)); | 708 new SiteDataDeleteHelper(profile, url)); |
| 705 site_data_deleter->Run(); | 709 site_data_deleter->Run(); |
| 706 } | 710 } |
| 707 | 711 |
| 708 // Register native methods | 712 // Register native methods |
| 709 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { | 713 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { |
| 710 return RegisterNativesImpl(env); | 714 return RegisterNativesImpl(env); |
| 711 } | 715 } |
| OLD | NEW |