| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
| 17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
| 18 #include "base/string16.h" | 18 #include "base/string16.h" |
| 19 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
| 20 #include "base/string_piece.h" | 20 #include "base/string_piece.h" |
| 21 #include "base/string_split.h" | 21 #include "base/string_split.h" |
| 22 #include "base/string_util.h" | 22 #include "base/string_util.h" |
| 23 #include "base/utf_string_conversions.h" | 23 #include "base/utf_string_conversions.h" |
| 24 #include "base/values.h" | 24 #include "base/values.h" |
| 25 #include "base/version.h" | 25 #include "base/version.h" |
| 26 #include "crypto/sha2.h" | |
| 27 #include "chrome/common/chrome_constants.h" | 26 #include "chrome/common/chrome_constants.h" |
| 28 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
| 29 #include "chrome/common/chrome_version_info.h" | 28 #include "chrome/common/chrome_version_info.h" |
| 30 #include "chrome/common/extensions/csp_validator.h" | 29 #include "chrome/common/extensions/csp_validator.h" |
| 31 #include "chrome/common/extensions/extension_action.h" | 30 #include "chrome/common/extensions/extension_action.h" |
| 32 #include "chrome/common/extensions/extension_manifest_constants.h" | 31 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 33 #include "chrome/common/extensions/extension_error_utils.h" | 32 #include "chrome/common/extensions/extension_error_utils.h" |
| 34 #include "chrome/common/extensions/extension_resource.h" | 33 #include "chrome/common/extensions/extension_resource.h" |
| 35 #include "chrome/common/extensions/feature.h" | 34 #include "chrome/common/extensions/feature.h" |
| 36 #include "chrome/common/extensions/file_browser_handler.h" | 35 #include "chrome/common/extensions/file_browser_handler.h" |
| 37 #include "chrome/common/extensions/manifest.h" | 36 #include "chrome/common/extensions/manifest.h" |
| 38 #include "chrome/common/extensions/simple_feature_provider.h" | 37 #include "chrome/common/extensions/simple_feature_provider.h" |
| 39 #include "chrome/common/extensions/user_script.h" | 38 #include "chrome/common/extensions/user_script.h" |
| 40 #include "chrome/common/url_constants.h" | 39 #include "chrome/common/url_constants.h" |
| 40 #include "crypto/sha2.h" |
| 41 #include "googleurl/src/url_util.h" | 41 #include "googleurl/src/url_util.h" |
| 42 #include "grit/chromium_strings.h" | 42 #include "grit/chromium_strings.h" |
| 43 #include "grit/generated_resources.h" | 43 #include "grit/generated_resources.h" |
| 44 #include "grit/theme_resources.h" | 44 #include "grit/theme_resources.h" |
| 45 #include "net/base/registry_controlled_domain.h" | 45 #include "net/base/registry_controlled_domain.h" |
| 46 #include "third_party/skia/include/core/SkBitmap.h" | 46 #include "third_party/skia/include/core/SkBitmap.h" |
| 47 #include "ui/base/keycodes/keyboard_codes.h" | 47 #include "ui/base/keycodes/keyboard_codes.h" |
| 48 #include "ui/base/l10n/l10n_util.h" | 48 #include "ui/base/l10n/l10n_util.h" |
| 49 #include "ui/base/resource/resource_bundle.h" | 49 #include "ui/base/resource/resource_bundle.h" |
| 50 #include "webkit/glue/image_decoder.h" | 50 #include "webkit/glue/image_decoder.h" |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 *utf8_error = UTF16ToUTF8(error); | 373 *utf8_error = UTF16ToUTF8(error); |
| 374 return NULL; | 374 return NULL; |
| 375 } | 375 } |
| 376 | 376 |
| 377 scoped_refptr<Extension> extension = new Extension(path, manifest.Pass()); | 377 scoped_refptr<Extension> extension = new Extension(path, manifest.Pass()); |
| 378 if (!extension->InitFromValue(flags, &error)) { | 378 if (!extension->InitFromValue(flags, &error)) { |
| 379 *utf8_error = UTF16ToUTF8(error); | 379 *utf8_error = UTF16ToUTF8(error); |
| 380 return NULL; | 380 return NULL; |
| 381 } | 381 } |
| 382 | 382 |
| 383 if (extension->is_platform_app() && |
| 384 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 385 switches::kEnablePlatformApps)) { |
| 386 *utf8_error = errors::kPlatformAppFlagRequired; |
| 387 return NULL; |
| 388 } |
| 389 |
| 383 return extension; | 390 return extension; |
| 384 } | 391 } |
| 385 | 392 |
| 386 // static | 393 // static |
| 387 Extension::Location Extension::GetHigherPriorityLocation( | 394 Extension::Location Extension::GetHigherPriorityLocation( |
| 388 Extension::Location loc1, Extension::Location loc2) { | 395 Extension::Location loc1, Extension::Location loc2) { |
| 389 if (loc1 == loc2) | 396 if (loc1 == loc2) |
| 390 return loc1; | 397 return loc1; |
| 391 | 398 |
| 392 int loc1_rank = GetLocationRank(loc1); | 399 int loc1_rank = GetLocationRank(loc1); |
| (...skipping 3137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3530 already_disabled(false), | 3537 already_disabled(false), |
| 3531 extension(extension) {} | 3538 extension(extension) {} |
| 3532 | 3539 |
| 3533 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3540 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
| 3534 const Extension* extension, | 3541 const Extension* extension, |
| 3535 const ExtensionPermissionSet* permissions, | 3542 const ExtensionPermissionSet* permissions, |
| 3536 Reason reason) | 3543 Reason reason) |
| 3537 : reason(reason), | 3544 : reason(reason), |
| 3538 extension(extension), | 3545 extension(extension), |
| 3539 permissions(permissions) {} | 3546 permissions(permissions) {} |
| OLD | NEW |