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/browser/extensions/installed_loader.h" | 5 #include "chrome/browser/extensions/installed_loader.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 : extension_service_(extension_service), | 86 : extension_service_(extension_service), |
87 extension_prefs_(extension_service->extension_prefs()) { | 87 extension_prefs_(extension_service->extension_prefs()) { |
88 } | 88 } |
89 | 89 |
90 InstalledLoader::~InstalledLoader() { | 90 InstalledLoader::~InstalledLoader() { |
91 } | 91 } |
92 | 92 |
93 void InstalledLoader::Load(const ExtensionInfo& info, bool write_to_prefs) { | 93 void InstalledLoader::Load(const ExtensionInfo& info, bool write_to_prefs) { |
94 std::string error; | 94 std::string error; |
95 scoped_refptr<const Extension> extension(NULL); | 95 scoped_refptr<const Extension> extension(NULL); |
96 if (info.extension_manifest.get()) { | 96 if (info.extension_manifest) { |
97 extension = Extension::Create( | 97 extension = Extension::Create( |
98 info.extension_path, | 98 info.extension_path, |
99 info.extension_location, | 99 info.extension_location, |
100 *info.extension_manifest, | 100 *info.extension_manifest, |
101 GetCreationFlags(&info), | 101 GetCreationFlags(&info), |
102 &error); | 102 &error); |
103 } else { | 103 } else { |
104 error = errors::kManifestUnreadable; | 104 error = errors::kManifestUnreadable; |
105 } | 105 } |
106 | 106 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 base::ThreadRestrictions::ScopedAllowIO allow_io; | 199 base::ThreadRestrictions::ScopedAllowIO allow_io; |
200 | 200 |
201 std::string error; | 201 std::string error; |
202 scoped_refptr<const Extension> extension( | 202 scoped_refptr<const Extension> extension( |
203 extension_file_util::LoadExtension( | 203 extension_file_util::LoadExtension( |
204 info->extension_path, | 204 info->extension_path, |
205 info->extension_location, | 205 info->extension_location, |
206 GetCreationFlags(info), | 206 GetCreationFlags(info), |
207 &error)); | 207 &error)); |
208 | 208 |
209 if (!extension.get()) { | 209 if (!extension) { |
210 extension_service_-> | 210 extension_service_-> |
211 ReportExtensionLoadError(info->extension_path, error, false); | 211 ReportExtensionLoadError(info->extension_path, error, false); |
212 continue; | 212 continue; |
213 } | 213 } |
214 | 214 |
215 extensions_info->at(i)->extension_manifest.reset( | 215 extensions_info->at(i)->extension_manifest.reset( |
216 static_cast<DictionaryValue*>( | 216 static_cast<DictionaryValue*>( |
217 extension->manifest()->value()->DeepCopy())); | 217 extension->manifest()->value()->DeepCopy())); |
218 should_write_prefs = true; | 218 should_write_prefs = true; |
219 } | 219 } |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { | 380 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { |
381 int flags = extension_prefs_->GetCreationFlags(info->extension_id); | 381 int flags = extension_prefs_->GetCreationFlags(info->extension_id); |
382 if (!Manifest::IsUnpackedLocation(info->extension_location)) | 382 if (!Manifest::IsUnpackedLocation(info->extension_location)) |
383 flags |= Extension::REQUIRE_KEY; | 383 flags |= Extension::REQUIRE_KEY; |
384 if (extension_prefs_->AllowFileAccess(info->extension_id)) | 384 if (extension_prefs_->AllowFileAccess(info->extension_id)) |
385 flags |= Extension::ALLOW_FILE_ACCESS; | 385 flags |= Extension::ALLOW_FILE_ACCESS; |
386 return flags; | 386 return flags; |
387 } | 387 } |
388 | 388 |
389 } // namespace extensions | 389 } // namespace extensions |
OLD | NEW |