| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "extensions/common/permissions/permissions_data.h" | 5 #include "extensions/common/permissions/permissions_data.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "content/public/common/url_constants.h" | 8 #include "content/public/common/url_constants.h" |
| 9 #include "extensions/common/constants.h" | 9 #include "extensions/common/constants.h" |
| 10 #include "extensions/common/error_utils.h" | 10 #include "extensions/common/error_utils.h" |
| 11 #include "extensions/common/extensions_client.h" | 11 #include "extensions/common/extensions_client.h" |
| 12 #include "extensions/common/manifest.h" | 12 #include "extensions/common/manifest.h" |
| 13 #include "extensions/common/manifest_constants.h" | 13 #include "extensions/common/manifest_constants.h" |
| 14 #include "extensions/common/manifest_handlers/permissions_parser.h" | 14 #include "extensions/common/manifest_handlers/permissions_parser.h" |
| 15 #include "extensions/common/permissions/permission_message_provider.h" | 15 #include "extensions/common/permissions/permission_message_provider.h" |
| 16 #include "extensions/common/switches.h" | 16 #include "extensions/common/switches.h" |
| 17 #include "extensions/common/url_pattern_set.h" | 17 #include "extensions/common/url_pattern_set.h" |
| 18 #include "extensions/common/user_script.h" | 18 #include "extensions/common/user_script.h" |
| 19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 20 #include "url/url_constants.h" | 20 #include "url/url_constants.h" |
| 21 | 21 |
| 22 namespace extensions { | 22 namespace extensions { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 PermissionsData::PolicyDelegate* g_policy_delegate = NULL; | 26 PermissionsData::PolicyDelegate* g_policy_delegate = nullptr; |
| 27 | 27 |
| 28 } // namespace | 28 } // namespace |
| 29 | 29 |
| 30 PermissionsData::PermissionsData(const Extension* extension) | 30 PermissionsData::PermissionsData(const Extension* extension) |
| 31 : extension_id_(extension->id()), manifest_type_(extension->GetType()) { | 31 : extension_id_(extension->id()), manifest_type_(extension->GetType()) { |
| 32 base::AutoLock auto_lock(runtime_lock_); | 32 base::AutoLock auto_lock(runtime_lock_); |
| 33 scoped_refptr<const PermissionSet> required_permissions = | 33 scoped_refptr<const PermissionSet> required_permissions = |
| 34 PermissionsParser::GetRequiredPermissions(extension); | 34 PermissionsParser::GetRequiredPermissions(extension); |
| 35 active_permissions_unsafe_ = | 35 active_permissions_unsafe_ = |
| 36 new PermissionSet(required_permissions->apis(), | 36 new PermissionSet(required_permissions->apis(), |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 *error = manifest_errors::kAllURLOrActiveTabNeeded; | 308 *error = manifest_errors::kAllURLOrActiveTabNeeded; |
| 309 return false; | 309 return false; |
| 310 } | 310 } |
| 311 | 311 |
| 312 scoped_refptr<const PermissionSet> PermissionsData::GetTabSpecificPermissions( | 312 scoped_refptr<const PermissionSet> PermissionsData::GetTabSpecificPermissions( |
| 313 int tab_id) const { | 313 int tab_id) const { |
| 314 base::AutoLock auto_lock(runtime_lock_); | 314 base::AutoLock auto_lock(runtime_lock_); |
| 315 CHECK_GE(tab_id, 0); | 315 CHECK_GE(tab_id, 0); |
| 316 TabPermissionsMap::const_iterator iter = | 316 TabPermissionsMap::const_iterator iter = |
| 317 tab_specific_permissions_.find(tab_id); | 317 tab_specific_permissions_.find(tab_id); |
| 318 return (iter != tab_specific_permissions_.end()) ? iter->second : NULL; | 318 return (iter != tab_specific_permissions_.end()) ? iter->second : nullptr; |
| 319 } | 319 } |
| 320 | 320 |
| 321 bool PermissionsData::HasTabSpecificPermissionToExecuteScript( | 321 bool PermissionsData::HasTabSpecificPermissionToExecuteScript( |
| 322 int tab_id, | 322 int tab_id, |
| 323 const GURL& url) const { | 323 const GURL& url) const { |
| 324 if (tab_id >= 0) { | 324 if (tab_id >= 0) { |
| 325 scoped_refptr<const PermissionSet> tab_permissions = | 325 scoped_refptr<const PermissionSet> tab_permissions = |
| 326 GetTabSpecificPermissions(tab_id); | 326 GetTabSpecificPermissions(tab_id); |
| 327 if (tab_permissions.get() && | 327 if (tab_permissions.get() && |
| 328 tab_permissions->explicit_hosts().MatchesSecurityOrigin(url)) { | 328 tab_permissions->explicit_hosts().MatchesSecurityOrigin(url)) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 return ACCESS_WITHHELD; | 360 return ACCESS_WITHHELD; |
| 361 | 361 |
| 362 if (error) { | 362 if (error) { |
| 363 *error = ErrorUtils::FormatErrorMessage(manifest_errors::kCannotAccessPage, | 363 *error = ErrorUtils::FormatErrorMessage(manifest_errors::kCannotAccessPage, |
| 364 document_url.spec()); | 364 document_url.spec()); |
| 365 } | 365 } |
| 366 return ACCESS_DENIED; | 366 return ACCESS_DENIED; |
| 367 } | 367 } |
| 368 | 368 |
| 369 } // namespace extensions | 369 } // namespace extensions |
| OLD | NEW |