| 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 "chrome/common/extensions/permissions/permissions_data.h" | 5 #include "chrome/common/extensions/permissions/permissions_data.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
| 15 #include "chrome/common/extensions/extension_manifest_constants.h" | 15 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 16 #include "chrome/common/extensions/features/base_feature_provider.h" | 16 #include "chrome/common/extensions/features/base_feature_provider.h" |
| 17 #include "chrome/common/extensions/permissions/api_permission_set.h" | 17 #include "chrome/common/extensions/permissions/api_permission_set.h" |
| 18 #include "chrome/common/extensions/permissions/chrome_scheme_hosts.h" | 18 #include "chrome/common/extensions/permissions/chrome_scheme_hosts.h" |
| 19 #include "chrome/common/extensions/permissions/permission_set.h" | 19 #include "chrome/common/extensions/permissions/permission_set.h" |
| 20 #include "chrome/common/extensions/permissions/permissions_info.h" | 20 #include "chrome/common/extensions/permissions/permissions_info.h" |
| 21 #include "content/public/common/url_constants.h" | 21 #include "content/public/common/url_constants.h" |
| 22 #include "extensions/common/constants.h" | 22 #include "extensions/common/constants.h" |
| 23 #include "extensions/common/error_utils.h" | 23 #include "extensions/common/error_utils.h" |
| 24 #include "extensions/common/features/feature.h" | 24 #include "extensions/common/features/feature.h" |
| 25 #include "extensions/common/manifest.h" | 25 #include "extensions/common/manifest.h" |
| 26 #include "extensions/common/manifest_constants.h" |
| 26 #include "extensions/common/switches.h" | 27 #include "extensions/common/switches.h" |
| 27 #include "extensions/common/url_pattern_set.h" | 28 #include "extensions/common/url_pattern_set.h" |
| 28 #include "extensions/common/user_script.h" | 29 #include "extensions/common/user_script.h" |
| 29 #include "url/gurl.h" | 30 #include "url/gurl.h" |
| 30 | 31 |
| 31 namespace keys = extensions::manifest_keys; | 32 namespace keys = extensions::manifest_keys; |
| 32 namespace errors = extension_manifest_errors; | 33 namespace errors = extension_manifest_errors; |
| 33 | 34 |
| 34 namespace extensions { | 35 namespace extensions { |
| 35 | 36 |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 // chrome://thumbnail, so add them back in to host_permissions separately. | 225 // chrome://thumbnail, so add them back in to host_permissions separately. |
| 225 if (pattern.match_all_urls()) | 226 if (pattern.match_all_urls()) |
| 226 host_permissions->AddPatterns(GetPermittedChromeSchemeHosts( | 227 host_permissions->AddPatterns(GetPermittedChromeSchemeHosts( |
| 227 extension, *api_permissions)); | 228 extension, *api_permissions)); |
| 228 continue; | 229 continue; |
| 229 } | 230 } |
| 230 | 231 |
| 231 // It's probably an unknown API permission. Do not throw an error so | 232 // It's probably an unknown API permission. Do not throw an error so |
| 232 // extensions can retain backwards compatability (http://crbug.com/42742). | 233 // extensions can retain backwards compatability (http://crbug.com/42742). |
| 233 extension->AddInstallWarning(InstallWarning( | 234 extension->AddInstallWarning(InstallWarning( |
| 234 base::StringPrintf( | 235 ErrorUtils::FormatErrorMessage( |
| 235 "Permission '%s' is unknown or URL pattern is malformed.", | 236 manifest_errors::kPermissionUnknownOrMalformed, |
| 236 permission_str.c_str()), | 237 permission_str), |
| 237 key, | 238 key, |
| 238 permission_str)); | 239 permission_str)); |
| 239 } | 240 } |
| 240 | 241 |
| 241 return true; | 242 return true; |
| 242 } | 243 } |
| 243 | 244 |
| 244 // Returns true if this extension id is from a trusted provider. | 245 // Returns true if this extension id is from a trusted provider. |
| 245 bool IsTrustedId(const std::string& extension_id) { | 246 bool IsTrustedId(const std::string& extension_id) { |
| 246 // See http://b/4946060 for more details. | 247 // See http://b/4946060 for more details. |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 optional_permission_set_ = new PermissionSet( | 636 optional_permission_set_ = new PermissionSet( |
| 636 initial_optional_permissions_->api_permissions, | 637 initial_optional_permissions_->api_permissions, |
| 637 initial_optional_permissions_->host_permissions, | 638 initial_optional_permissions_->host_permissions, |
| 638 URLPatternSet()); | 639 URLPatternSet()); |
| 639 | 640 |
| 640 initial_required_permissions_.reset(); | 641 initial_required_permissions_.reset(); |
| 641 initial_optional_permissions_.reset(); | 642 initial_optional_permissions_.reset(); |
| 642 } | 643 } |
| 643 | 644 |
| 644 } // namespace extensions | 645 } // namespace extensions |
| OLD | NEW |