| 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, |
| 46 const GURL& requesting_frame, | 47 const GURL& requesting_frame, |
| 47 const base::Callback<void(bool)>& callback) { | 48 const base::Callback<void(bool)>& callback) { |
| 48 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 49 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 49 if (shutting_down_) | 50 if (shutting_down_) |
| 50 return; | 51 return; |
| 51 | 52 |
| 52 content::WebContents* web_contents = | 53 content::WebContents* web_contents = |
| 53 tab_util::GetWebContentsByID(render_process_id, render_view_id); | 54 tab_util::GetWebContentsByID(render_process_id, render_view_id); |
| 54 const PermissionRequestID id(render_process_id, render_view_id, 0); | 55 const PermissionRequestID id(render_process_id, render_view_id, bridge_id); |
| 55 | 56 |
| 56 if (extensions::GetViewType(web_contents) != | 57 if (extensions::GetViewType(web_contents) != |
| 57 extensions::VIEW_TYPE_TAB_CONTENTS) { | 58 extensions::VIEW_TYPE_TAB_CONTENTS) { |
| 58 // The tab may have gone away, or the request may not be from a tab at all. | 59 // The tab may have gone away, or the request may not be from a tab at all. |
| 59 LOG(WARNING) | 60 LOG(WARNING) |
| 60 << "Attempt to use protected media identifier in tabless renderer: " | 61 << "Attempt to use protected media identifier in tabless renderer: " |
| 61 << id.ToString() | 62 << id.ToString() |
| 62 << " (can't prompt user without a visible tab)"; | 63 << " (can't prompt user without a visible tab)"; |
| 63 NotifyPermissionSet(id, requesting_frame, callback, false); | 64 NotifyPermissionSet(id, requesting_frame, callback, false); |
| 64 return; | 65 return; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 75 } | 76 } |
| 76 | 77 |
| 77 content::RenderViewHost* rvh = web_contents->GetRenderViewHost(); | 78 content::RenderViewHost* rvh = web_contents->GetRenderViewHost(); |
| 78 DecidePermission(id, requesting_frame, embedder, rvh, callback); | 79 DecidePermission(id, requesting_frame, embedder, rvh, callback); |
| 79 } | 80 } |
| 80 | 81 |
| 81 void ProtectedMediaIdentifierPermissionContext:: | 82 void ProtectedMediaIdentifierPermissionContext:: |
| 82 CancelProtectedMediaIdentifierPermissionRequest( | 83 CancelProtectedMediaIdentifierPermissionRequest( |
| 83 int render_process_id, | 84 int render_process_id, |
| 84 int render_view_id, | 85 int render_view_id, |
| 86 int bridge_id, |
| 85 const GURL& requesting_frame) { | 87 const GURL& requesting_frame) { |
| 86 CancelPendingInfoBarRequest( | 88 CancelPendingInfoBarRequest( |
| 87 PermissionRequestID(render_process_id, render_view_id, 0)); | 89 PermissionRequestID(render_process_id, render_view_id, bridge_id)); |
| 88 } | 90 } |
| 89 | 91 |
| 90 void ProtectedMediaIdentifierPermissionContext::DecidePermission( | 92 void ProtectedMediaIdentifierPermissionContext::DecidePermission( |
| 91 const PermissionRequestID& id, | 93 const PermissionRequestID& id, |
| 92 const GURL& requesting_frame, | 94 const GURL& requesting_frame, |
| 93 const GURL& embedder, | 95 const GURL& embedder, |
| 94 content::RenderViewHost* rvh, | 96 content::RenderViewHost* rvh, |
| 95 const base::Callback<void(bool)>& callback) { | 97 const base::Callback<void(bool)>& callback) { |
| 96 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 98 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 97 | 99 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 CancelPendingInfoBarRequest, | 198 CancelPendingInfoBarRequest, |
| 197 this, | 199 this, |
| 198 id)); | 200 id)); |
| 199 return; | 201 return; |
| 200 } | 202 } |
| 201 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 203 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 202 if (shutting_down_) | 204 if (shutting_down_) |
| 203 return; | 205 return; |
| 204 QueueController()->CancelInfoBarRequest(id); | 206 QueueController()->CancelInfoBarRequest(id); |
| 205 } | 207 } |
| OLD | NEW |