OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/permissions/permission_context_base.h" | 5 #include "chrome/browser/permissions/permission_context_base.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 const PermissionRequestID& id, | 79 const PermissionRequestID& id, |
80 const GURL& requesting_frame, | 80 const GURL& requesting_frame, |
81 bool user_gesture, | 81 bool user_gesture, |
82 const BrowserPermissionCallback& callback) { | 82 const BrowserPermissionCallback& callback) { |
83 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 83 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
84 | 84 |
85 // First check if this permission has been disabled. | 85 // First check if this permission has been disabled. |
86 if (IsPermissionKillSwitchOn()) { | 86 if (IsPermissionKillSwitchOn()) { |
87 // Log to the developer console. | 87 // Log to the developer console. |
88 web_contents->GetMainFrame()->AddMessageToConsole( | 88 web_contents->GetMainFrame()->AddMessageToConsole( |
89 content::CONSOLE_MESSAGE_LEVEL_LOG, | 89 content::CONSOLE_MESSAGE_LEVEL_INFO, |
90 base::StringPrintf( | 90 base::StringPrintf( |
91 "%s permission has been blocked.", | 91 "%s permission has been blocked.", |
92 PermissionUtil::GetPermissionString(permission_type_).c_str())); | 92 PermissionUtil::GetPermissionString(permission_type_).c_str())); |
93 // The kill switch is enabled for this permission; Block all requests. | 93 // The kill switch is enabled for this permission; Block all requests. |
94 callback.Run(CONTENT_SETTING_BLOCK); | 94 callback.Run(CONTENT_SETTING_BLOCK); |
95 return; | 95 return; |
96 } | 96 } |
97 | 97 |
98 GURL requesting_origin = requesting_frame.GetOrigin(); | 98 GURL requesting_origin = requesting_frame.GetOrigin(); |
99 GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin(); | 99 GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 const PermissionRequestID& id, | 154 const PermissionRequestID& id, |
155 const GURL& requesting_origin, | 155 const GURL& requesting_origin, |
156 const GURL& embedding_origin, | 156 const GURL& embedding_origin, |
157 bool user_gesture, | 157 bool user_gesture, |
158 const BrowserPermissionCallback& callback, | 158 const BrowserPermissionCallback& callback, |
159 bool permission_blocked) { | 159 bool permission_blocked) { |
160 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 160 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
161 if (permission_blocked) { | 161 if (permission_blocked) { |
162 // TODO(meredithl): Add UMA metrics here. | 162 // TODO(meredithl): Add UMA metrics here. |
163 web_contents->GetMainFrame()->AddMessageToConsole( | 163 web_contents->GetMainFrame()->AddMessageToConsole( |
164 content::CONSOLE_MESSAGE_LEVEL_LOG, | 164 content::CONSOLE_MESSAGE_LEVEL_INFO, |
165 base::StringPrintf( | 165 base::StringPrintf( |
166 "%s permission has been auto-blocked.", | 166 "%s permission has been auto-blocked.", |
167 PermissionUtil::GetPermissionString(permission_type_).c_str())); | 167 PermissionUtil::GetPermissionString(permission_type_).c_str())); |
168 // Permission has been blacklisted, block the request. | 168 // Permission has been blacklisted, block the request. |
169 // TODO(meredithl): Consider setting the content setting and persisting | 169 // TODO(meredithl): Consider setting the content setting and persisting |
170 // the decision to block. | 170 // the decision to block. |
171 callback.Run(CONTENT_SETTING_BLOCK); | 171 callback.Run(CONTENT_SETTING_BLOCK); |
172 return; | 172 return; |
173 } | 173 } |
174 | 174 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 content_settings_type_, std::string(), | 390 content_settings_type_, std::string(), |
391 content_setting); | 391 content_setting); |
392 } | 392 } |
393 | 393 |
394 void PermissionContextBase::SetSafeBrowsingDatabaseManagerAndTimeoutForTest( | 394 void PermissionContextBase::SetSafeBrowsingDatabaseManagerAndTimeoutForTest( |
395 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager, | 395 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager, |
396 int timeout) { | 396 int timeout) { |
397 db_manager_ = db_manager; | 397 db_manager_ = db_manager; |
398 safe_browsing_timeout_ = timeout; | 398 safe_browsing_timeout_ = timeout; |
399 } | 399 } |
OLD | NEW |