| 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/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 "chrome/browser/content_settings/tab_specific_content_settings.h" | 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
| 12 #include "components/content_settings/core/common/permission_request_id.h" | |
| 13 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/user_metrics.h" | 13 #include "content/public/browser/user_metrics.h" |
| 15 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 16 #if defined(OS_CHROMEOS) | 15 #if defined(OS_CHROMEOS) |
| 17 #include <utility> | 16 #include <utility> |
| 18 | 17 |
| 19 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h" | 18 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h" |
| 20 #include "chrome/browser/chromeos/settings/cros_settings.h" | 19 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 21 #include "chromeos/chromeos_switches.h" | 20 #include "chromeos/chromeos_switches.h" |
| 22 #include "chromeos/settings/cros_settings_names.h" | 21 #include "chromeos/settings/cros_settings_names.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 return content_setting; | 131 return content_setting; |
| 133 } | 132 } |
| 134 | 133 |
| 135 void ProtectedMediaIdentifierPermissionContext::CancelPermissionRequest( | 134 void ProtectedMediaIdentifierPermissionContext::CancelPermissionRequest( |
| 136 content::WebContents* web_contents, | 135 content::WebContents* web_contents, |
| 137 const PermissionRequestID& id) { | 136 const PermissionRequestID& id) { |
| 138 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 137 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 139 | 138 |
| 140 #if defined(OS_CHROMEOS) | 139 #if defined(OS_CHROMEOS) |
| 141 PendingRequestMap::iterator request = pending_requests_.find(web_contents); | 140 PendingRequestMap::iterator request = pending_requests_.find(web_contents); |
| 142 if (request == pending_requests_.end() || !request->second.second.Equals(id)) | 141 if (request == pending_requests_.end() || (request->second.second != id)) |
| 143 return; | 142 return; |
| 144 | 143 |
| 145 views::Widget* widget = request->second.first; | 144 views::Widget* widget = request->second.first; |
| 146 pending_requests_.erase(request); | 145 pending_requests_.erase(request); |
| 147 | 146 |
| 148 // If |web_contents| is being destroyed, |widget| could be invalid. No need to | 147 // If |web_contents| is being destroyed, |widget| could be invalid. No need to |
| 149 // manually close it here. Otherwise, close the |widget| here. | 148 // manually close it here. Otherwise, close the |widget| here. |
| 150 // OnPlatformVerificationConsentResponse() will be fired during this process, | 149 // OnPlatformVerificationConsentResponse() will be fired during this process, |
| 151 // but since |web_contents| is removed from |pending_requests_|, the callback | 150 // but since |web_contents| is removed from |pending_requests_|, the callback |
| 152 // will simply be dropped. | 151 // will simply be dropped. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 const PermissionRequestID& id, | 219 const PermissionRequestID& id, |
| 221 const GURL& requesting_origin, | 220 const GURL& requesting_origin, |
| 222 const GURL& embedding_origin, | 221 const GURL& embedding_origin, |
| 223 const BrowserPermissionCallback& callback, | 222 const BrowserPermissionCallback& callback, |
| 224 PlatformVerificationDialog::ConsentResponse response) { | 223 PlatformVerificationDialog::ConsentResponse response) { |
| 225 // The request may have been canceled. Drop the callback in that case. | 224 // The request may have been canceled. Drop the callback in that case. |
| 226 PendingRequestMap::iterator request = pending_requests_.find(web_contents); | 225 PendingRequestMap::iterator request = pending_requests_.find(web_contents); |
| 227 if (request == pending_requests_.end()) | 226 if (request == pending_requests_.end()) |
| 228 return; | 227 return; |
| 229 | 228 |
| 230 DCHECK(request->second.second.Equals(id)); | 229 DCHECK(request->second.second == id); |
| 231 pending_requests_.erase(request); | 230 pending_requests_.erase(request); |
| 232 | 231 |
| 233 ContentSetting content_setting = CONTENT_SETTING_ASK; | 232 ContentSetting content_setting = CONTENT_SETTING_ASK; |
| 234 bool persist = false; // Whether the ContentSetting should be saved. | 233 bool persist = false; // Whether the ContentSetting should be saved. |
| 235 switch (response) { | 234 switch (response) { |
| 236 case PlatformVerificationDialog::CONSENT_RESPONSE_NONE: | 235 case PlatformVerificationDialog::CONSENT_RESPONSE_NONE: |
| 237 content_setting = CONTENT_SETTING_ASK; | 236 content_setting = CONTENT_SETTING_ASK; |
| 238 persist = false; | 237 persist = false; |
| 239 break; | 238 break; |
| 240 case PlatformVerificationDialog::CONSENT_RESPONSE_ALLOW: | 239 case PlatformVerificationDialog::CONSENT_RESPONSE_ALLOW: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 251 content_setting = CONTENT_SETTING_BLOCK; | 250 content_setting = CONTENT_SETTING_BLOCK; |
| 252 persist = true; | 251 persist = true; |
| 253 break; | 252 break; |
| 254 } | 253 } |
| 255 | 254 |
| 256 NotifyPermissionSet( | 255 NotifyPermissionSet( |
| 257 id, requesting_origin, embedding_origin, callback, | 256 id, requesting_origin, embedding_origin, callback, |
| 258 persist, content_setting); | 257 persist, content_setting); |
| 259 } | 258 } |
| 260 #endif | 259 #endif |
| OLD | NEW |