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 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 void SetSettingForOrigin(JNIEnv* env, | 196 void SetSettingForOrigin(JNIEnv* env, |
197 ContentSettingsType content_type, | 197 ContentSettingsType content_type, |
198 jstring origin, | 198 jstring origin, |
199 jstring embedder, | 199 jstring embedder, |
200 ContentSetting setting, | 200 ContentSetting setting, |
201 jboolean is_incognito) { | 201 jboolean is_incognito) { |
202 GURL origin_url(ConvertJavaStringToUTF8(env, origin)); | 202 GURL origin_url(ConvertJavaStringToUTF8(env, origin)); |
203 GURL embedder_url = | 203 GURL embedder_url = |
204 embedder ? GURL(ConvertJavaStringToUTF8(env, embedder)) : GURL(); | 204 embedder ? GURL(ConvertJavaStringToUTF8(env, embedder)) : GURL(); |
205 Profile* profile = GetActiveUserProfile(is_incognito); | 205 Profile* profile = GetActiveUserProfile(is_incognito); |
| 206 |
| 207 // The permission may have been blocked due to being under embargo, so if it |
| 208 // was changed away from BLOCK, clear embargo status if it exists. |
| 209 if (setting != CONTENT_SETTING_BLOCK) { |
| 210 PermissionDecisionAutoBlocker::GetForProfile(profile)->RemoveEmbargoByUrl( |
| 211 origin_url, content_type); |
| 212 } |
| 213 |
206 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter( | 214 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter( |
207 profile, origin_url, embedder_url, content_type, | 215 profile, origin_url, embedder_url, content_type, |
208 PermissionSourceUI::SITE_SETTINGS); | 216 PermissionSourceUI::SITE_SETTINGS); |
209 HostContentSettingsMapFactory::GetForProfile(profile) | 217 HostContentSettingsMapFactory::GetForProfile(profile) |
210 ->SetContentSettingDefaultScope(origin_url, embedder_url, content_type, | 218 ->SetContentSettingDefaultScope(origin_url, embedder_url, content_type, |
211 std::string(), setting); | 219 std::string(), setting); |
212 WebSiteSettingsUmaUtil::LogPermissionChange(content_type, setting); | 220 WebSiteSettingsUmaUtil::LogPermissionChange(content_type, setting); |
213 } | 221 } |
214 | 222 |
215 } // anonymous namespace | 223 } // anonymous namespace |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 JNIEnv* env, | 332 JNIEnv* env, |
325 const JavaParamRef<jclass>& clazz, | 333 const JavaParamRef<jclass>& clazz, |
326 const JavaParamRef<jstring>& origin, | 334 const JavaParamRef<jstring>& origin, |
327 jint value, | 335 jint value, |
328 jboolean is_incognito) { | 336 jboolean is_incognito) { |
329 // Note: Web Notification permission behaves differently from all other | 337 // Note: Web Notification permission behaves differently from all other |
330 // permission types. See https://crbug.com/416894. | 338 // permission types. See https://crbug.com/416894. |
331 Profile* profile = GetActiveUserProfile(is_incognito); | 339 Profile* profile = GetActiveUserProfile(is_incognito); |
332 GURL url = GURL(ConvertJavaStringToUTF8(env, origin)); | 340 GURL url = GURL(ConvertJavaStringToUTF8(env, origin)); |
333 ContentSetting setting = static_cast<ContentSetting>(value); | 341 ContentSetting setting = static_cast<ContentSetting>(value); |
| 342 |
| 343 if (setting != CONTENT_SETTING_BLOCK) { |
| 344 PermissionDecisionAutoBlocker::GetForProfile(profile)->RemoveEmbargoByUrl( |
| 345 url, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
| 346 } |
| 347 |
334 switch (setting) { | 348 switch (setting) { |
335 case CONTENT_SETTING_DEFAULT: | 349 case CONTENT_SETTING_DEFAULT: |
336 DesktopNotificationProfileUtil::ClearSetting(profile, url); | 350 DesktopNotificationProfileUtil::ClearSetting(profile, url); |
337 break; | 351 break; |
338 case CONTENT_SETTING_ALLOW: | 352 case CONTENT_SETTING_ALLOW: |
339 DesktopNotificationProfileUtil::GrantPermission(profile, url); | 353 DesktopNotificationProfileUtil::GrantPermission(profile, url); |
340 break; | 354 break; |
341 case CONTENT_SETTING_BLOCK: | 355 case CONTENT_SETTING_BLOCK: |
342 DesktopNotificationProfileUtil::DenyPermission(profile, url); | 356 DesktopNotificationProfileUtil::DenyPermission(profile, url); |
343 break; | 357 break; |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 SearchGeolocationService* search_helper = | 820 SearchGeolocationService* search_helper = |
807 SearchGeolocationService::Factory::GetForBrowserContext( | 821 SearchGeolocationService::Factory::GetForBrowserContext( |
808 GetActiveUserProfile(false /* is_incognito */)); | 822 GetActiveUserProfile(false /* is_incognito */)); |
809 return search_helper->SetDSEGeolocationSetting(setting); | 823 return search_helper->SetDSEGeolocationSetting(setting); |
810 } | 824 } |
811 | 825 |
812 // Register native methods | 826 // Register native methods |
813 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { | 827 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { |
814 return RegisterNativesImpl(env); | 828 return RegisterNativesImpl(env); |
815 } | 829 } |
OLD | NEW |