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

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

Issue 1153543015: media: Remove kDisableInfobarForProtectedMediaIdentifier flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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"
11 #include "chrome/common/pref_names.h" 11 #include "chrome/common/pref_names.h"
12 #include "components/content_settings/core/common/permission_request_id.h" 12 #include "components/content_settings/core/common/permission_request_id.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/user_metrics.h" 14 #include "content/public/browser/user_metrics.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #if defined(OS_CHROMEOS) 16 #if defined(OS_CHROMEOS)
17 #include <utility> 17 #include <utility>
18 18
19 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h" 19 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h"
20 #include "chrome/browser/chromeos/settings/cros_settings.h" 20 #include "chrome/browser/chromeos/settings/cros_settings.h"
21 #include "chromeos/chromeos_switches.h" 21 #include "chromeos/chromeos_switches.h"
22 #include "chromeos/settings/cros_settings_names.h" 22 #include "chromeos/settings/cros_settings_names.h"
23 #include "components/pref_registry/pref_registry_syncable.h" 23 #include "components/pref_registry/pref_registry_syncable.h"
24 #include "components/user_prefs/user_prefs.h" 24 #include "components/user_prefs/user_prefs.h"
25 #include "ui/views/widget/widget.h" 25 #include "ui/views/widget/widget.h"
26 #elif defined(OS_ANDROID) 26 #elif !defined(OS_ANDROID)
27 #include "media/base/media_switches.h"
28 #else
29 #error This file currently only supports Chrome OS and Android. 27 #error This file currently only supports Chrome OS and Android.
30 #endif 28 #endif
31 29
32 #if defined(OS_CHROMEOS) 30 #if defined(OS_CHROMEOS)
33 using chromeos::attestation::PlatformVerificationDialog; 31 using chromeos::attestation::PlatformVerificationDialog;
34 #endif 32 #endif
35 33
36 ProtectedMediaIdentifierPermissionContext:: 34 ProtectedMediaIdentifierPermissionContext::
37 ProtectedMediaIdentifierPermissionContext(Profile* profile) 35 ProtectedMediaIdentifierPermissionContext(Profile* profile)
38 : PermissionContextBase(profile, 36 : PermissionContextBase(profile,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // TODO(xhwang): Remove when http://crbug.com/454847 is fixed. 86 // TODO(xhwang): Remove when http://crbug.com/454847 is fixed.
89 views::Widget* widget = PlatformVerificationDialog::ShowDialog( 87 views::Widget* widget = PlatformVerificationDialog::ShowDialog(
90 web_contents, requesting_origin, 88 web_contents, requesting_origin,
91 base::Bind(&ProtectedMediaIdentifierPermissionContext:: 89 base::Bind(&ProtectedMediaIdentifierPermissionContext::
92 OnPlatformVerificationConsentResponse, 90 OnPlatformVerificationConsentResponse,
93 weak_factory_.GetWeakPtr(), web_contents, id, 91 weak_factory_.GetWeakPtr(), web_contents, id,
94 requesting_origin, embedding_origin, callback)); 92 requesting_origin, embedding_origin, callback));
95 pending_requests_.insert( 93 pending_requests_.insert(
96 std::make_pair(web_contents, std::make_pair(widget, id))); 94 std::make_pair(web_contents, std::make_pair(widget, id)));
97 #else 95 #else
98 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(
99 switches::kDisableInfobarForProtectedMediaIdentifier));
100 PermissionContextBase::RequestPermission(web_contents, id, requesting_origin, 96 PermissionContextBase::RequestPermission(web_contents, id, requesting_origin,
101 user_gesture, callback); 97 user_gesture, callback);
102 #endif 98 #endif
103 } 99 }
104 100
105 ContentSetting ProtectedMediaIdentifierPermissionContext::GetPermissionStatus( 101 ContentSetting ProtectedMediaIdentifierPermissionContext::GetPermissionStatus(
106 const GURL& requesting_origin, 102 const GURL& requesting_origin,
107 const GURL& embedding_origin) const { 103 const GURL& embedding_origin) const {
108 DVLOG(1) << __FUNCTION__ << ": (" << requesting_origin.spec() << ", " 104 DVLOG(1) << __FUNCTION__ << ": (" << requesting_origin.spec() << ", "
109 << embedding_origin.spec() << ")"; 105 << embedding_origin.spec() << ")";
110 106
111 if (!requesting_origin.is_valid() || !embedding_origin.is_valid() || 107 if (!requesting_origin.is_valid() || !embedding_origin.is_valid() ||
112 !IsProtectedMediaIdentifierEnabled()) { 108 !IsProtectedMediaIdentifierEnabled()) {
113 return CONTENT_SETTING_BLOCK; 109 return CONTENT_SETTING_BLOCK;
114 } 110 }
115 111
116 ContentSetting content_setting = PermissionContextBase::GetPermissionStatus( 112 ContentSetting content_setting = PermissionContextBase::GetPermissionStatus(
117 requesting_origin, embedding_origin); 113 requesting_origin, embedding_origin);
118 DCHECK(content_setting == CONTENT_SETTING_ALLOW || 114 DCHECK(content_setting == CONTENT_SETTING_ALLOW ||
119 content_setting == CONTENT_SETTING_BLOCK || 115 content_setting == CONTENT_SETTING_BLOCK ||
120 content_setting == CONTENT_SETTING_ASK); 116 content_setting == CONTENT_SETTING_ASK);
121 117
122 #if defined(OS_ANDROID)
123 // When kDisableInfobarForProtectedMediaIdentifier is enabled, do not "ask"
124 // the user and always "allow".
125 if (content_setting == CONTENT_SETTING_ASK &&
126 base::CommandLine::ForCurrentProcess()->HasSwitch(
127 switches::kDisableInfobarForProtectedMediaIdentifier)) {
128 content_setting = CONTENT_SETTING_ALLOW;
129 }
130 #endif
131
132 return content_setting; 118 return content_setting;
133 } 119 }
134 120
135 void ProtectedMediaIdentifierPermissionContext::CancelPermissionRequest( 121 void ProtectedMediaIdentifierPermissionContext::CancelPermissionRequest(
136 content::WebContents* web_contents, 122 content::WebContents* web_contents,
137 const PermissionRequestID& id) { 123 const PermissionRequestID& id) {
138 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 124 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
139 125
140 #if defined(OS_CHROMEOS) 126 #if defined(OS_CHROMEOS)
141 PendingRequestMap::iterator request = pending_requests_.find(web_contents); 127 PendingRequestMap::iterator request = pending_requests_.find(web_contents);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 content_setting = CONTENT_SETTING_BLOCK; 232 content_setting = CONTENT_SETTING_BLOCK;
247 persist = true; 233 persist = true;
248 break; 234 break;
249 } 235 }
250 236
251 NotifyPermissionSet( 237 NotifyPermissionSet(
252 id, requesting_origin, embedding_origin, callback, 238 id, requesting_origin, embedding_origin, callback,
253 persist, content_setting); 239 persist, content_setting);
254 } 240 }
255 #endif 241 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698