| 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 "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| 11 #include "components/content_settings/core/common/permission_request_id.h" | 11 #include "components/content_settings/core/common/permission_request_id.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 | 14 |
| 15 #if defined(ENABLE_EXTENSIONS) | |
| 16 #include "chrome/browser/extensions/extension_service.h" | |
| 17 #include "extensions/browser/extension_system.h" | |
| 18 #include "extensions/browser/suggest_permission_util.h" | |
| 19 #include "extensions/browser/view_type_utils.h" | |
| 20 #include "extensions/common/extension.h" | |
| 21 | |
| 22 using extensions::APIPermission; | |
| 23 #endif | |
| 24 | |
| 25 ProtectedMediaIdentifierPermissionContext:: | 15 ProtectedMediaIdentifierPermissionContext:: |
| 26 ProtectedMediaIdentifierPermissionContext(Profile* profile) | 16 ProtectedMediaIdentifierPermissionContext(Profile* profile) |
| 27 : PermissionContextBase(profile, | 17 : PermissionContextBase(profile, |
| 28 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) { | 18 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) { |
| 29 } | 19 } |
| 30 | 20 |
| 31 ProtectedMediaIdentifierPermissionContext:: | 21 ProtectedMediaIdentifierPermissionContext:: |
| 32 ~ProtectedMediaIdentifierPermissionContext() { | 22 ~ProtectedMediaIdentifierPermissionContext() { |
| 33 } | 23 } |
| 34 | 24 |
| 35 void ProtectedMediaIdentifierPermissionContext::RequestPermission( | 25 void ProtectedMediaIdentifierPermissionContext::RequestPermission( |
| 36 content::WebContents* web_contents, | 26 content::WebContents* web_contents, |
| 37 const PermissionRequestID& id, | 27 const PermissionRequestID& id, |
| 38 const GURL& requesting_frame_origin, | 28 const GURL& requesting_frame_origin, |
| 39 bool user_gesture, | 29 bool user_gesture, |
| 40 const BrowserPermissionCallback& callback) { | 30 const BrowserPermissionCallback& callback) { |
| 41 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 31 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 42 | 32 |
| 43 #if defined(ENABLE_EXTENSIONS) | |
| 44 if (extensions::GetViewType(web_contents) != | |
| 45 extensions::VIEW_TYPE_TAB_CONTENTS) { | |
| 46 // The tab may have gone away, or the request may not be from a tab at all. | |
| 47 DVLOG(1) | |
| 48 << "Attempt to use protected media identifier in tabless renderer: " | |
| 49 << id.ToString() | |
| 50 << " (can't prompt user without a visible tab)"; | |
| 51 NotifyPermissionSet(id, requesting_frame_origin, | |
| 52 web_contents->GetLastCommittedURL().GetOrigin(), | |
| 53 callback, false, false); | |
| 54 return; | |
| 55 } | |
| 56 #endif | |
| 57 | |
| 58 #if defined(OS_ANDROID) | 33 #if defined(OS_ANDROID) |
| 59 // Check if the protected media identifier master switch is disabled. | 34 // Check if the protected media identifier master switch is disabled. |
| 60 if (!profile()->GetPrefs()->GetBoolean( | 35 if (!profile()->GetPrefs()->GetBoolean( |
| 61 prefs::kProtectedMediaIdentifierEnabled)) { | 36 prefs::kProtectedMediaIdentifierEnabled)) { |
| 62 NotifyPermissionSet(id, | 37 NotifyPermissionSet(id, |
| 63 requesting_frame_origin, | 38 requesting_frame_origin, |
| 64 web_contents->GetLastCommittedURL().GetOrigin(), | 39 web_contents->GetLastCommittedURL().GetOrigin(), |
| 65 callback, false, false); | 40 callback, false, false); |
| 66 return; | 41 return; |
| 67 } | 42 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 82 // WebContents may have gone away. | 57 // WebContents may have gone away. |
| 83 TabSpecificContentSettings* content_settings = | 58 TabSpecificContentSettings* content_settings = |
| 84 TabSpecificContentSettings::Get(id.render_process_id(), | 59 TabSpecificContentSettings::Get(id.render_process_id(), |
| 85 id.render_view_id()); | 60 id.render_view_id()); |
| 86 if (content_settings) { | 61 if (content_settings) { |
| 87 content_settings->OnProtectedMediaIdentifierPermissionSet( | 62 content_settings->OnProtectedMediaIdentifierPermissionSet( |
| 88 requesting_frame.GetOrigin(), allowed); | 63 requesting_frame.GetOrigin(), allowed); |
| 89 } | 64 } |
| 90 | 65 |
| 91 } | 66 } |
| OLD | NEW |