| OLD | NEW |
| 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 <functional> | 7 #include <functional> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 // ProtectedMediaIdentifierPermissionContext may be destroyed on either | 36 // ProtectedMediaIdentifierPermissionContext may be destroyed on either |
| 37 // the UI thread or the IO thread, but the PermissionQueueController must have | 37 // the UI thread or the IO thread, but the PermissionQueueController must have |
| 38 // been destroyed on the UI thread. | 38 // been destroyed on the UI thread. |
| 39 DCHECK(!permission_queue_controller_.get()); | 39 DCHECK(!permission_queue_controller_.get()); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void ProtectedMediaIdentifierPermissionContext:: | 42 void ProtectedMediaIdentifierPermissionContext:: |
| 43 RequestProtectedMediaIdentifierPermission( | 43 RequestProtectedMediaIdentifierPermission( |
| 44 int render_process_id, | 44 int render_process_id, |
| 45 int render_view_id, | 45 int render_view_id, |
| 46 int bridge_id, |
| 47 int group_id, |
| 46 const GURL& requesting_frame, | 48 const GURL& requesting_frame, |
| 47 const base::Callback<void(bool)>& callback) { | 49 const base::Callback<void(bool)>& callback) { |
| 48 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 50 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 49 if (shutting_down_) | 51 if (shutting_down_) |
| 50 return; | 52 return; |
| 51 | 53 |
| 52 content::WebContents* web_contents = | 54 content::WebContents* web_contents = |
| 53 tab_util::GetWebContentsByID(render_process_id, render_view_id); | 55 tab_util::GetWebContentsByID(render_process_id, render_view_id); |
| 54 const PermissionRequestID id(render_process_id, render_view_id, 0); | 56 const PermissionRequestID id( |
| 57 render_process_id, render_view_id, bridge_id, group_id); |
| 55 | 58 |
| 56 if (extensions::GetViewType(web_contents) != | 59 if (extensions::GetViewType(web_contents) != |
| 57 extensions::VIEW_TYPE_TAB_CONTENTS) { | 60 extensions::VIEW_TYPE_TAB_CONTENTS) { |
| 58 // The tab may have gone away, or the request may not be from a tab at all. | 61 // The tab may have gone away, or the request may not be from a tab at all. |
| 59 LOG(WARNING) | 62 LOG(WARNING) |
| 60 << "Attempt to use protected media identifier in tabless renderer: " | 63 << "Attempt to use protected media identifier in tabless renderer: " |
| 61 << id.ToString() | 64 << id.ToString() |
| 62 << " (can't prompt user without a visible tab)"; | 65 << " (can't prompt user without a visible tab)"; |
| 63 NotifyPermissionSet(id, requesting_frame, callback, false); | 66 NotifyPermissionSet(id, requesting_frame, callback, false); |
| 64 return; | 67 return; |
| 65 } | 68 } |
| 66 | 69 |
| 67 GURL embedder = web_contents->GetLastCommittedURL(); | 70 GURL embedder = web_contents->GetLastCommittedURL(); |
| 68 if (!requesting_frame.is_valid() || !embedder.is_valid()) { | 71 if (!requesting_frame.is_valid() || !embedder.is_valid()) { |
| 69 LOG(WARNING) | 72 LOG(WARNING) |
| 70 << "Attempt to use protected media identifier from an invalid URL: " | 73 << "Attempt to use protected media identifier from an invalid URL: " |
| 71 << requesting_frame << "," << embedder | 74 << requesting_frame << "," << embedder |
| 72 << " (proteced media identifier is not supported in popups)"; | 75 << " (proteced media identifier is not supported in popups)"; |
| 73 NotifyPermissionSet(id, requesting_frame, callback, false); | 76 NotifyPermissionSet(id, requesting_frame, callback, false); |
| 74 return; | 77 return; |
| 75 } | 78 } |
| 76 | 79 |
| 77 content::RenderViewHost* rvh = web_contents->GetRenderViewHost(); | 80 content::RenderViewHost* rvh = web_contents->GetRenderViewHost(); |
| 78 DecidePermission(id, requesting_frame, embedder, rvh, callback); | 81 DecidePermission(id, requesting_frame, embedder, rvh, callback); |
| 79 } | 82 } |
| 80 | 83 |
| 81 void ProtectedMediaIdentifierPermissionContext:: | 84 void ProtectedMediaIdentifierPermissionContext:: |
| 82 CancelProtectedMediaIdentifierPermissionRequest( | 85 CancelProtectedMediaIdentifierPermissionRequests(int group_id) { |
| 83 int render_process_id, | 86 CancelPendingInfobarRequests(group_id); |
| 84 int render_view_id, | |
| 85 const GURL& requesting_frame) { | |
| 86 CancelPendingInfoBarRequest( | |
| 87 PermissionRequestID(render_process_id, render_view_id, 0)); | |
| 88 } | 87 } |
| 89 | 88 |
| 90 void ProtectedMediaIdentifierPermissionContext::DecidePermission( | 89 void ProtectedMediaIdentifierPermissionContext::DecidePermission( |
| 91 const PermissionRequestID& id, | 90 const PermissionRequestID& id, |
| 92 const GURL& requesting_frame, | 91 const GURL& requesting_frame, |
| 93 const GURL& embedder, | 92 const GURL& embedder, |
| 94 content::RenderViewHost* rvh, | 93 content::RenderViewHost* rvh, |
| 95 const base::Callback<void(bool)>& callback) { | 94 const base::Callback<void(bool)>& callback) { |
| 96 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 95 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 97 | 96 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 } | 178 } |
| 180 | 179 |
| 181 PermissionQueueController* | 180 PermissionQueueController* |
| 182 ProtectedMediaIdentifierPermissionContext::CreateQueueController() { | 181 ProtectedMediaIdentifierPermissionContext::CreateQueueController() { |
| 183 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 182 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 184 return new PermissionQueueController( | 183 return new PermissionQueueController( |
| 185 profile(), CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER); | 184 profile(), CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER); |
| 186 } | 185 } |
| 187 | 186 |
| 188 void | 187 void |
| 189 ProtectedMediaIdentifierPermissionContext::CancelPendingInfoBarRequest( | 188 ProtectedMediaIdentifierPermissionContext::CancelPendingInfobarRequests( |
| 190 const PermissionRequestID& id) { | 189 int group_id) { |
| 191 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { | 190 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { |
| 192 content::BrowserThread::PostTask( | 191 content::BrowserThread::PostTask( |
| 193 content::BrowserThread::UI, | 192 content::BrowserThread::UI, |
| 194 FROM_HERE, | 193 FROM_HERE, |
| 195 base::Bind(&ProtectedMediaIdentifierPermissionContext:: | 194 base::Bind(&ProtectedMediaIdentifierPermissionContext:: |
| 196 CancelPendingInfoBarRequest, | 195 CancelPendingInfobarRequests, |
| 197 this, | 196 this, |
| 198 id)); | 197 group_id)); |
| 199 return; | 198 return; |
| 200 } | 199 } |
| 201 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 200 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 202 if (shutting_down_) | 201 if (shutting_down_) |
| 203 return; | 202 return; |
| 204 QueueController()->CancelInfoBarRequest(id); | 203 QueueController()->CancelInfoBarRequests(group_id); |
| 205 } | 204 } |
| OLD | NEW |