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/content_settings/permission_context_base.h" | 5 #include "chrome/browser/content_settings/permission_context_base.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "chrome/browser/content_settings/permission_bubble_request_impl.h" | 9 #include "chrome/browser/content_settings/permission_bubble_request_impl.h" |
| 10 #include "chrome/browser/content_settings/permission_context_uma_util.h" | 10 #include "chrome/browser/content_settings/permission_context_uma_util.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 << "Attempt to use " << content_settings::GetTypeName(permission_type_) | 103 << "Attempt to use " << content_settings::GetTypeName(permission_type_) |
| 104 << " from an invalid URL: " << requesting_origin | 104 << " from an invalid URL: " << requesting_origin |
| 105 << "," << embedding_origin | 105 << "," << embedding_origin |
| 106 << " (" << content_settings::GetTypeName(permission_type_) | 106 << " (" << content_settings::GetTypeName(permission_type_) |
| 107 << " is not supported in popups)"; | 107 << " is not supported in popups)"; |
| 108 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, | 108 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, |
| 109 false /* persist */, CONTENT_SETTING_BLOCK); | 109 false /* persist */, CONTENT_SETTING_BLOCK); |
| 110 return; | 110 return; |
| 111 } | 111 } |
| 112 | 112 |
| 113 // Some permissions may not be used over unsecured http. | |
|
mlamouri (slow - plz ping)
2015/06/22 22:10:57
I would prefer to avoid this comment because the g
jww
2015/06/23 05:32:58
Additionally, "what is a secure origin" is defined
keenanb
2015/06/24 22:26:10
Done.
| |
| 113 if (IsRestrictedToSecureOrigins() && | 114 if (IsRestrictedToSecureOrigins() && |
| 114 !content::IsOriginSecure(requesting_origin)) { | 115 !content::IsOriginSecure(requesting_origin)) { |
| 115 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, | 116 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, |
| 116 false /* persist */, CONTENT_SETTING_BLOCK); | 117 false /* persist */, CONTENT_SETTING_BLOCK); |
| 117 return; | 118 return; |
| 118 } | 119 } |
| 119 | 120 |
| 120 ContentSetting content_setting = | 121 ContentSetting content_setting = |
| 121 profile_->GetHostContentSettingsMap() | 122 profile_->GetHostContentSettingsMap() |
| 122 ->GetContentSettingAndMaybeUpdateLastUsage( | 123 ->GetContentSettingAndMaybeUpdateLastUsage( |
| 123 requesting_origin, embedding_origin, permission_type_, | 124 requesting_origin, embedding_origin, permission_type_, |
| 124 std::string()); | 125 std::string()); |
| 125 | 126 |
| 126 if (content_setting == CONTENT_SETTING_ALLOW || | 127 if (content_setting == CONTENT_SETTING_ALLOW || |
| 127 content_setting == CONTENT_SETTING_BLOCK) { | 128 content_setting == CONTENT_SETTING_BLOCK) { |
| 128 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, | 129 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, |
| 129 false /* persist */, content_setting); | 130 false /* persist */, content_setting); |
| 130 return; | 131 return; |
| 131 } | 132 } |
| 132 | 133 |
| 133 PermissionContextUmaUtil::PermissionRequested( | 134 PermissionContextUmaUtil::PermissionRequested( |
| 134 permission_type_, requesting_origin); | 135 permission_type_, profile_->GetHostContentSettingsMap(), |
| 136 requesting_origin, embedding_origin); | |
| 135 | 137 |
| 136 if (PermissionBubbleManager::Enabled()) { | 138 if (PermissionBubbleManager::Enabled()) { |
| 137 if (pending_bubbles_.get(id.ToString()) != NULL) | 139 if (pending_bubbles_.get(id.ToString()) != NULL) |
| 138 return; | 140 return; |
| 139 PermissionBubbleManager* bubble_manager = | 141 PermissionBubbleManager* bubble_manager = |
| 140 PermissionBubbleManager::FromWebContents(web_contents); | 142 PermissionBubbleManager::FromWebContents(web_contents); |
| 141 // TODO(mlamouri): sometimes |bubble_manager| is null. This check is meant | 143 // TODO(mlamouri): sometimes |bubble_manager| is null. This check is meant |
| 142 // to prevent crashes. See bug 457091. | 144 // to prevent crashes. See bug 457091. |
| 143 if (!bubble_manager) | 145 if (!bubble_manager) |
| 144 return; | 146 return; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 DCHECK_EQ(requesting_origin, requesting_origin.GetOrigin()); | 249 DCHECK_EQ(requesting_origin, requesting_origin.GetOrigin()); |
| 248 DCHECK_EQ(embedding_origin, embedding_origin.GetOrigin()); | 250 DCHECK_EQ(embedding_origin, embedding_origin.GetOrigin()); |
| 249 DCHECK(content_setting == CONTENT_SETTING_ALLOW || | 251 DCHECK(content_setting == CONTENT_SETTING_ALLOW || |
| 250 content_setting == CONTENT_SETTING_BLOCK); | 252 content_setting == CONTENT_SETTING_BLOCK); |
| 251 | 253 |
| 252 profile_->GetHostContentSettingsMap()->SetContentSetting( | 254 profile_->GetHostContentSettingsMap()->SetContentSetting( |
| 253 ContentSettingsPattern::FromURLNoWildcard(requesting_origin), | 255 ContentSettingsPattern::FromURLNoWildcard(requesting_origin), |
| 254 ContentSettingsPattern::FromURLNoWildcard(embedding_origin), | 256 ContentSettingsPattern::FromURLNoWildcard(embedding_origin), |
| 255 permission_type_, std::string(), content_setting); | 257 permission_type_, std::string(), content_setting); |
| 256 } | 258 } |
| OLD | NEW |