Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: chrome/browser/content_settings/permission_context_base.cc

Issue 864753007: media: Use PlatformVerificationDialog in PermissionContextBase on ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/content_settings/permission_context_base.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 125 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
120 false /* persist */, true /* granted */); 126 false /* persist */, true /* granted */);
121 return; 127 return;
122 default: 128 default:
123 break; 129 break;
124 } 130 }
125 131
126 PermissionContextUmaUtil::PermissionRequested( 132 PermissionContextUmaUtil::PermissionRequested(
127 permission_type_, requesting_origin); 133 permission_type_, requesting_origin);
128 134
135 #if defined(OS_CHROMEOS)
136 // TODO(xhwang): This is to use the existing platform verification UI. Remove
137 // it when the infobar/bubble UI can satisfy our requirements.
138 if (permission_type_ == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) {
139 PlatformVerificationDialog::ShowDialog(
140 web_contents,
141 base::Bind(&PermissionContextBase::OnPlatformVerificationResult,
142 weak_factory_.GetWeakPtr(), id, requesting_origin,
143 embedding_origin, callback));
144 return;
145 }
146 #endif
147
129 if (PermissionBubbleManager::Enabled()) { 148 if (PermissionBubbleManager::Enabled()) {
130 if (pending_bubbles_.get(id.ToString()) != NULL) 149 if (pending_bubbles_.get(id.ToString()) != NULL)
131 return; 150 return;
132 PermissionBubbleManager* bubble_manager = 151 PermissionBubbleManager* bubble_manager =
133 PermissionBubbleManager::FromWebContents(web_contents); 152 PermissionBubbleManager::FromWebContents(web_contents);
134 DCHECK(bubble_manager); 153 DCHECK(bubble_manager);
135 scoped_ptr<PermissionBubbleRequest> request_ptr( 154 scoped_ptr<PermissionBubbleRequest> request_ptr(
136 new PermissionBubbleRequestImpl( 155 new PermissionBubbleRequestImpl(
137 requesting_origin, user_gesture, permission_type_, 156 requesting_origin, user_gesture, permission_type_,
138 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), 157 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages),
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 bool allowed) { 241 bool allowed) {
223 DCHECK_EQ(requesting_origin, requesting_origin.GetOrigin()); 242 DCHECK_EQ(requesting_origin, requesting_origin.GetOrigin());
224 DCHECK_EQ(embedding_origin, embedding_origin.GetOrigin()); 243 DCHECK_EQ(embedding_origin, embedding_origin.GetOrigin());
225 ContentSetting content_setting = 244 ContentSetting content_setting =
226 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; 245 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
227 profile_->GetHostContentSettingsMap()->SetContentSetting( 246 profile_->GetHostContentSettingsMap()->SetContentSetting(
228 ContentSettingsPattern::FromURLNoWildcard(requesting_origin), 247 ContentSettingsPattern::FromURLNoWildcard(requesting_origin),
229 ContentSettingsPattern::FromURLNoWildcard(embedding_origin), 248 ContentSettingsPattern::FromURLNoWildcard(embedding_origin),
230 permission_type_, std::string(), content_setting); 249 permission_type_, std::string(), content_setting);
231 } 250 }
251
252 #if defined(OS_CHROMEOS)
253 void PermissionContextBase::OnPlatformVerificationResult(
254 const PermissionRequestID& id,
255 const GURL& requesting_origin,
256 const GURL& embedding_origin,
257 const BrowserPermissionCallback& callback,
258 chromeos::attestation::PlatformVerificationFlow::ConsentResponse response) {
259 if (response == PlatformVerificationFlow::CONSENT_RESPONSE_NONE) {
260 // Deny request and do not save to content settings.
261 PermissionDecided(id, requesting_origin, embedding_origin, callback,
262 false, // Do not save to content settings.
263 false); // Do not allow the permission.
264 return;
265 }
266
267 PermissionDecided(
268 id, requesting_origin, embedding_origin, callback,
269 true, // Save to content settings.
270 response == PlatformVerificationFlow::CONSENT_RESPONSE_ALLOW);
271 }
272 #endif
OLDNEW
« no previous file with comments | « chrome/browser/content_settings/permission_context_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698