| 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 "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 int flags, | 459 int flags, |
| 460 const std::string& explicit_id, | 460 const std::string& explicit_id, |
| 461 std::string* utf8_error) { | 461 std::string* utf8_error) { |
| 462 DCHECK(utf8_error); | 462 DCHECK(utf8_error); |
| 463 string16 error; | 463 string16 error; |
| 464 scoped_ptr<extensions::Manifest> manifest( | 464 scoped_ptr<extensions::Manifest> manifest( |
| 465 new extensions::Manifest( | 465 new extensions::Manifest( |
| 466 location, | 466 location, |
| 467 scoped_ptr<DictionaryValue>(value.DeepCopy()))); | 467 scoped_ptr<DictionaryValue>(value.DeepCopy()))); |
| 468 | 468 |
| 469 if (!InitExtensionID(manifest.get(), path, explicit_id, flags, &error) || | 469 if (!InitExtensionID(manifest.get(), path, explicit_id, flags, &error)) { |
| 470 !manifest->ValidateManifest(&error)) { | |
| 471 *utf8_error = UTF16ToUTF8(error); | 470 *utf8_error = UTF16ToUTF8(error); |
| 472 return NULL; | 471 return NULL; |
| 473 } | 472 } |
| 474 | 473 |
| 474 std::vector<std::string> install_warnings; |
| 475 manifest->ValidateManifest(&install_warnings); |
| 476 |
| 475 scoped_refptr<Extension> extension = new Extension(path, manifest.Pass()); | 477 scoped_refptr<Extension> extension = new Extension(path, manifest.Pass()); |
| 478 extension->install_warnings_.swap(install_warnings); |
| 479 |
| 476 if (!extension->InitFromValue(flags, &error)) { | 480 if (!extension->InitFromValue(flags, &error)) { |
| 477 *utf8_error = UTF16ToUTF8(error); | 481 *utf8_error = UTF16ToUTF8(error); |
| 478 return NULL; | 482 return NULL; |
| 479 } | 483 } |
| 480 | 484 |
| 481 if (extension->is_platform_app()) { | 485 if (extension->is_platform_app()) { |
| 482 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 486 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 483 switches::kEnablePlatformApps)) { | 487 switches::kEnablePlatformApps)) { |
| 484 *utf8_error = errors::kPlatformAppFlagRequired; | 488 *utf8_error = errors::kPlatformAppFlagRequired; |
| 485 return NULL; | 489 return NULL; |
| (...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1863 background_url_ = GetResourceURL(background_str); | 1867 background_url_ = GetResourceURL(background_str); |
| 1864 } | 1868 } |
| 1865 | 1869 |
| 1866 return true; | 1870 return true; |
| 1867 } | 1871 } |
| 1868 | 1872 |
| 1869 bool Extension::LoadBackgroundPersistent( | 1873 bool Extension::LoadBackgroundPersistent( |
| 1870 const ExtensionAPIPermissionSet& api_permissions, | 1874 const ExtensionAPIPermissionSet& api_permissions, |
| 1871 string16* error) { | 1875 string16* error) { |
| 1872 Value* background_persistent = NULL; | 1876 Value* background_persistent = NULL; |
| 1873 if (!api_permissions.count(ExtensionAPIPermission::kExperimental) || | 1877 if (!manifest_->Get(keys::kBackgroundPersistent, &background_persistent)) |
| 1874 !manifest_->Get(keys::kBackgroundPersistent, &background_persistent)) | |
| 1875 return true; | 1878 return true; |
| 1876 | 1879 |
| 1877 if (!background_persistent->IsType(Value::TYPE_BOOLEAN) || | 1880 if (!background_persistent->GetAsBoolean(&background_page_is_persistent_)) { |
| 1878 !background_persistent->GetAsBoolean(&background_page_is_persistent_)) { | |
| 1879 *error = ASCIIToUTF16(errors::kInvalidBackgroundPersistent); | 1881 *error = ASCIIToUTF16(errors::kInvalidBackgroundPersistent); |
| 1880 return false; | 1882 return false; |
| 1881 } | 1883 } |
| 1882 | 1884 |
| 1883 if (!has_background_page()) { | 1885 if (!has_background_page()) { |
| 1884 *error = ASCIIToUTF16(errors::kInvalidBackgroundPersistentNoPage); | 1886 *error = ASCIIToUTF16(errors::kInvalidBackgroundPersistentNoPage); |
| 1885 return false; | 1887 return false; |
| 1886 } | 1888 } |
| 1887 | 1889 |
| 1888 return true; | 1890 return true; |
| (...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3647 already_disabled(false), | 3649 already_disabled(false), |
| 3648 extension(extension) {} | 3650 extension(extension) {} |
| 3649 | 3651 |
| 3650 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3652 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
| 3651 const Extension* extension, | 3653 const Extension* extension, |
| 3652 const ExtensionPermissionSet* permissions, | 3654 const ExtensionPermissionSet* permissions, |
| 3653 Reason reason) | 3655 Reason reason) |
| 3654 : reason(reason), | 3656 : reason(reason), |
| 3655 extension(extension), | 3657 extension(extension), |
| 3656 permissions(permissions) {} | 3658 permissions(permissions) {} |
| OLD | NEW |