Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/permissions/permission_context_base.h" | 5 #include "chrome/browser/permissions/permission_context_base.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 | 45 |
| 46 // static | 46 // static |
| 47 const char PermissionContextBase::kPermissionsKillSwitchFieldStudy[] = | 47 const char PermissionContextBase::kPermissionsKillSwitchFieldStudy[] = |
| 48 "PermissionsKillSwitch"; | 48 "PermissionsKillSwitch"; |
| 49 // static | 49 // static |
| 50 const char PermissionContextBase::kPermissionsKillSwitchBlockedValue[] = | 50 const char PermissionContextBase::kPermissionsKillSwitchBlockedValue[] = |
| 51 "blocked"; | 51 "blocked"; |
| 52 | 52 |
| 53 PermissionContextBase::PermissionContextBase( | 53 PermissionContextBase::PermissionContextBase( |
| 54 Profile* profile, | 54 Profile* profile, |
| 55 const content::PermissionType permission_type, | |
| 56 const ContentSettingsType content_settings_type) | 55 const ContentSettingsType content_settings_type) |
| 57 : profile_(profile), | 56 : profile_(profile), |
| 58 permission_type_(permission_type), | |
| 59 content_settings_type_(content_settings_type), | 57 content_settings_type_(content_settings_type), |
| 60 weak_factory_(this) { | 58 weak_factory_(this) { |
| 61 #if defined(OS_ANDROID) | 59 #if defined(OS_ANDROID) |
| 62 permission_queue_controller_.reset(new PermissionQueueController( | 60 permission_queue_controller_.reset( |
| 63 profile_, permission_type_, content_settings_type_)); | 61 new PermissionQueueController(profile_, content_settings_type_)); |
| 64 #endif | 62 #endif |
| 65 PermissionDecisionAutoBlocker::UpdateFromVariations(); | 63 PermissionDecisionAutoBlocker::UpdateFromVariations(); |
| 66 } | 64 } |
| 67 | 65 |
| 68 PermissionContextBase::~PermissionContextBase() { | 66 PermissionContextBase::~PermissionContextBase() { |
| 69 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 67 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 70 } | 68 } |
| 71 | 69 |
| 72 void PermissionContextBase::RequestPermission( | 70 void PermissionContextBase::RequestPermission( |
| 73 content::WebContents* web_contents, | 71 content::WebContents* web_contents, |
| 74 const PermissionRequestID& id, | 72 const PermissionRequestID& id, |
| 75 const GURL& requesting_frame, | 73 const GURL& requesting_frame, |
| 76 bool user_gesture, | 74 bool user_gesture, |
| 77 const BrowserPermissionCallback& callback) { | 75 const BrowserPermissionCallback& callback) { |
| 78 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 76 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 79 | 77 |
| 80 // First check if this permission has been disabled. | 78 // First check if this permission has been disabled. |
| 81 if (IsPermissionKillSwitchOn()) { | 79 if (IsPermissionKillSwitchOn()) { |
| 82 // Log to the developer console. | 80 // Log to the developer console. |
| 83 web_contents->GetMainFrame()->AddMessageToConsole( | 81 web_contents->GetMainFrame()->AddMessageToConsole( |
| 84 content::CONSOLE_MESSAGE_LEVEL_INFO, | 82 content::CONSOLE_MESSAGE_LEVEL_INFO, |
| 85 base::StringPrintf( | 83 base::StringPrintf( |
| 86 "%s permission has been blocked.", | 84 "%s permission has been blocked.", |
| 87 PermissionUtil::GetPermissionString(permission_type_).c_str())); | 85 PermissionUtil::GetPermissionString(content_settings_type_) |
| 86 .c_str())); | |
| 88 // The kill switch is enabled for this permission; Block all requests. | 87 // The kill switch is enabled for this permission; Block all requests. |
| 89 callback.Run(CONTENT_SETTING_BLOCK); | 88 callback.Run(CONTENT_SETTING_BLOCK); |
| 90 return; | 89 return; |
| 91 } | 90 } |
| 92 | 91 |
| 93 GURL requesting_origin = requesting_frame.GetOrigin(); | 92 GURL requesting_origin = requesting_frame.GetOrigin(); |
| 94 GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin(); | 93 GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin(); |
| 95 | 94 |
| 96 if (!requesting_origin.is_valid() || !embedding_origin.is_valid()) { | 95 if (!requesting_origin.is_valid() || !embedding_origin.is_valid()) { |
| 97 std::string type_name = | 96 std::string type_name = |
| 98 content_settings::WebsiteSettingsRegistry::GetInstance() | 97 content_settings::WebsiteSettingsRegistry::GetInstance() |
| 99 ->Get(content_settings_type_) | 98 ->Get(content_settings_type_) |
|
Peter Beverloo
2017/02/10 16:22:51
Since the ContentSettingsRegistry hasn't been upda
Timothy Loh
2017/02/13 04:08:36
Good catch. I changed this to use use PermissionUt
| |
| 100 ->name(); | 99 ->name(); |
| 101 | 100 |
| 102 DVLOG(1) << "Attempt to use " << type_name | 101 DVLOG(1) << "Attempt to use " << type_name |
| 103 << " from an invalid URL: " << requesting_origin << "," | 102 << " from an invalid URL: " << requesting_origin << "," |
| 104 << embedding_origin << " (" << type_name | 103 << embedding_origin << " (" << type_name |
| 105 << " is not supported in popups)"; | 104 << " is not supported in popups)"; |
| 106 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, | 105 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, |
| 107 false /* persist */, CONTENT_SETTING_BLOCK); | 106 false /* persist */, CONTENT_SETTING_BLOCK); |
| 108 return; | 107 return; |
| 109 } | 108 } |
| 110 | 109 |
| 111 // Synchronously check the content setting to see if the user has already made | 110 // Synchronously check the content setting to see if the user has already made |
| 112 // a decision, or if the origin is under embargo. If so, respect that | 111 // a decision, or if the origin is under embargo. If so, respect that |
| 113 // decision. | 112 // decision. |
| 114 ContentSetting content_setting = | 113 ContentSetting content_setting = |
| 115 GetPermissionStatus(requesting_origin, embedding_origin); | 114 GetPermissionStatus(requesting_origin, embedding_origin); |
| 116 if (content_setting == CONTENT_SETTING_ALLOW) { | 115 if (content_setting == CONTENT_SETTING_ALLOW) { |
| 117 HostContentSettingsMapFactory::GetForProfile(profile_)->UpdateLastUsage( | 116 HostContentSettingsMapFactory::GetForProfile(profile_)->UpdateLastUsage( |
| 118 requesting_origin, embedding_origin, content_settings_type_); | 117 requesting_origin, embedding_origin, content_settings_storage_type()); |
| 119 } | 118 } |
| 120 | 119 |
| 121 if (content_setting == CONTENT_SETTING_ALLOW || | 120 if (content_setting == CONTENT_SETTING_ALLOW || |
| 122 content_setting == CONTENT_SETTING_BLOCK) { | 121 content_setting == CONTENT_SETTING_BLOCK) { |
| 123 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, | 122 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, |
| 124 false /* persist */, content_setting); | 123 false /* persist */, content_setting); |
| 125 return; | 124 return; |
| 126 } | 125 } |
| 127 | 126 |
| 128 // Asynchronously check whether the origin should be blocked from making this | 127 // Asynchronously check whether the origin should be blocked from making this |
| 129 // permission request. It may be on the Safe Browsing API blacklist, or it may | 128 // permission request. It may be on the Safe Browsing API blacklist, or it may |
| 130 // have been dismissed too many times in a row. If the origin is allowed to | 129 // have been dismissed too many times in a row. If the origin is allowed to |
| 131 // request, that request will be made to ContinueRequestPermission(). | 130 // request, that request will be made to ContinueRequestPermission(). |
| 132 PermissionDecisionAutoBlocker::GetForProfile(profile_)->UpdateEmbargoedStatus( | 131 PermissionDecisionAutoBlocker::GetForProfile(profile_)->UpdateEmbargoedStatus( |
| 133 permission_type_, requesting_origin, web_contents, | 132 content_settings_type_, requesting_origin, web_contents, |
|
Peter Beverloo
2017/02/10 16:22:51
Should the auto blocker use the storage type too?
Timothy Loh
2017/02/13 04:08:36
I think this issue already exists, since it curren
| |
| 134 base::Bind(&PermissionContextBase::ContinueRequestPermission, | 133 base::Bind(&PermissionContextBase::ContinueRequestPermission, |
| 135 weak_factory_.GetWeakPtr(), web_contents, id, | 134 weak_factory_.GetWeakPtr(), web_contents, id, |
| 136 requesting_origin, embedding_origin, user_gesture, callback)); | 135 requesting_origin, embedding_origin, user_gesture, callback)); |
| 137 } | 136 } |
| 138 | 137 |
| 139 void PermissionContextBase::ContinueRequestPermission( | 138 void PermissionContextBase::ContinueRequestPermission( |
| 140 content::WebContents* web_contents, | 139 content::WebContents* web_contents, |
| 141 const PermissionRequestID& id, | 140 const PermissionRequestID& id, |
| 142 const GURL& requesting_origin, | 141 const GURL& requesting_origin, |
| 143 const GURL& embedding_origin, | 142 const GURL& embedding_origin, |
| 144 bool user_gesture, | 143 bool user_gesture, |
| 145 const BrowserPermissionCallback& callback, | 144 const BrowserPermissionCallback& callback, |
| 146 bool permission_blocked) { | 145 bool permission_blocked) { |
| 147 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 146 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 148 if (permission_blocked) { | 147 if (permission_blocked) { |
| 149 // TODO(meredithl): Add UMA metrics here. | 148 // TODO(meredithl): Add UMA metrics here. |
| 150 web_contents->GetMainFrame()->AddMessageToConsole( | 149 web_contents->GetMainFrame()->AddMessageToConsole( |
| 151 content::CONSOLE_MESSAGE_LEVEL_INFO, | 150 content::CONSOLE_MESSAGE_LEVEL_INFO, |
| 152 base::StringPrintf( | 151 base::StringPrintf( |
| 153 "%s permission has been auto-blocked.", | 152 "%s permission has been auto-blocked.", |
| 154 PermissionUtil::GetPermissionString(permission_type_).c_str())); | 153 PermissionUtil::GetPermissionString(content_settings_type_) |
| 154 .c_str())); | |
| 155 // Permission has been automatically blocked. | 155 // Permission has been automatically blocked. |
| 156 callback.Run(CONTENT_SETTING_BLOCK); | 156 callback.Run(CONTENT_SETTING_BLOCK); |
| 157 return; | 157 return; |
| 158 } | 158 } |
| 159 | 159 |
| 160 PermissionUmaUtil::PermissionRequested(permission_type_, requesting_origin, | 160 PermissionUmaUtil::PermissionRequested( |
| 161 embedding_origin, profile_); | 161 content_settings_type_, requesting_origin, embedding_origin, profile_); |
| 162 | 162 |
| 163 DecidePermission(web_contents, id, requesting_origin, embedding_origin, | 163 DecidePermission(web_contents, id, requesting_origin, embedding_origin, |
| 164 user_gesture, callback); | 164 user_gesture, callback); |
| 165 } | 165 } |
| 166 | 166 |
| 167 ContentSetting PermissionContextBase::GetPermissionStatus( | 167 ContentSetting PermissionContextBase::GetPermissionStatus( |
| 168 const GURL& requesting_origin, | 168 const GURL& requesting_origin, |
| 169 const GURL& embedding_origin) const { | 169 const GURL& embedding_origin) const { |
| 170 // If the permission has been disabled through Finch, block all requests. | 170 // If the permission has been disabled through Finch, block all requests. |
| 171 if (IsPermissionKillSwitchOn()) | 171 if (IsPermissionKillSwitchOn()) |
| 172 return CONTENT_SETTING_BLOCK; | 172 return CONTENT_SETTING_BLOCK; |
| 173 | 173 |
| 174 if (IsRestrictedToSecureOrigins() && | 174 if (IsRestrictedToSecureOrigins() && |
| 175 !content::IsOriginSecure(requesting_origin)) { | 175 !content::IsOriginSecure(requesting_origin)) { |
| 176 return CONTENT_SETTING_BLOCK; | 176 return CONTENT_SETTING_BLOCK; |
| 177 } | 177 } |
| 178 | 178 |
| 179 ContentSetting content_setting = | 179 ContentSetting content_setting = |
| 180 GetPermissionStatusInternal(requesting_origin, embedding_origin); | 180 GetPermissionStatusInternal(requesting_origin, embedding_origin); |
| 181 if (content_setting == CONTENT_SETTING_ASK && | 181 if (content_setting == CONTENT_SETTING_ASK && |
| 182 PermissionDecisionAutoBlocker::GetForProfile(profile_)->IsUnderEmbargo( | 182 PermissionDecisionAutoBlocker::GetForProfile(profile_)->IsUnderEmbargo( |
| 183 permission_type_, requesting_origin)) { | 183 content_settings_type_, requesting_origin)) { |
| 184 return CONTENT_SETTING_BLOCK; | 184 return CONTENT_SETTING_BLOCK; |
| 185 } | 185 } |
| 186 return content_setting; | 186 return content_setting; |
| 187 } | 187 } |
| 188 | 188 |
| 189 void PermissionContextBase::ResetPermission( | 189 void PermissionContextBase::ResetPermission( |
| 190 const GURL& requesting_origin, | 190 const GURL& requesting_origin, |
| 191 const GURL& embedding_origin) { | 191 const GURL& embedding_origin) { |
| 192 HostContentSettingsMapFactory::GetForProfile(profile_) | 192 HostContentSettingsMapFactory::GetForProfile(profile_) |
| 193 ->SetContentSettingDefaultScope(requesting_origin, embedding_origin, | 193 ->SetContentSettingDefaultScope(requesting_origin, embedding_origin, |
| 194 content_settings_type_, std::string(), | 194 content_settings_storage_type(), |
| 195 CONTENT_SETTING_DEFAULT); | 195 std::string(), CONTENT_SETTING_DEFAULT); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void PermissionContextBase::CancelPermissionRequest( | 198 void PermissionContextBase::CancelPermissionRequest( |
| 199 content::WebContents* web_contents, | 199 content::WebContents* web_contents, |
| 200 const PermissionRequestID& id) { | 200 const PermissionRequestID& id) { |
| 201 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 201 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 202 | 202 |
| 203 if (PermissionRequestManager::IsEnabled()) { | 203 if (PermissionRequestManager::IsEnabled()) { |
| 204 auto it = pending_requests_.find(id.ToString()); | 204 auto it = pending_requests_.find(id.ToString()); |
| 205 if (it != pending_requests_.end() && web_contents != nullptr && | 205 if (it != pending_requests_.end() && web_contents != nullptr && |
| 206 PermissionRequestManager::FromWebContents(web_contents) != nullptr) { | 206 PermissionRequestManager::FromWebContents(web_contents) != nullptr) { |
| 207 PermissionRequestManager::FromWebContents(web_contents) | 207 PermissionRequestManager::FromWebContents(web_contents) |
| 208 ->CancelRequest(it->second.get()); | 208 ->CancelRequest(it->second.get()); |
| 209 } | 209 } |
| 210 } else { | 210 } else { |
| 211 #if defined(OS_ANDROID) | 211 #if defined(OS_ANDROID) |
| 212 GetQueueController()->CancelInfoBarRequest(id); | 212 GetQueueController()->CancelInfoBarRequest(id); |
| 213 #else | 213 #else |
| 214 NOTREACHED(); | 214 NOTREACHED(); |
| 215 #endif | 215 #endif |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 | 218 |
| 219 bool PermissionContextBase::IsPermissionKillSwitchOn() const { | 219 bool PermissionContextBase::IsPermissionKillSwitchOn() const { |
| 220 const std::string param = variations::GetVariationParamValue( | 220 const std::string param = variations::GetVariationParamValue( |
| 221 kPermissionsKillSwitchFieldStudy, | 221 kPermissionsKillSwitchFieldStudy, |
| 222 PermissionUtil::GetPermissionString(permission_type_)); | 222 PermissionUtil::GetPermissionString(content_settings_type_)); |
| 223 | 223 |
| 224 return param == kPermissionsKillSwitchBlockedValue; | 224 return param == kPermissionsKillSwitchBlockedValue; |
| 225 } | 225 } |
| 226 | 226 |
| 227 ContentSetting PermissionContextBase::GetPermissionStatusInternal( | 227 ContentSetting PermissionContextBase::GetPermissionStatusInternal( |
| 228 const GURL& requesting_origin, | 228 const GURL& requesting_origin, |
| 229 const GURL& embedding_origin) const { | 229 const GURL& embedding_origin) const { |
| 230 return HostContentSettingsMapFactory::GetForProfile(profile_) | 230 return HostContentSettingsMapFactory::GetForProfile(profile_) |
| 231 ->GetContentSetting(requesting_origin, embedding_origin, | 231 ->GetContentSetting(requesting_origin, embedding_origin, |
| 232 content_settings_type_, std::string()); | 232 content_settings_storage_type(), std::string()); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void PermissionContextBase::DecidePermission( | 235 void PermissionContextBase::DecidePermission( |
| 236 content::WebContents* web_contents, | 236 content::WebContents* web_contents, |
| 237 const PermissionRequestID& id, | 237 const PermissionRequestID& id, |
| 238 const GURL& requesting_origin, | 238 const GURL& requesting_origin, |
| 239 const GURL& embedding_origin, | 239 const GURL& embedding_origin, |
| 240 bool user_gesture, | 240 bool user_gesture, |
| 241 const BrowserPermissionCallback& callback) { | 241 const BrowserPermissionCallback& callback) { |
| 242 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 242 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 243 | 243 |
| 244 if (PermissionRequestManager::IsEnabled()) { | 244 if (PermissionRequestManager::IsEnabled()) { |
| 245 PermissionRequestManager* permission_request_manager = | 245 PermissionRequestManager* permission_request_manager = |
| 246 PermissionRequestManager::FromWebContents(web_contents); | 246 PermissionRequestManager::FromWebContents(web_contents); |
| 247 // TODO(felt): sometimes |permission_request_manager| is null. This check is | 247 // TODO(felt): sometimes |permission_request_manager| is null. This check is |
| 248 // meant to prevent crashes. See crbug.com/457091. | 248 // meant to prevent crashes. See crbug.com/457091. |
| 249 if (!permission_request_manager) | 249 if (!permission_request_manager) |
| 250 return; | 250 return; |
| 251 | 251 |
| 252 std::unique_ptr<PermissionRequest> request_ptr = | 252 std::unique_ptr<PermissionRequest> request_ptr = |
| 253 base::MakeUnique<PermissionRequestImpl>( | 253 base::MakeUnique<PermissionRequestImpl>( |
| 254 requesting_origin, permission_type_, profile_, user_gesture, | 254 requesting_origin, content_settings_type_, profile_, user_gesture, |
| 255 base::Bind(&PermissionContextBase::PermissionDecided, | 255 base::Bind(&PermissionContextBase::PermissionDecided, |
| 256 weak_factory_.GetWeakPtr(), id, requesting_origin, | 256 weak_factory_.GetWeakPtr(), id, requesting_origin, |
| 257 embedding_origin, user_gesture, callback), | 257 embedding_origin, user_gesture, callback), |
| 258 base::Bind(&PermissionContextBase::CleanUpRequest, | 258 base::Bind(&PermissionContextBase::CleanUpRequest, |
| 259 weak_factory_.GetWeakPtr(), id)); | 259 weak_factory_.GetWeakPtr(), id)); |
| 260 PermissionRequest* request = request_ptr.get(); | 260 PermissionRequest* request = request_ptr.get(); |
| 261 | 261 |
| 262 bool inserted = | 262 bool inserted = |
| 263 pending_requests_ | 263 pending_requests_ |
| 264 .insert(std::make_pair(id.ToString(), std::move(request_ptr))) | 264 .insert(std::make_pair(id.ToString(), std::move(request_ptr))) |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 292 if (PermissionRequestManager::IsEnabled()) { | 292 if (PermissionRequestManager::IsEnabled()) { |
| 293 // Infobar persistence and its related UMA is tracked on the infobar | 293 // Infobar persistence and its related UMA is tracked on the infobar |
| 294 // controller directly. | 294 // controller directly. |
| 295 PermissionRequestGestureType gesture_type = | 295 PermissionRequestGestureType gesture_type = |
| 296 user_gesture ? PermissionRequestGestureType::GESTURE | 296 user_gesture ? PermissionRequestGestureType::GESTURE |
| 297 : PermissionRequestGestureType::NO_GESTURE; | 297 : PermissionRequestGestureType::NO_GESTURE; |
| 298 DCHECK(content_setting == CONTENT_SETTING_ALLOW || | 298 DCHECK(content_setting == CONTENT_SETTING_ALLOW || |
| 299 content_setting == CONTENT_SETTING_BLOCK || | 299 content_setting == CONTENT_SETTING_BLOCK || |
| 300 content_setting == CONTENT_SETTING_DEFAULT); | 300 content_setting == CONTENT_SETTING_DEFAULT); |
| 301 if (content_setting == CONTENT_SETTING_ALLOW) { | 301 if (content_setting == CONTENT_SETTING_ALLOW) { |
| 302 PermissionUmaUtil::PermissionGranted(permission_type_, gesture_type, | 302 PermissionUmaUtil::PermissionGranted(content_settings_type_, gesture_type, |
| 303 requesting_origin, profile_); | 303 requesting_origin, profile_); |
| 304 } else if (content_setting == CONTENT_SETTING_BLOCK) { | 304 } else if (content_setting == CONTENT_SETTING_BLOCK) { |
| 305 PermissionUmaUtil::PermissionDenied(permission_type_, gesture_type, | 305 PermissionUmaUtil::PermissionDenied(content_settings_type_, gesture_type, |
| 306 requesting_origin, profile_); | 306 requesting_origin, profile_); |
| 307 } else { | 307 } else { |
| 308 PermissionUmaUtil::PermissionDismissed(permission_type_, gesture_type, | 308 PermissionUmaUtil::PermissionDismissed( |
| 309 requesting_origin, profile_); | 309 content_settings_type_, gesture_type, requesting_origin, profile_); |
| 310 } | 310 } |
| 311 } | 311 } |
| 312 | 312 |
| 313 if (content_setting == CONTENT_SETTING_DEFAULT && | 313 if (content_setting == CONTENT_SETTING_DEFAULT && |
| 314 PermissionDecisionAutoBlocker::GetForProfile(profile_) | 314 PermissionDecisionAutoBlocker::GetForProfile(profile_) |
| 315 ->RecordDismissAndEmbargo(requesting_origin, permission_type_)) { | 315 ->RecordDismissAndEmbargo(requesting_origin, |
| 316 content_settings_type_)) { | |
| 316 // The permission has been embargoed, so it is blocked for this permission | 317 // The permission has been embargoed, so it is blocked for this permission |
| 317 // request, but not persisted. | 318 // request, but not persisted. |
| 318 content_setting = CONTENT_SETTING_BLOCK; | 319 content_setting = CONTENT_SETTING_BLOCK; |
| 319 } | 320 } |
| 320 | 321 |
| 321 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, | 322 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, |
| 322 persist, content_setting); | 323 persist, content_setting); |
| 323 } | 324 } |
| 324 | 325 |
| 325 #if defined(OS_ANDROID) | 326 #if defined(OS_ANDROID) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 ContentSetting content_setting) { | 365 ContentSetting content_setting) { |
| 365 DCHECK_EQ(requesting_origin, requesting_origin.GetOrigin()); | 366 DCHECK_EQ(requesting_origin, requesting_origin.GetOrigin()); |
| 366 DCHECK_EQ(embedding_origin, embedding_origin.GetOrigin()); | 367 DCHECK_EQ(embedding_origin, embedding_origin.GetOrigin()); |
| 367 DCHECK(content_setting == CONTENT_SETTING_ALLOW || | 368 DCHECK(content_setting == CONTENT_SETTING_ALLOW || |
| 368 content_setting == CONTENT_SETTING_BLOCK); | 369 content_setting == CONTENT_SETTING_BLOCK); |
| 369 DCHECK(!requesting_origin.SchemeIsFile()); | 370 DCHECK(!requesting_origin.SchemeIsFile()); |
| 370 DCHECK(!embedding_origin.SchemeIsFile()); | 371 DCHECK(!embedding_origin.SchemeIsFile()); |
| 371 | 372 |
| 372 HostContentSettingsMapFactory::GetForProfile(profile_) | 373 HostContentSettingsMapFactory::GetForProfile(profile_) |
| 373 ->SetContentSettingDefaultScope(requesting_origin, embedding_origin, | 374 ->SetContentSettingDefaultScope(requesting_origin, embedding_origin, |
| 374 content_settings_type_, std::string(), | 375 content_settings_storage_type(), |
| 375 content_setting); | 376 std::string(), content_setting); |
| 376 } | 377 } |
| 378 | |
| 379 ContentSettingsType PermissionContextBase::content_settings_storage_type() | |
| 380 const { | |
| 381 if (content_settings_type_ == CONTENT_SETTINGS_TYPE_PUSH_MESSAGING) | |
| 382 return CONTENT_SETTINGS_TYPE_NOTIFICATIONS; | |
| 383 return content_settings_type_; | |
| 384 } | |
| OLD | NEW |