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

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

Issue 1478433002: Permissions: Move common logic from DecidePermission to RequestPermission (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@innoinherit
Patch Set: Rebase / git cl format Created 5 years 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 "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
(...skipping 30 matching lines...) Expand all
41 , 41 ,
42 weak_factory_(this) 42 weak_factory_(this)
43 #endif 43 #endif
44 { 44 {
45 } 45 }
46 46
47 ProtectedMediaIdentifierPermissionContext:: 47 ProtectedMediaIdentifierPermissionContext::
48 ~ProtectedMediaIdentifierPermissionContext() { 48 ~ProtectedMediaIdentifierPermissionContext() {
49 } 49 }
50 50
51 #if defined(OS_CHROMEOS)
51 void ProtectedMediaIdentifierPermissionContext::RequestPermission( 52 void ProtectedMediaIdentifierPermissionContext::RequestPermission(
52 content::WebContents* web_contents, 53 content::WebContents* web_contents,
53 const PermissionRequestID& id, 54 const PermissionRequestID& id,
54 const GURL& requesting_origin, 55 const GURL& requesting_origin,
55 bool user_gesture, 56 bool user_gesture,
56 const BrowserPermissionCallback& callback) { 57 const BrowserPermissionCallback& callback) {
57 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 58 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
58 59
59 // First check if this permission has been disabled. This check occurs before 60 // First check if this permission has been disabled. This check occurs before
60 // the call to GetPermissionStatus, which will return CONTENT_SETTING_BLOCK 61 // the call to GetPermissionStatus, which will return CONTENT_SETTING_BLOCK
(...skipping 25 matching lines...) Expand all
86 87
87 if (content_setting == CONTENT_SETTING_ALLOW || 88 if (content_setting == CONTENT_SETTING_ALLOW ||
88 content_setting == CONTENT_SETTING_BLOCK) { 89 content_setting == CONTENT_SETTING_BLOCK) {
89 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 90 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
90 false /* persist */, content_setting); 91 false /* persist */, content_setting);
91 return; 92 return;
92 } 93 }
93 94
94 DCHECK_EQ(CONTENT_SETTING_ASK, content_setting); 95 DCHECK_EQ(CONTENT_SETTING_ASK, content_setting);
95 96
96 #if defined(OS_CHROMEOS)
97 // Since the dialog is modal, we only support one prompt per |web_contents|. 97 // Since the dialog is modal, we only support one prompt per |web_contents|.
98 // Reject the new one if there is already one pending. See 98 // Reject the new one if there is already one pending. See
99 // http://crbug.com/447005 99 // http://crbug.com/447005
100 if (pending_requests_.count(web_contents)) { 100 if (pending_requests_.count(web_contents)) {
101 callback.Run(CONTENT_SETTING_ASK); 101 callback.Run(CONTENT_SETTING_ASK);
102 return; 102 return;
103 } 103 }
104 104
105 // On ChromeOS, we don't use PermissionContextBase::RequestPermission() which 105 // On ChromeOS, we don't use PermissionContextBase::RequestPermission() which
106 // uses the standard permission infobar/bubble UI. See http://crbug.com/454847 106 // uses the standard permission infobar/bubble UI. See http://crbug.com/454847
107 // Instead, we show the existing platform verification UI. 107 // Instead, we show the existing platform verification UI.
108 // TODO(xhwang): Remove when http://crbug.com/454847 is fixed. 108 // TODO(xhwang): Remove when http://crbug.com/454847 is fixed.
109 views::Widget* widget = PlatformVerificationDialog::ShowDialog( 109 views::Widget* widget = PlatformVerificationDialog::ShowDialog(
110 web_contents, requesting_origin, 110 web_contents, requesting_origin,
111 base::Bind(&ProtectedMediaIdentifierPermissionContext:: 111 base::Bind(&ProtectedMediaIdentifierPermissionContext::
112 OnPlatformVerificationConsentResponse, 112 OnPlatformVerificationConsentResponse,
113 weak_factory_.GetWeakPtr(), web_contents, id, 113 weak_factory_.GetWeakPtr(), web_contents, id,
114 requesting_origin, embedding_origin, callback)); 114 requesting_origin, embedding_origin, callback));
115 pending_requests_.insert( 115 pending_requests_.insert(
116 std::make_pair(web_contents, std::make_pair(widget, id))); 116 std::make_pair(web_contents, std::make_pair(widget, id)));
117 #else
118 PermissionContextBase::RequestPermission(web_contents, id, requesting_origin,
119 user_gesture, callback);
120 #endif
121 } 117 }
118 #endif // defined(OS_CHROMEOS)
122 119
123 ContentSetting ProtectedMediaIdentifierPermissionContext::GetPermissionStatus( 120 ContentSetting ProtectedMediaIdentifierPermissionContext::GetPermissionStatus(
124 const GURL& requesting_origin, 121 const GURL& requesting_origin,
125 const GURL& embedding_origin) const { 122 const GURL& embedding_origin) const {
126 DVLOG(1) << __FUNCTION__ << ": (" << requesting_origin.spec() << ", " 123 DVLOG(1) << __FUNCTION__ << ": (" << requesting_origin.spec() << ", "
127 << embedding_origin.spec() << ")"; 124 << embedding_origin.spec() << ")";
128 125
129 if (!requesting_origin.is_valid() || !embedding_origin.is_valid() || 126 if (!requesting_origin.is_valid() || !embedding_origin.is_valid() ||
130 !IsProtectedMediaIdentifierEnabled()) { 127 !IsProtectedMediaIdentifierEnabled()) {
131 return CONTENT_SETTING_BLOCK; 128 return CONTENT_SETTING_BLOCK;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 content_setting = CONTENT_SETTING_BLOCK; 256 content_setting = CONTENT_SETTING_BLOCK;
260 persist = true; 257 persist = true;
261 break; 258 break;
262 } 259 }
263 260
264 NotifyPermissionSet( 261 NotifyPermissionSet(
265 id, requesting_origin, embedding_origin, callback, 262 id, requesting_origin, embedding_origin, callback,
266 persist, content_setting); 263 persist, content_setting);
267 } 264 }
268 #endif 265 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698