| 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/extension.h" | 5 #include "extensions/common/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/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 const std::string& explicit_id, | 107 const std::string& explicit_id, |
| 108 std::string* utf8_error) { | 108 std::string* utf8_error) { |
| 109 DCHECK(utf8_error); | 109 DCHECK(utf8_error); |
| 110 base::string16 error; | 110 base::string16 error; |
| 111 scoped_ptr<extensions::Manifest> manifest( | 111 scoped_ptr<extensions::Manifest> manifest( |
| 112 new extensions::Manifest( | 112 new extensions::Manifest( |
| 113 location, scoped_ptr<base::DictionaryValue>(value.DeepCopy()))); | 113 location, scoped_ptr<base::DictionaryValue>(value.DeepCopy()))); |
| 114 | 114 |
| 115 if (!InitExtensionID(manifest.get(), path, explicit_id, flags, &error)) { | 115 if (!InitExtensionID(manifest.get(), path, explicit_id, flags, &error)) { |
| 116 *utf8_error = base::UTF16ToUTF8(error); | 116 *utf8_error = base::UTF16ToUTF8(error); |
| 117 return NULL; | 117 return nullptr; |
| 118 } | 118 } |
| 119 | 119 |
| 120 std::vector<InstallWarning> install_warnings; | 120 std::vector<InstallWarning> install_warnings; |
| 121 if (!manifest->ValidateManifest(utf8_error, &install_warnings)) { | 121 if (!manifest->ValidateManifest(utf8_error, &install_warnings)) { |
| 122 return NULL; | 122 return nullptr; |
| 123 } | 123 } |
| 124 | 124 |
| 125 scoped_refptr<Extension> extension = new Extension(path, manifest.Pass()); | 125 scoped_refptr<Extension> extension = new Extension(path, manifest.Pass()); |
| 126 extension->install_warnings_.swap(install_warnings); | 126 extension->install_warnings_.swap(install_warnings); |
| 127 | 127 |
| 128 if (!extension->InitFromValue(flags, &error)) { | 128 if (!extension->InitFromValue(flags, &error)) { |
| 129 *utf8_error = base::UTF16ToUTF8(error); | 129 *utf8_error = base::UTF16ToUTF8(error); |
| 130 return NULL; | 130 return nullptr; |
| 131 } | 131 } |
| 132 | 132 |
| 133 return extension; | 133 return extension; |
| 134 } | 134 } |
| 135 | 135 |
| 136 Manifest::Type Extension::GetType() const { | 136 Manifest::Type Extension::GetType() const { |
| 137 return converted_from_user_script() ? | 137 return converted_from_user_script() ? |
| 138 Manifest::TYPE_USER_SCRIPT : manifest_->type(); | 138 Manifest::TYPE_USER_SCRIPT : manifest_->type(); |
| 139 } | 139 } |
| 140 | 140 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 356 |
| 357 return false; | 357 return false; |
| 358 } | 358 } |
| 359 | 359 |
| 360 Extension::ManifestData* Extension::GetManifestData(const std::string& key) | 360 Extension::ManifestData* Extension::GetManifestData(const std::string& key) |
| 361 const { | 361 const { |
| 362 DCHECK(finished_parsing_manifest_ || thread_checker_.CalledOnValidThread()); | 362 DCHECK(finished_parsing_manifest_ || thread_checker_.CalledOnValidThread()); |
| 363 ManifestDataMap::const_iterator iter = manifest_data_.find(key); | 363 ManifestDataMap::const_iterator iter = manifest_data_.find(key); |
| 364 if (iter != manifest_data_.end()) | 364 if (iter != manifest_data_.end()) |
| 365 return iter->second.get(); | 365 return iter->second.get(); |
| 366 return NULL; | 366 return nullptr; |
| 367 } | 367 } |
| 368 | 368 |
| 369 void Extension::SetManifestData(const std::string& key, | 369 void Extension::SetManifestData(const std::string& key, |
| 370 Extension::ManifestData* data) { | 370 Extension::ManifestData* data) { |
| 371 DCHECK(!finished_parsing_manifest_ && thread_checker_.CalledOnValidThread()); | 371 DCHECK(!finished_parsing_manifest_ && thread_checker_.CalledOnValidThread()); |
| 372 manifest_data_[key] = linked_ptr<ManifestData>(data); | 372 manifest_data_[key] = linked_ptr<ManifestData>(data); |
| 373 } | 373 } |
| 374 | 374 |
| 375 Manifest::Location Extension::location() const { | 375 Manifest::Location Extension::location() const { |
| 376 return manifest_->location(); | 376 return manifest_->location(); |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 display_in_new_tab_page_ = display_in_launcher_; | 593 display_in_new_tab_page_ = display_in_launcher_; |
| 594 } | 594 } |
| 595 return true; | 595 return true; |
| 596 } | 596 } |
| 597 | 597 |
| 598 bool Extension::LoadExtent(const char* key, | 598 bool Extension::LoadExtent(const char* key, |
| 599 URLPatternSet* extent, | 599 URLPatternSet* extent, |
| 600 const char* list_error, | 600 const char* list_error, |
| 601 const char* value_error, | 601 const char* value_error, |
| 602 base::string16* error) { | 602 base::string16* error) { |
| 603 const base::Value* temp_pattern_value = NULL; | 603 const base::Value* temp_pattern_value = nullptr; |
| 604 if (!manifest_->Get(key, &temp_pattern_value)) | 604 if (!manifest_->Get(key, &temp_pattern_value)) |
| 605 return true; | 605 return true; |
| 606 | 606 |
| 607 const base::ListValue* pattern_list = NULL; | 607 const base::ListValue* pattern_list = nullptr; |
| 608 if (!temp_pattern_value->GetAsList(&pattern_list)) { | 608 if (!temp_pattern_value->GetAsList(&pattern_list)) { |
| 609 *error = base::ASCIIToUTF16(list_error); | 609 *error = base::ASCIIToUTF16(list_error); |
| 610 return false; | 610 return false; |
| 611 } | 611 } |
| 612 | 612 |
| 613 for (size_t i = 0; i < pattern_list->GetSize(); ++i) { | 613 for (size_t i = 0; i < pattern_list->GetSize(); ++i) { |
| 614 std::string pattern_string; | 614 std::string pattern_string; |
| 615 if (!pattern_list->GetString(i, &pattern_string)) { | 615 if (!pattern_list->GetString(i, &pattern_string)) { |
| 616 *error = ErrorUtils::FormatErrorMessageUTF16(value_error, | 616 *error = ErrorUtils::FormatErrorMessageUTF16(value_error, |
| 617 base::UintToString(i), | 617 base::UintToString(i), |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 | 763 |
| 764 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 764 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
| 765 const Extension* extension, | 765 const Extension* extension, |
| 766 const PermissionSet* permissions, | 766 const PermissionSet* permissions, |
| 767 Reason reason) | 767 Reason reason) |
| 768 : reason(reason), | 768 : reason(reason), |
| 769 extension(extension), | 769 extension(extension), |
| 770 permissions(permissions) {} | 770 permissions(permissions) {} |
| 771 | 771 |
| 772 } // namespace extensions | 772 } // namespace extensions |
| OLD | NEW |