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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/android/callback_android.h" | 11 #include "base/android/callback_android.h" |
12 #include "base/android/jni_android.h" | 12 #include "base/android/jni_android.h" |
13 #include "base/android/jni_string.h" | 13 #include "base/android/jni_string.h" |
14 #include "base/android/scoped_java_ref.h" | 14 #include "base/android/scoped_java_ref.h" |
15 #include "base/bind.h" | 15 #include "base/bind.h" |
16 #include "base/bind_helpers.h" | 16 #include "base/bind_helpers.h" |
17 #include "base/json/json_reader.h" | 17 #include "base/json/json_reader.h" |
18 #include "base/json/json_writer.h" | 18 #include "base/json/json_writer.h" |
19 #include "base/logging.h" | 19 #include "base/logging.h" |
20 #include "base/macros.h" | 20 #include "base/macros.h" |
| 21 #include "base/stl_util.h" |
21 #include "chrome/browser/android/search_geolocation/search_geolocation_service.h
" | 22 #include "chrome/browser/android/search_geolocation/search_geolocation_service.h
" |
22 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" | 23 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" |
23 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 24 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
24 #include "chrome/browser/browsing_data/browsing_data_quota_helper.h" | 25 #include "chrome/browser/browsing_data/browsing_data_quota_helper.h" |
25 #include "chrome/browser/browsing_data/cookies_tree_model.h" | 26 #include "chrome/browser/browsing_data/cookies_tree_model.h" |
26 #include "chrome/browser/browsing_data/local_data_container.h" | 27 #include "chrome/browser/browsing_data/local_data_container.h" |
27 #include "chrome/browser/content_settings/cookie_settings_factory.h" | 28 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
28 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 29 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
29 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 30 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
30 #include "chrome/browser/content_settings/web_site_settings_uma_util.h" | 31 #include "chrome/browser/content_settings/web_site_settings_uma_util.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // Add any origins which have a default content setting value (thus skipped | 161 // Add any origins which have a default content setting value (thus skipped |
161 // above), but have been automatically blocked for this permission type. | 162 // above), but have been automatically blocked for this permission type. |
162 // We use an empty embedder since embargo doesn't care about it. | 163 // We use an empty embedder since embargo doesn't care about it. |
163 PermissionDecisionAutoBlocker* auto_blocker = | 164 PermissionDecisionAutoBlocker* auto_blocker = |
164 PermissionDecisionAutoBlocker::GetForProfile( | 165 PermissionDecisionAutoBlocker::GetForProfile( |
165 GetActiveUserProfile(false /* is_incognito */)); | 166 GetActiveUserProfile(false /* is_incognito */)); |
166 ScopedJavaLocalRef<jstring> jembedder; | 167 ScopedJavaLocalRef<jstring> jembedder; |
167 | 168 |
168 for (const auto& settings_it : embargo_settings) { | 169 for (const auto& settings_it : embargo_settings) { |
169 const std::string origin = settings_it.primary_pattern.ToString(); | 170 const std::string origin = settings_it.primary_pattern.ToString(); |
170 if (std::find(seen_origins.begin(), seen_origins.end(), origin) != | 171 if (base::ContainsValue(seen_origins, origin)) { |
171 seen_origins.end()) { | |
172 // This origin has already been added to the list, so don't add it again. | 172 // This origin has already been added to the list, so don't add it again. |
173 continue; | 173 continue; |
174 } | 174 } |
175 | 175 |
176 if (auto_blocker->GetEmbargoResult(GURL(origin), content_type) | 176 if (auto_blocker->GetEmbargoResult(GURL(origin), content_type) |
177 .content_setting == CONTENT_SETTING_BLOCK) { | 177 .content_setting == CONTENT_SETTING_BLOCK) { |
178 insertionFunc(env, list, ConvertOriginToJavaString(env, origin), | 178 insertionFunc(env, list, ConvertOriginToJavaString(env, origin), |
179 jembedder); | 179 jembedder); |
180 } | 180 } |
181 } | 181 } |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 const JavaParamRef<jstring>& jorigin) { | 828 const JavaParamRef<jstring>& jorigin) { |
829 GURL url(ConvertJavaStringToUTF8(env, jorigin)); | 829 GURL url(ConvertJavaStringToUTF8(env, jorigin)); |
830 return !!GetHostContentSettingsMap(false)->GetWebsiteSetting( | 830 return !!GetHostContentSettingsMap(false)->GetWebsiteSetting( |
831 url, GURL(), CONTENT_SETTINGS_TYPE_ADS_DATA, std::string(), nullptr); | 831 url, GURL(), CONTENT_SETTINGS_TYPE_ADS_DATA, std::string(), nullptr); |
832 } | 832 } |
833 | 833 |
834 // Register native methods | 834 // Register native methods |
835 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { | 835 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { |
836 return RegisterNativesImpl(env); | 836 return RegisterNativesImpl(env); |
837 } | 837 } |
OLD | NEW |