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

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

Issue 1726323002: Have Permission{Manager,Service} use Origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clarify and test Origin.empty_. Created 4 years, 9 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/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 ProtectedMediaIdentifierPermissionContext:: 50 ProtectedMediaIdentifierPermissionContext::
51 ~ProtectedMediaIdentifierPermissionContext() { 51 ~ProtectedMediaIdentifierPermissionContext() {
52 } 52 }
53 53
54 #if defined(OS_CHROMEOS) 54 #if defined(OS_CHROMEOS)
55 void ProtectedMediaIdentifierPermissionContext::RequestPermission( 55 void ProtectedMediaIdentifierPermissionContext::RequestPermission(
56 content::WebContents* web_contents, 56 content::WebContents* web_contents,
57 const PermissionRequestID& id, 57 const PermissionRequestID& id,
58 const GURL& requesting_origin, 58 const url::Origin& requesting_origin,
59 const BrowserPermissionCallback& callback) { 59 const BrowserPermissionCallback& callback) {
60 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 60 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
61 61
62 // First check if this permission has been disabled. This check occurs before 62 // First check if this permission has been disabled. This check occurs before
63 // the call to GetPermissionStatus, which will return CONTENT_SETTING_BLOCK 63 // the call to GetPermissionStatus, which will return CONTENT_SETTING_BLOCK
64 // if the kill switch is on. 64 // if the kill switch is on.
65 // 65 //
66 // TODO(xhwang): Remove this kill switch block when crbug.com/454847 is fixed 66 // TODO(xhwang): Remove this kill switch block when crbug.com/454847 is fixed
67 // and we no longer call GetPermissionStatus before 67 // and we no longer call GetPermissionStatus before
68 // PermissionContextBase::RequestPermission. 68 // PermissionContextBase::RequestPermission.
69 if (IsPermissionKillSwitchOn()) { 69 if (IsPermissionKillSwitchOn()) {
70 // Log to the developer console. 70 // Log to the developer console.
71 web_contents->GetMainFrame()->AddMessageToConsole( 71 web_contents->GetMainFrame()->AddMessageToConsole(
72 content::CONSOLE_MESSAGE_LEVEL_LOG, 72 content::CONSOLE_MESSAGE_LEVEL_LOG,
73 base::StringPrintf( 73 base::StringPrintf(
74 "%s permission has been blocked.", 74 "%s permission has been blocked.",
75 PermissionUtil::GetPermissionString( 75 PermissionUtil::GetPermissionString(
76 content::PermissionType::PROTECTED_MEDIA_IDENTIFIER) 76 content::PermissionType::PROTECTED_MEDIA_IDENTIFIER)
77 .c_str())); 77 .c_str()));
78 // The kill switch is enabled for this permission; Block all requests and 78 // The kill switch is enabled for this permission; Block all requests and
79 // run the callback immediately. 79 // run the callback immediately.
80 callback.Run(CONTENT_SETTING_BLOCK); 80 callback.Run(CONTENT_SETTING_BLOCK);
81 return; 81 return;
82 } 82 }
83 83
84 GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin(); 84 const url::Origin embedding_origin(web_contents->GetLastCommittedURL());
85 85
86 DVLOG(1) << __FUNCTION__ << ": (" << requesting_origin.spec() << ", " 86 DVLOG(1) << __FUNCTION__ << ": (" << requesting_origin << ", "
87 << embedding_origin.spec() << ")"; 87 << embedding_origin << ")";
88 88
89 ContentSetting content_setting = 89 ContentSetting content_setting =
90 GetPermissionStatus(requesting_origin, embedding_origin); 90 GetPermissionStatus(requesting_origin, embedding_origin);
91 91
92 if (content_setting == CONTENT_SETTING_ALLOW || 92 if (content_setting == CONTENT_SETTING_ALLOW ||
93 content_setting == CONTENT_SETTING_BLOCK) { 93 content_setting == CONTENT_SETTING_BLOCK) {
94 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 94 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
95 false /* persist */, content_setting); 95 false /* persist */, content_setting);
96 return; 96 return;
97 } 97 }
(...skipping 17 matching lines...) Expand all
115 base::Bind(&ProtectedMediaIdentifierPermissionContext:: 115 base::Bind(&ProtectedMediaIdentifierPermissionContext::
116 OnPlatformVerificationConsentResponse, 116 OnPlatformVerificationConsentResponse,
117 weak_factory_.GetWeakPtr(), web_contents, id, 117 weak_factory_.GetWeakPtr(), web_contents, id,
118 requesting_origin, embedding_origin, callback)); 118 requesting_origin, embedding_origin, callback));
119 pending_requests_.insert( 119 pending_requests_.insert(
120 std::make_pair(web_contents, std::make_pair(widget, id))); 120 std::make_pair(web_contents, std::make_pair(widget, id)));
121 } 121 }
122 #endif // defined(OS_CHROMEOS) 122 #endif // defined(OS_CHROMEOS)
123 123
124 ContentSetting ProtectedMediaIdentifierPermissionContext::GetPermissionStatus( 124 ContentSetting ProtectedMediaIdentifierPermissionContext::GetPermissionStatus(
125 const GURL& requesting_origin, 125 const url::Origin& requesting_origin,
126 const GURL& embedding_origin) const { 126 const url::Origin& embedding_origin) const {
127 DVLOG(1) << __FUNCTION__ << ": (" << requesting_origin.spec() << ", " 127 DVLOG(1) << __FUNCTION__ << ": (" << requesting_origin.spec() << ", "
128 << embedding_origin.spec() << ")"; 128 << embedding_origin.spec() << ")";
129 129
130 if (!requesting_origin.is_valid() || !embedding_origin.is_valid() || 130 if (!requesting_origin.is_valid() || !embedding_origin.is_valid() ||
131 !IsProtectedMediaIdentifierEnabled()) { 131 !IsProtectedMediaIdentifierEnabled()) {
132 return CONTENT_SETTING_BLOCK; 132 return CONTENT_SETTING_BLOCK;
133 } 133 }
134 134
135 ContentSetting content_setting = PermissionContextBase::GetPermissionStatus( 135 ContentSetting content_setting = PermissionContextBase::GetPermissionStatus(
136 requesting_origin, embedding_origin); 136 requesting_origin, embedding_origin);
(...skipping 24 matching lines...) Expand all
161 // will simply be dropped. 161 // will simply be dropped.
162 if (!web_contents->IsBeingDestroyed()) 162 if (!web_contents->IsBeingDestroyed())
163 widget->Close(); 163 widget->Close();
164 #else 164 #else
165 PermissionContextBase::CancelPermissionRequest(web_contents, id); 165 PermissionContextBase::CancelPermissionRequest(web_contents, id);
166 #endif 166 #endif
167 } 167 }
168 168
169 void ProtectedMediaIdentifierPermissionContext::UpdateTabContext( 169 void ProtectedMediaIdentifierPermissionContext::UpdateTabContext(
170 const PermissionRequestID& id, 170 const PermissionRequestID& id,
171 const GURL& requesting_frame, 171 const url::Origin& requesting_frame,
172 bool allowed) { 172 bool allowed) {
173 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 173 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
174 174
175 // WebContents may have gone away. 175 // WebContents may have gone away.
176 TabSpecificContentSettings* content_settings = 176 TabSpecificContentSettings* content_settings =
177 TabSpecificContentSettings::GetForFrame(id.render_process_id(), 177 TabSpecificContentSettings::GetForFrame(id.render_process_id(),
178 id.render_frame_id()); 178 id.render_frame_id());
179 if (content_settings) { 179 if (content_settings) {
180 content_settings->OnProtectedMediaIdentifierPermissionSet( 180 content_settings->OnProtectedMediaIdentifierPermissionSet(
181 requesting_frame.GetOrigin(), allowed); 181 requesting_frame.GetOrigin(), allowed);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 #endif 220 #endif
221 221
222 return true; 222 return true;
223 } 223 }
224 224
225 #if defined(OS_CHROMEOS) 225 #if defined(OS_CHROMEOS)
226 void ProtectedMediaIdentifierPermissionContext:: 226 void ProtectedMediaIdentifierPermissionContext::
227 OnPlatformVerificationConsentResponse( 227 OnPlatformVerificationConsentResponse(
228 content::WebContents* web_contents, 228 content::WebContents* web_contents,
229 const PermissionRequestID& id, 229 const PermissionRequestID& id,
230 const GURL& requesting_origin, 230 const url::Origin& requesting_origin,
231 const GURL& embedding_origin, 231 const url::Origin& embedding_origin,
232 const BrowserPermissionCallback& callback, 232 const BrowserPermissionCallback& callback,
233 PlatformVerificationDialog::ConsentResponse response) { 233 PlatformVerificationDialog::ConsentResponse response) {
234 // The request may have been canceled. Drop the callback in that case. 234 // The request may have been canceled. Drop the callback in that case.
235 PendingRequestMap::iterator request = pending_requests_.find(web_contents); 235 PendingRequestMap::iterator request = pending_requests_.find(web_contents);
236 if (request == pending_requests_.end()) 236 if (request == pending_requests_.end())
237 return; 237 return;
238 238
239 DCHECK(request->second.second == id); 239 DCHECK(request->second.second == id);
240 pending_requests_.erase(request); 240 pending_requests_.erase(request);
241 241
(...skipping 18 matching lines...) Expand all
260 content_setting = CONTENT_SETTING_BLOCK; 260 content_setting = CONTENT_SETTING_BLOCK;
261 persist = true; 261 persist = true;
262 break; 262 break;
263 } 263 }
264 264
265 NotifyPermissionSet( 265 NotifyPermissionSet(
266 id, requesting_origin, embedding_origin, callback, 266 id, requesting_origin, embedding_origin, callback,
267 persist, content_setting); 267 persist, content_setting);
268 } 268 }
269 #endif 269 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698