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/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "base/threading/thread_restrictions.h" | 11 #include "base/threading/thread_restrictions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/extensions/api/runtime/runtime_api.h" | 14 #include "chrome/browser/extensions/api/runtime/runtime_api.h" |
15 #include "chrome/browser/extensions/extension_action_manager.h" | 15 #include "chrome/browser/extensions/extension_action_manager.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/extensions/api/managed_mode_private/managed_mode_handler
.h" | 19 #include "chrome/common/extensions/api/managed_mode_private/managed_mode_handler
.h" |
20 #include "chrome/common/extensions/extension_file_util.h" | |
21 #include "chrome/common/extensions/manifest_url_handler.h" | 20 #include "chrome/common/extensions/manifest_url_handler.h" |
22 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
23 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
24 #include "content/public/browser/user_metrics.h" | 23 #include "content/public/browser/user_metrics.h" |
25 #include "extensions/browser/extension_prefs.h" | 24 #include "extensions/browser/extension_prefs.h" |
26 #include "extensions/browser/extension_registry.h" | 25 #include "extensions/browser/extension_registry.h" |
27 #include "extensions/browser/extension_system.h" | 26 #include "extensions/browser/extension_system.h" |
28 #include "extensions/browser/management_policy.h" | 27 #include "extensions/browser/management_policy.h" |
29 #include "extensions/common/extension.h" | 28 #include "extensions/common/extension.h" |
30 #include "extensions/common/extension_l10n_util.h" | 29 #include "extensions/common/extension_l10n_util.h" |
| 30 #include "extensions/common/file_util.h" |
31 #include "extensions/common/manifest.h" | 31 #include "extensions/common/manifest.h" |
32 #include "extensions/common/manifest_constants.h" | 32 #include "extensions/common/manifest_constants.h" |
33 #include "extensions/common/manifest_handlers/background_info.h" | 33 #include "extensions/common/manifest_handlers/background_info.h" |
34 | 34 |
35 using base::UserMetricsAction; | 35 using base::UserMetricsAction; |
36 using content::BrowserThread; | 36 using content::BrowserThread; |
37 | 37 |
38 namespace extensions { | 38 namespace extensions { |
39 | 39 |
40 namespace errors = manifest_errors; | 40 namespace errors = manifest_errors; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 // Reloading an extension reads files from disk. We do this on the | 210 // Reloading an extension reads files from disk. We do this on the |
211 // UI thread because reloads should be very rare, and the complexity | 211 // UI thread because reloads should be very rare, and the complexity |
212 // added by delaying the time when the extensions service knows about | 212 // added by delaying the time when the extensions service knows about |
213 // all extensions is significant. See crbug.com/37548 for details. | 213 // all extensions is significant. See crbug.com/37548 for details. |
214 // |allow_io| disables tests that file operations run on the file | 214 // |allow_io| disables tests that file operations run on the file |
215 // thread. | 215 // thread. |
216 base::ThreadRestrictions::ScopedAllowIO allow_io; | 216 base::ThreadRestrictions::ScopedAllowIO allow_io; |
217 | 217 |
218 std::string error; | 218 std::string error; |
219 scoped_refptr<const Extension> extension( | 219 scoped_refptr<const Extension> extension( |
220 extension_file_util::LoadExtension( | 220 file_util::LoadExtension(info->extension_path, |
221 info->extension_path, | 221 info->extension_location, |
222 info->extension_location, | 222 GetCreationFlags(info), |
223 GetCreationFlags(info), | 223 &error)); |
224 &error)); | |
225 | 224 |
226 if (!extension.get()) { | 225 if (!extension.get()) { |
227 extension_service_->ReportExtensionLoadError( | 226 extension_service_->ReportExtensionLoadError( |
228 info->extension_path, error, false); | 227 info->extension_path, error, false); |
229 continue; | 228 continue; |
230 } | 229 } |
231 | 230 |
232 extensions_info->at(i)->extension_manifest.reset( | 231 extensions_info->at(i)->extension_manifest.reset( |
233 static_cast<base::DictionaryValue*>( | 232 static_cast<base::DictionaryValue*>( |
234 extension->manifest()->value()->DeepCopy())); | 233 extension->manifest()->value()->DeepCopy())); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { | 477 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { |
479 int flags = extension_prefs_->GetCreationFlags(info->extension_id); | 478 int flags = extension_prefs_->GetCreationFlags(info->extension_id); |
480 if (!Manifest::IsUnpackedLocation(info->extension_location)) | 479 if (!Manifest::IsUnpackedLocation(info->extension_location)) |
481 flags |= Extension::REQUIRE_KEY; | 480 flags |= Extension::REQUIRE_KEY; |
482 if (extension_prefs_->AllowFileAccess(info->extension_id)) | 481 if (extension_prefs_->AllowFileAccess(info->extension_id)) |
483 flags |= Extension::ALLOW_FILE_ACCESS; | 482 flags |= Extension::ALLOW_FILE_ACCESS; |
484 return flags; | 483 return flags; |
485 } | 484 } |
486 | 485 |
487 } // namespace extensions | 486 } // namespace extensions |
OLD | NEW |