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

Side by Side Diff: chrome/browser/media/protected_media_identifier_permission_context.cc

Issue 1153873003: Add way for PermissionContext to be automatically restricted to secure origins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@midi_permission_sysex
Patch Set: review comments Created 5 years, 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/media/protected_media_identifier_permission_context.h" 5 #include "chrome/browser/media/protected_media_identifier_permission_context.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 return; 82 return;
83 } 83 }
84 84
85 // On ChromeOS, we don't use PermissionContextBase::RequestPermission() which 85 // On ChromeOS, we don't use PermissionContextBase::RequestPermission() which
86 // uses the standard permission infobar/bubble UI. See http://crbug.com/454847 86 // uses the standard permission infobar/bubble UI. See http://crbug.com/454847
87 // Instead, we show the existing platform verification UI. 87 // Instead, we show the existing platform verification UI.
88 // TODO(xhwang): Remove when http://crbug.com/454847 is fixed. 88 // TODO(xhwang): Remove when http://crbug.com/454847 is fixed.
89 views::Widget* widget = PlatformVerificationDialog::ShowDialog( 89 views::Widget* widget = PlatformVerificationDialog::ShowDialog(
90 web_contents, requesting_origin, 90 web_contents, requesting_origin,
91 base::Bind(&ProtectedMediaIdentifierPermissionContext:: 91 base::Bind(&ProtectedMediaIdentifierPermissionContext::
92 OnPlatformVerificationConsentResponse, 92 OnPlatformVerificationConsentponse,
Peter Beverloo 2015/05/29 14:45:58 Unintentional change?
93 weak_factory_.GetWeakPtr(), web_contents, id, 93 weak_factory_.GetWeakPtr(), web_contents, id,
94 requesting_origin, embedding_origin, callback)); 94 requesting_origin, embedding_origin, callback));
95 pending_requests_.insert( 95 pending_requests_.insert(
96 std::make_pair(web_contents, std::make_pair(widget, id))); 96 std::make_pair(web_contents, std::make_pair(widget, id)));
97 #else 97 #else
98 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch( 98 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(
99 switches::kDisableInfobarForProtectedMediaIdentifier)); 99 switches::kDisableInfobarForProtectedMediaIdentifier));
100 PermissionContextBase::RequestPermission(web_contents, id, requesting_origin, 100 PermissionContextBase::RequestPermission(web_contents, id, requesting_origin,
101 user_gesture, callback); 101 user_gesture, callback);
102 #endif 102 #endif
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // WebContents may have gone away. 166 // WebContents may have gone away.
167 TabSpecificContentSettings* content_settings = 167 TabSpecificContentSettings* content_settings =
168 TabSpecificContentSettings::Get(id.render_process_id(), 168 TabSpecificContentSettings::Get(id.render_process_id(),
169 id.render_view_id()); 169 id.render_view_id());
170 if (content_settings) { 170 if (content_settings) {
171 content_settings->OnProtectedMediaIdentifierPermissionSet( 171 content_settings->OnProtectedMediaIdentifierPermissionSet(
172 requesting_frame.GetOrigin(), allowed); 172 requesting_frame.GetOrigin(), allowed);
173 } 173 }
174 } 174 }
175 175
176 bool
177 ProtectedMediaIdentifierPermissionContext::IsRestrictedToSecureOrigins() const {
178 return false;
179 }
180
176 // TODO(xhwang): We should consolidate the "protected content" related pref 181 // TODO(xhwang): We should consolidate the "protected content" related pref
177 // across platforms. 182 // across platforms.
178 bool ProtectedMediaIdentifierPermissionContext:: 183 bool ProtectedMediaIdentifierPermissionContext::
179 IsProtectedMediaIdentifierEnabled() const { 184 IsProtectedMediaIdentifierEnabled() const {
180 #if defined(OS_CHROMEOS) 185 #if defined(OS_CHROMEOS)
181 // Platform verification is not allowed in incognito or guest mode. 186 // Platform verification is not allowed in incognito or guest mode.
182 if (profile()->IsOffTheRecord() || profile()->IsGuestSession()) { 187 if (profile()->IsOffTheRecord() || profile()->IsGuestSession()) {
183 DVLOG(1) << "Protected media identifier disabled in incognito or guest " 188 DVLOG(1) << "Protected media identifier disabled in incognito or guest "
184 "mode."; 189 "mode.";
185 return false; 190 return false;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 content_setting = CONTENT_SETTING_BLOCK; 251 content_setting = CONTENT_SETTING_BLOCK;
247 persist = true; 252 persist = true;
248 break; 253 break;
249 } 254 }
250 255
251 NotifyPermissionSet( 256 NotifyPermissionSet(
252 id, requesting_origin, embedding_origin, callback, 257 id, requesting_origin, embedding_origin, callback,
253 persist, content_setting); 258 persist, content_setting);
254 } 259 }
255 #endif 260 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698