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 "chrome/browser/extensions/unpacked_installer.h" | 5 #include "chrome/browser/extensions/unpacked_installer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/threading/thread_restrictions.h" | 11 #include "base/threading/thread_restrictions.h" |
12 #include "chrome/browser/extensions/extension_error_reporter.h" | 12 #include "chrome/browser/extensions/extension_error_reporter.h" |
13 #include "chrome/browser/extensions/extension_install_prompt.h" | 13 #include "chrome/browser/extensions/extension_install_prompt.h" |
14 #include "chrome/browser/extensions/extension_install_ui.h" | 14 #include "chrome/browser/extensions/extension_install_ui.h" |
15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
16 #include "chrome/browser/extensions/permissions_updater.h" | 16 #include "chrome/browser/extensions/permissions_updater.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/common/extensions/api/plugins/plugins_handler.h" | 18 #include "chrome/common/extensions/api/plugins/plugins_handler.h" |
| 19 #include "components/crx_file/id_util.h" |
19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
20 #include "extensions/browser/extension_prefs.h" | 21 #include "extensions/browser/extension_prefs.h" |
21 #include "extensions/browser/extension_registry.h" | 22 #include "extensions/browser/extension_registry.h" |
22 #include "extensions/browser/install_flag.h" | 23 #include "extensions/browser/install_flag.h" |
23 #include "extensions/common/extension.h" | 24 #include "extensions/common/extension.h" |
24 #include "extensions/common/extension_l10n_util.h" | 25 #include "extensions/common/extension_l10n_util.h" |
25 #include "extensions/common/file_util.h" | 26 #include "extensions/common/file_util.h" |
26 #include "extensions/common/id_util.h" | |
27 #include "extensions/common/manifest.h" | 27 #include "extensions/common/manifest.h" |
28 #include "sync/api/string_ordinal.h" | 28 #include "sync/api/string_ordinal.h" |
29 | 29 |
30 using content::BrowserThread; | 30 using content::BrowserThread; |
31 using extensions::Extension; | 31 using extensions::Extension; |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 const char kUnpackedExtensionsBlacklistedError[] = | 35 const char kUnpackedExtensionsBlacklistedError[] = |
36 "Loading of unpacked extensions is disabled by the administrator."; | 36 "Loading of unpacked extensions is disabled by the administrator."; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 if (!install_checker_.requirement_errors().empty()) { | 203 if (!install_checker_.requirement_errors().empty()) { |
204 ReportExtensionLoadError( | 204 ReportExtensionLoadError( |
205 JoinString(install_checker_.requirement_errors(), ' ')); | 205 JoinString(install_checker_.requirement_errors(), ' ')); |
206 return; | 206 return; |
207 } | 207 } |
208 | 208 |
209 InstallExtension(); | 209 InstallExtension(); |
210 } | 210 } |
211 | 211 |
212 int UnpackedInstaller::GetFlags() { | 212 int UnpackedInstaller::GetFlags() { |
213 std::string id = id_util::GenerateIdForPath(extension_path_); | 213 std::string id = crx_file::id_util::GenerateIdForPath(extension_path_); |
214 bool allow_file_access = | 214 bool allow_file_access = |
215 Manifest::ShouldAlwaysAllowFileAccess(Manifest::UNPACKED); | 215 Manifest::ShouldAlwaysAllowFileAccess(Manifest::UNPACKED); |
216 ExtensionPrefs* prefs = ExtensionPrefs::Get(service_weak_->profile()); | 216 ExtensionPrefs* prefs = ExtensionPrefs::Get(service_weak_->profile()); |
217 if (prefs->HasAllowFileAccessSetting(id)) | 217 if (prefs->HasAllowFileAccessSetting(id)) |
218 allow_file_access = prefs->AllowFileAccess(id); | 218 allow_file_access = prefs->AllowFileAccess(id); |
219 | 219 |
220 int result = Extension::FOLLOW_SYMLINKS_ANYWHERE; | 220 int result = Extension::FOLLOW_SYMLINKS_ANYWHERE; |
221 if (allow_file_access) | 221 if (allow_file_access) |
222 result |= Extension::ALLOW_FILE_ACCESS; | 222 result |= Extension::ALLOW_FILE_ACCESS; |
223 if (require_modern_manifest_version_) | 223 if (require_modern_manifest_version_) |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 309 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
310 | 310 |
311 PermissionsUpdater perms_updater(service_weak_->profile()); | 311 PermissionsUpdater perms_updater(service_weak_->profile()); |
312 perms_updater.GrantActivePermissions(extension()); | 312 perms_updater.GrantActivePermissions(extension()); |
313 | 313 |
314 service_weak_->OnExtensionInstalled( | 314 service_weak_->OnExtensionInstalled( |
315 extension(), syncer::StringOrdinal(), kInstallFlagInstallImmediately); | 315 extension(), syncer::StringOrdinal(), kInstallFlagInstallImmediately); |
316 } | 316 } |
317 | 317 |
318 } // namespace extensions | 318 } // namespace extensions |
OLD | NEW |