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

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

Issue 2945243002: Permissions: Allow PermissionManager to return more PermissionStatusSources.
Patch Set: Cleanup. Created 3 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/metrics/user_metrics.h" 8 #include "base/metrics/user_metrics.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 if (!widget) { 88 if (!widget) {
89 callback.Run(CONTENT_SETTING_ASK); 89 callback.Run(CONTENT_SETTING_ASK);
90 return; 90 return;
91 } 91 }
92 92
93 pending_requests_.insert( 93 pending_requests_.insert(
94 std::make_pair(web_contents, std::make_pair(widget, id))); 94 std::make_pair(web_contents, std::make_pair(widget, id)));
95 } 95 }
96 #endif // defined(OS_CHROMEOS) 96 #endif // defined(OS_CHROMEOS)
97 97
98 ContentSetting 98 PermissionResult
99 ProtectedMediaIdentifierPermissionContext::GetPermissionStatusInternal( 99 ProtectedMediaIdentifierPermissionContext::GetPermissionStatusInternal(
100 content::RenderFrameHost* render_frame_host, 100 content::RenderFrameHost* render_frame_host,
101 const GURL& requesting_origin, 101 const GURL& requesting_origin,
102 const GURL& embedding_origin) const { 102 const GURL& embedding_origin) const {
103 DVLOG(1) << __func__ << ": (" << requesting_origin.spec() << ", " 103 DVLOG(1) << __func__ << ": (" << requesting_origin.spec() << ", "
104 << embedding_origin.spec() << ")"; 104 << embedding_origin.spec() << ")";
105 105
106 if (!requesting_origin.is_valid() || !embedding_origin.is_valid() || 106 if (!requesting_origin.is_valid() || !embedding_origin.is_valid() ||
107 !IsProtectedMediaIdentifierEnabled()) { 107 !IsProtectedMediaIdentifierEnabled()) {
108 return CONTENT_SETTING_BLOCK; 108 return PermissionResult(CONTENT_SETTING_BLOCK,
109 PermissionStatusSource::UNSPECIFIED);
109 } 110 }
110 111
111 ContentSetting content_setting = 112 PermissionResult result = PermissionContextBase::GetPermissionStatusInternal(
112 PermissionContextBase::GetPermissionStatusInternal( 113 render_frame_host, requesting_origin, embedding_origin);
113 render_frame_host, requesting_origin, embedding_origin); 114 DCHECK(result.content_setting == CONTENT_SETTING_ALLOW ||
114 DCHECK(content_setting == CONTENT_SETTING_ALLOW || 115 result.content_setting == CONTENT_SETTING_BLOCK ||
115 content_setting == CONTENT_SETTING_BLOCK || 116 result.content_setting == CONTENT_SETTING_ASK);
116 content_setting == CONTENT_SETTING_ASK);
117 117
118 // For automated testing of protected content - having a prompt that 118 // For automated testing of protected content - having a prompt that
119 // requires user intervention is problematic. If the domain has been 119 // requires user intervention is problematic. If the domain has been
120 // whitelisted as safe - suppress the request and allow. 120 // whitelisted as safe - suppress the request and allow.
121 if (content_setting == CONTENT_SETTING_ASK && 121 if (result.content_setting == CONTENT_SETTING_ASK &&
122 IsOriginWhitelisted(requesting_origin)) { 122 IsOriginWhitelisted(requesting_origin)) {
123 content_setting = CONTENT_SETTING_ALLOW; 123 result.content_setting = CONTENT_SETTING_ALLOW;
124 result.source = PermissionStatusSource::ENTERPRISE_POLICY;
124 } 125 }
125 126
126 return content_setting; 127 return result;
127 } 128 }
128 129
129 bool ProtectedMediaIdentifierPermissionContext::IsOriginWhitelisted( 130 bool ProtectedMediaIdentifierPermissionContext::IsOriginWhitelisted(
130 const GURL& origin) { 131 const GURL& origin) {
131 const base::CommandLine& command_line = 132 const base::CommandLine& command_line =
132 *base::CommandLine::ForCurrentProcess(); 133 *base::CommandLine::ForCurrentProcess();
133 134
134 if (command_line.GetSwitchValueASCII(switches::kUserDataDir).empty()) { 135 if (command_line.GetSwitchValueASCII(switches::kUserDataDir).empty()) {
135 return false; 136 return false;
136 } 137 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 content_setting = CONTENT_SETTING_BLOCK; 287 content_setting = CONTENT_SETTING_BLOCK;
287 persist = true; 288 persist = true;
288 break; 289 break;
289 } 290 }
290 291
291 NotifyPermissionSet( 292 NotifyPermissionSet(
292 id, requesting_origin, embedding_origin, callback, 293 id, requesting_origin, embedding_origin, callback,
293 persist, content_setting); 294 persist, content_setting);
294 } 295 }
295 #endif 296 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698