| 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" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 PermissionsData::~PermissionsData() { | 43 PermissionsData::~PermissionsData() { |
| 44 } | 44 } |
| 45 | 45 |
| 46 // static | 46 // static |
| 47 void PermissionsData::SetPolicyDelegate(PolicyDelegate* delegate) { | 47 void PermissionsData::SetPolicyDelegate(PolicyDelegate* delegate) { |
| 48 g_policy_delegate = delegate; | 48 g_policy_delegate = delegate; |
| 49 } | 49 } |
| 50 | 50 |
| 51 // static | 51 // static |
| 52 bool PermissionsData::IsExtensionIdWhitelisted( |
| 53 const std::string& extension_id) { |
| 54 const ExtensionsClient::ScriptingWhitelist& whitelist = |
| 55 ExtensionsClient::Get()->GetScriptingWhitelist(); |
| 56 |
| 57 return std::find(whitelist.begin(), whitelist.end(), extension_id) != |
| 58 whitelist.end(); |
| 59 } |
| 60 |
| 61 // static |
| 52 bool PermissionsData::CanExecuteScriptEverywhere(const Extension* extension) { | 62 bool PermissionsData::CanExecuteScriptEverywhere(const Extension* extension) { |
| 53 if (extension->location() == Manifest::COMPONENT) | 63 if (extension->location() == Manifest::COMPONENT) |
| 54 return true; | 64 return true; |
| 55 | 65 |
| 56 const ExtensionsClient::ScriptingWhitelist& whitelist = | 66 return IsExtensionIdWhitelisted(extension->id()); |
| 57 ExtensionsClient::Get()->GetScriptingWhitelist(); | |
| 58 | |
| 59 return std::find(whitelist.begin(), whitelist.end(), extension->id()) != | |
| 60 whitelist.end(); | |
| 61 } | 67 } |
| 62 | 68 |
| 63 // static | 69 // static |
| 64 bool PermissionsData::ScriptsMayRequireActionForExtension( | 70 bool PermissionsData::ScriptsMayRequireActionForExtension( |
| 65 const Extension* extension, | 71 const Extension* extension, |
| 66 const PermissionSet* permissions) { | 72 const PermissionSet* permissions) { |
| 67 // An extension may require user action to execute scripts iff the extension | 73 // An extension may require user action to execute scripts iff the extension |
| 68 // shows up in chrome:extensions (so the user can grant withheld permissions), | 74 // shows up in chrome:extensions (so the user can grant withheld permissions), |
| 69 // is not part of chrome or corporate policy, not on the scripting whitelist, | 75 // is not part of chrome or corporate policy, not on the scripting whitelist, |
| 70 // and requires enough permissions that we should withhold them. | 76 // and requires enough permissions that we should withhold them. |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 return ACCESS_WITHHELD; | 383 return ACCESS_WITHHELD; |
| 378 | 384 |
| 379 if (error) { | 385 if (error) { |
| 380 *error = ErrorUtils::FormatErrorMessage(manifest_errors::kCannotAccessPage, | 386 *error = ErrorUtils::FormatErrorMessage(manifest_errors::kCannotAccessPage, |
| 381 document_url.spec()); | 387 document_url.spec()); |
| 382 } | 388 } |
| 383 return ACCESS_DENIED; | 389 return ACCESS_DENIED; |
| 384 } | 390 } |
| 385 | 391 |
| 386 } // namespace extensions | 392 } // namespace extensions |
| OLD | NEW |