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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 int flags, | 468 int flags, |
469 const std::string& explicit_id, | 469 const std::string& explicit_id, |
470 std::string* utf8_error) { | 470 std::string* utf8_error) { |
471 DCHECK(utf8_error); | 471 DCHECK(utf8_error); |
472 string16 error; | 472 string16 error; |
473 scoped_ptr<extensions::Manifest> manifest( | 473 scoped_ptr<extensions::Manifest> manifest( |
474 new extensions::Manifest( | 474 new extensions::Manifest( |
475 location, | 475 location, |
476 scoped_ptr<DictionaryValue>(value.DeepCopy()))); | 476 scoped_ptr<DictionaryValue>(value.DeepCopy()))); |
477 | 477 |
478 if (!InitExtensionID(manifest.get(), path, explicit_id, flags, &error) || | 478 if (!InitExtensionID(manifest.get(), path, explicit_id, flags, &error)) { |
479 !manifest->ValidateManifest(&error)) { | |
480 *utf8_error = UTF16ToUTF8(error); | 479 *utf8_error = UTF16ToUTF8(error); |
481 return NULL; | 480 return NULL; |
482 } | 481 } |
483 | 482 |
| 483 std::vector<std::string> install_warnings; |
| 484 manifest->ValidateManifest(&install_warnings); |
| 485 |
484 scoped_refptr<Extension> extension = new Extension(path, manifest.Pass()); | 486 scoped_refptr<Extension> extension = new Extension(path, manifest.Pass()); |
| 487 extension->install_warnings_.swap(install_warnings); |
| 488 |
485 if (!extension->InitFromValue(flags, &error)) { | 489 if (!extension->InitFromValue(flags, &error)) { |
486 *utf8_error = UTF16ToUTF8(error); | 490 *utf8_error = UTF16ToUTF8(error); |
487 return NULL; | 491 return NULL; |
488 } | 492 } |
489 | 493 |
490 if (extension->is_platform_app()) { | 494 if (extension->is_platform_app()) { |
491 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 495 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
492 switches::kEnablePlatformApps)) { | 496 switches::kEnablePlatformApps)) { |
493 *utf8_error = errors::kPlatformAppFlagRequired; | 497 *utf8_error = errors::kPlatformAppFlagRequired; |
494 return NULL; | 498 return NULL; |
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1871 background_url_ = GetResourceURL(background_str); | 1875 background_url_ = GetResourceURL(background_str); |
1872 } | 1876 } |
1873 | 1877 |
1874 return true; | 1878 return true; |
1875 } | 1879 } |
1876 | 1880 |
1877 bool Extension::LoadBackgroundPersistent( | 1881 bool Extension::LoadBackgroundPersistent( |
1878 const ExtensionAPIPermissionSet& api_permissions, | 1882 const ExtensionAPIPermissionSet& api_permissions, |
1879 string16* error) { | 1883 string16* error) { |
1880 Value* background_persistent = NULL; | 1884 Value* background_persistent = NULL; |
1881 if (!api_permissions.count(ExtensionAPIPermission::kExperimental) || | 1885 if (!manifest_->Get(keys::kBackgroundPersistent, &background_persistent)) |
1882 !manifest_->Get(keys::kBackgroundPersistent, &background_persistent)) | |
1883 return true; | 1886 return true; |
1884 | 1887 |
1885 if (!background_persistent->IsType(Value::TYPE_BOOLEAN) || | 1888 if (!background_persistent->GetAsBoolean(&background_page_is_persistent_)) { |
1886 !background_persistent->GetAsBoolean(&background_page_is_persistent_)) { | |
1887 *error = ASCIIToUTF16(errors::kInvalidBackgroundPersistent); | 1889 *error = ASCIIToUTF16(errors::kInvalidBackgroundPersistent); |
1888 return false; | 1890 return false; |
1889 } | 1891 } |
1890 | 1892 |
1891 if (!has_background_page()) { | 1893 if (!has_background_page()) { |
1892 *error = ASCIIToUTF16(errors::kInvalidBackgroundPersistentNoPage); | 1894 *error = ASCIIToUTF16(errors::kInvalidBackgroundPersistentNoPage); |
1893 return false; | 1895 return false; |
1894 } | 1896 } |
1895 | 1897 |
1896 return true; | 1898 return true; |
(...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3669 already_disabled(false), | 3671 already_disabled(false), |
3670 extension(extension) {} | 3672 extension(extension) {} |
3671 | 3673 |
3672 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3674 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
3673 const Extension* extension, | 3675 const Extension* extension, |
3674 const ExtensionPermissionSet* permissions, | 3676 const ExtensionPermissionSet* permissions, |
3675 Reason reason) | 3677 Reason reason) |
3676 : reason(reason), | 3678 : reason(reason), |
3677 extension(extension), | 3679 extension(extension), |
3678 permissions(permissions) {} | 3680 permissions(permissions) {} |
OLD | NEW |