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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/browser/content_settings/host_content_settings_map.h" | 14 #include "chrome/browser/content_settings/host_content_settings_map.h" |
15 #include "chrome/browser/content_settings/permission_request_id.h" | 15 #include "chrome/browser/content_settings/permission_request_id.h" |
16 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 16 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
17 #include "chrome/browser/extensions/extension_service.h" | |
18 #include "chrome/browser/extensions/suggest_permission_util.h" | |
19 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/tab_contents/tab_util.h" | 18 #include "chrome/browser/tab_contents/tab_util.h" |
21 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
22 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
23 #include "content/public/browser/render_process_host.h" | 21 #include "content/public/browser/render_process_host.h" |
24 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
25 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 24 |
| 25 #if defined(ENABLE_EXTENSIONS) |
| 26 #include "chrome/browser/extensions/extension_service.h" |
| 27 #include "chrome/browser/extensions/suggest_permission_util.h" |
26 #include "extensions/browser/extension_system.h" | 28 #include "extensions/browser/extension_system.h" |
27 #include "extensions/browser/view_type_utils.h" | 29 #include "extensions/browser/view_type_utils.h" |
28 #include "extensions/common/extension.h" | 30 #include "extensions/common/extension.h" |
29 | 31 |
30 using extensions::APIPermission; | 32 using extensions::APIPermission; |
| 33 #endif |
31 | 34 |
32 ProtectedMediaIdentifierPermissionContext:: | 35 ProtectedMediaIdentifierPermissionContext:: |
33 ProtectedMediaIdentifierPermissionContext(Profile* profile) | 36 ProtectedMediaIdentifierPermissionContext(Profile* profile) |
34 : profile_(profile), shutting_down_(false) {} | 37 : profile_(profile), shutting_down_(false) {} |
35 | 38 |
36 ProtectedMediaIdentifierPermissionContext:: | 39 ProtectedMediaIdentifierPermissionContext:: |
37 ~ProtectedMediaIdentifierPermissionContext() { | 40 ~ProtectedMediaIdentifierPermissionContext() { |
38 // ProtectedMediaIdentifierPermissionContext may be destroyed on either | 41 // ProtectedMediaIdentifierPermissionContext may be destroyed on either |
39 // the UI thread or the IO thread, but the PermissionQueueController must have | 42 // the UI thread or the IO thread, but the PermissionQueueController must have |
40 // been destroyed on the UI thread. | 43 // been destroyed on the UI thread. |
(...skipping 15 matching lines...) Expand all Loading... |
56 if (cancel_callback) { | 59 if (cancel_callback) { |
57 *cancel_callback = base::Bind( | 60 *cancel_callback = base::Bind( |
58 &ProtectedMediaIdentifierPermissionContext:: | 61 &ProtectedMediaIdentifierPermissionContext:: |
59 CancelProtectedMediaIdentifierPermissionRequests, | 62 CancelProtectedMediaIdentifierPermissionRequests, |
60 this, render_process_id, render_view_id, origin); | 63 this, render_process_id, render_view_id, origin); |
61 } | 64 } |
62 | 65 |
63 const PermissionRequestID id( | 66 const PermissionRequestID id( |
64 render_process_id, render_view_id, 0, origin); | 67 render_process_id, render_view_id, 0, origin); |
65 | 68 |
| 69 #if defined(ENABLE_EXTENSIONS) |
66 if (extensions::GetViewType(web_contents) != | 70 if (extensions::GetViewType(web_contents) != |
67 extensions::VIEW_TYPE_TAB_CONTENTS) { | 71 extensions::VIEW_TYPE_TAB_CONTENTS) { |
68 // The tab may have gone away, or the request may not be from a tab at all. | 72 // The tab may have gone away, or the request may not be from a tab at all. |
69 LOG(WARNING) | 73 LOG(WARNING) |
70 << "Attempt to use protected media identifier in tabless renderer: " | 74 << "Attempt to use protected media identifier in tabless renderer: " |
71 << id.ToString() | 75 << id.ToString() |
72 << " (can't prompt user without a visible tab)"; | 76 << " (can't prompt user without a visible tab)"; |
73 NotifyPermissionSet(id, origin, result_callback, false); | 77 NotifyPermissionSet(id, origin, result_callback, false); |
74 return; | 78 return; |
75 } | 79 } |
| 80 #endif |
76 | 81 |
77 GURL embedder = web_contents->GetLastCommittedURL(); | 82 GURL embedder = web_contents->GetLastCommittedURL(); |
78 if (!origin.is_valid() || !embedder.is_valid()) { | 83 if (!origin.is_valid() || !embedder.is_valid()) { |
79 LOG(WARNING) | 84 LOG(WARNING) |
80 << "Attempt to use protected media identifier from an invalid URL: " | 85 << "Attempt to use protected media identifier from an invalid URL: " |
81 << origin << "," << embedder | 86 << origin << "," << embedder |
82 << " (proteced media identifier is not supported in popups)"; | 87 << " (proteced media identifier is not supported in popups)"; |
83 NotifyPermissionSet(id, origin, result_callback, false); | 88 NotifyPermissionSet(id, origin, result_callback, false); |
84 return; | 89 return; |
85 } | 90 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 origin)); | 217 origin)); |
213 return; | 218 return; |
214 } | 219 } |
215 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 220 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
216 if (shutting_down_) | 221 if (shutting_down_) |
217 return; | 222 return; |
218 QueueController()->CancelInfoBarRequest( | 223 QueueController()->CancelInfoBarRequest( |
219 PermissionRequestID(render_process_id, render_view_id, 0, | 224 PermissionRequestID(render_process_id, render_view_id, 0, |
220 origin)); | 225 origin)); |
221 } | 226 } |
OLD | NEW |