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" |
11 #include "chrome/browser/content_settings/permission_queue_controller.h" | 11 #include "chrome/browser/content_settings/permission_queue_controller.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | 13 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
15 #include "components/content_settings/core/browser/content_settings_utils.h" | 15 #include "components/content_settings/core/browser/content_settings_utils.h" |
16 #include "components/content_settings/core/browser/host_content_settings_map.h" | 16 #include "components/content_settings/core/browser/host_content_settings_map.h" |
17 #include "components/content_settings/core/common/permission_request_id.h" | 17 #include "components/content_settings/core/common/permission_request_id.h" |
18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
20 | 20 |
21 #if defined(OS_CHROMEOS) | |
22 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h" | |
23 using chromeos::attestation::PlatformVerificationDialog; | |
24 using chromeos::attestation::PlatformVerificationFlow; | |
25 #endif | |
26 | |
21 PermissionContextBase::PermissionContextBase( | 27 PermissionContextBase::PermissionContextBase( |
22 Profile* profile, | 28 Profile* profile, |
23 const ContentSettingsType permission_type) | 29 const ContentSettingsType permission_type) |
24 : profile_(profile), | 30 : profile_(profile), |
25 permission_type_(permission_type), | 31 permission_type_(permission_type), |
26 weak_factory_(this) { | 32 weak_factory_(this) { |
27 permission_queue_controller_.reset( | 33 permission_queue_controller_.reset( |
28 new PermissionQueueController(profile_, permission_type_)); | 34 new PermissionQueueController(profile_, permission_type_)); |
29 } | 35 } |
30 | 36 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, | 116 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, |
111 false /* persist */, true /* granted */); | 117 false /* persist */, true /* granted */); |
112 return; | 118 return; |
113 default: | 119 default: |
114 break; | 120 break; |
115 } | 121 } |
116 | 122 |
117 PermissionContextUmaUtil::PermissionRequested( | 123 PermissionContextUmaUtil::PermissionRequested( |
118 permission_type_, requesting_origin); | 124 permission_type_, requesting_origin); |
119 | 125 |
126 #if defined(OS_CHROMEOS) | |
127 // TODO(xhwang): This is to use the existing platform verification UI. Remove | |
128 // it when the infobar/bubble UI can satisfy our requirements. | |
129 if (permission_type_ == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) { | |
130 PlatformVerificationDialog::ShowDialog( | |
131 web_contents, | |
132 base::Bind(&PermissionContextBase::OnPlatformVerificationResult, | |
133 weak_factory_.GetWeakPtr(), | |
134 base::Bind(&PermissionContextBase::PermissionDecided, | |
Bernhard Bauer
2015/02/02 10:59:40
Do you need to pass this in as a callback? If you
xhwang
2015/02/02 21:24:25
Done.
| |
135 weak_factory_.GetWeakPtr(), id, requesting_origin, | |
136 embedding_origin, callback))); | |
137 return; | |
138 } | |
139 #endif | |
140 | |
120 if (PermissionBubbleManager::Enabled()) { | 141 if (PermissionBubbleManager::Enabled()) { |
121 if (pending_bubbles_.get(id.ToString()) != NULL) | 142 if (pending_bubbles_.get(id.ToString()) != NULL) |
122 return; | 143 return; |
123 PermissionBubbleManager* bubble_manager = | 144 PermissionBubbleManager* bubble_manager = |
124 PermissionBubbleManager::FromWebContents(web_contents); | 145 PermissionBubbleManager::FromWebContents(web_contents); |
125 DCHECK(bubble_manager); | 146 DCHECK(bubble_manager); |
126 scoped_ptr<PermissionBubbleRequest> request_ptr( | 147 scoped_ptr<PermissionBubbleRequest> request_ptr( |
127 new PermissionBubbleRequestImpl( | 148 new PermissionBubbleRequestImpl( |
128 requesting_origin, user_gesture, permission_type_, | 149 requesting_origin, user_gesture, permission_type_, |
129 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), | 150 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 bool allowed) { | 234 bool allowed) { |
214 DCHECK_EQ(requesting_origin, requesting_origin.GetOrigin()); | 235 DCHECK_EQ(requesting_origin, requesting_origin.GetOrigin()); |
215 DCHECK_EQ(embedding_origin, embedding_origin.GetOrigin()); | 236 DCHECK_EQ(embedding_origin, embedding_origin.GetOrigin()); |
216 ContentSetting content_setting = | 237 ContentSetting content_setting = |
217 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; | 238 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; |
218 profile_->GetHostContentSettingsMap()->SetContentSetting( | 239 profile_->GetHostContentSettingsMap()->SetContentSetting( |
219 ContentSettingsPattern::FromURLNoWildcard(requesting_origin), | 240 ContentSettingsPattern::FromURLNoWildcard(requesting_origin), |
220 ContentSettingsPattern::FromURLNoWildcard(embedding_origin), | 241 ContentSettingsPattern::FromURLNoWildcard(embedding_origin), |
221 permission_type_, std::string(), content_setting); | 242 permission_type_, std::string(), content_setting); |
222 } | 243 } |
244 | |
245 #if defined(OS_CHROMEOS) | |
246 void PermissionContextBase::OnPlatformVerificationResult( | |
247 const PermissionCallback& permission_callback, | |
248 PlatformVerificationFlow::ConsentResponse response) { | |
249 if (response == PlatformVerificationFlow::CONSENT_RESPONSE_NONE) { | |
250 // Deny request and do not save to content settings. | |
251 permission_callback.Run(false, false); | |
252 return; | |
253 } | |
254 | |
255 permission_callback.Run( | |
256 true, // Save to content settings. | |
257 response == PlatformVerificationFlow::CONSENT_RESPONSE_ALLOW); | |
258 } | |
259 #endif | |
OLD | NEW |