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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // TODO(sungguk): Continue removing std::string errors and replacing | 111 // TODO(sungguk): Continue removing std::string errors and replacing |
112 // with base::string16. See http://crbug.com/71980. | 112 // with base::string16. See http://crbug.com/71980. |
113 scoped_refptr<Extension> Extension::Create(const base::FilePath& path, | 113 scoped_refptr<Extension> Extension::Create(const base::FilePath& path, |
114 Manifest::Location location, | 114 Manifest::Location location, |
115 const base::DictionaryValue& value, | 115 const base::DictionaryValue& value, |
116 int flags, | 116 int flags, |
117 const std::string& explicit_id, | 117 const std::string& explicit_id, |
118 std::string* utf8_error) { | 118 std::string* utf8_error) { |
119 DCHECK(utf8_error); | 119 DCHECK(utf8_error); |
120 base::string16 error; | 120 base::string16 error; |
121 scoped_ptr<extensions::Manifest> manifest( | 121 std::unique_ptr<extensions::Manifest> manifest(new extensions::Manifest( |
122 new extensions::Manifest( | 122 location, std::unique_ptr<base::DictionaryValue>(value.DeepCopy()))); |
123 location, scoped_ptr<base::DictionaryValue>(value.DeepCopy()))); | |
124 | 123 |
125 if (!InitExtensionID(manifest.get(), path, explicit_id, flags, &error)) { | 124 if (!InitExtensionID(manifest.get(), path, explicit_id, flags, &error)) { |
126 *utf8_error = base::UTF16ToUTF8(error); | 125 *utf8_error = base::UTF16ToUTF8(error); |
127 return NULL; | 126 return NULL; |
128 } | 127 } |
129 | 128 |
130 std::vector<InstallWarning> install_warnings; | 129 std::vector<InstallWarning> install_warnings; |
131 if (!manifest->ValidateManifest(utf8_error, &install_warnings)) { | 130 if (!manifest->ValidateManifest(utf8_error, &install_warnings)) { |
132 return NULL; | 131 return NULL; |
133 } | 132 } |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 DCHECK(finished_parsing_manifest_ || thread_checker_.CalledOnValidThread()); | 376 DCHECK(finished_parsing_manifest_ || thread_checker_.CalledOnValidThread()); |
378 ManifestDataMap::const_iterator iter = manifest_data_.find(key); | 377 ManifestDataMap::const_iterator iter = manifest_data_.find(key); |
379 if (iter != manifest_data_.end()) | 378 if (iter != manifest_data_.end()) |
380 return iter->second.get(); | 379 return iter->second.get(); |
381 return NULL; | 380 return NULL; |
382 } | 381 } |
383 | 382 |
384 void Extension::SetManifestData(const std::string& key, | 383 void Extension::SetManifestData(const std::string& key, |
385 Extension::ManifestData* data) { | 384 Extension::ManifestData* data) { |
386 DCHECK(!finished_parsing_manifest_ && thread_checker_.CalledOnValidThread()); | 385 DCHECK(!finished_parsing_manifest_ && thread_checker_.CalledOnValidThread()); |
387 manifest_data_[key] = scoped_ptr<ManifestData>(data); | 386 manifest_data_[key] = std::unique_ptr<ManifestData>(data); |
388 } | 387 } |
389 | 388 |
390 Manifest::Location Extension::location() const { | 389 Manifest::Location Extension::location() const { |
391 return manifest_->location(); | 390 return manifest_->location(); |
392 } | 391 } |
393 | 392 |
394 const std::string& Extension::id() const { | 393 const std::string& Extension::id() const { |
395 return manifest_->extension_id(); | 394 return manifest_->extension_id(); |
396 } | 395 } |
397 | 396 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 if (extension_id.empty()) { | 485 if (extension_id.empty()) { |
487 NOTREACHED() << "Could not create ID from path."; | 486 NOTREACHED() << "Could not create ID from path."; |
488 return false; | 487 return false; |
489 } | 488 } |
490 manifest->set_extension_id(extension_id); | 489 manifest->set_extension_id(extension_id); |
491 return true; | 490 return true; |
492 } | 491 } |
493 } | 492 } |
494 | 493 |
495 Extension::Extension(const base::FilePath& path, | 494 Extension::Extension(const base::FilePath& path, |
496 scoped_ptr<extensions::Manifest> manifest) | 495 std::unique_ptr<extensions::Manifest> manifest) |
497 : manifest_version_(0), | 496 : manifest_version_(0), |
498 converted_from_user_script_(false), | 497 converted_from_user_script_(false), |
499 manifest_(manifest.release()), | 498 manifest_(manifest.release()), |
500 finished_parsing_manifest_(false), | 499 finished_parsing_manifest_(false), |
501 display_in_launcher_(true), | 500 display_in_launcher_(true), |
502 display_in_new_tab_page_(true), | 501 display_in_new_tab_page_(true), |
503 wants_file_access_(false), | 502 wants_file_access_(false), |
504 creation_flags_(0) { | 503 creation_flags_(0) { |
505 DCHECK(path.empty() || path.IsAbsolute()); | 504 DCHECK(path.empty() || path.IsAbsolute()); |
506 path_ = crx_file::id_util::MaybeNormalizePath(path); | 505 path_ = crx_file::id_util::MaybeNormalizePath(path); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 : reason(reason), | 776 : reason(reason), |
778 extension(extension) {} | 777 extension(extension) {} |
779 | 778 |
780 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 779 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
781 const Extension* extension, | 780 const Extension* extension, |
782 const PermissionSet& permissions, | 781 const PermissionSet& permissions, |
783 Reason reason) | 782 Reason reason) |
784 : reason(reason), extension(extension), permissions(permissions) {} | 783 : reason(reason), extension(extension), permissions(permissions) {} |
785 | 784 |
786 } // namespace extensions | 785 } // namespace extensions |
OLD | NEW |