| 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/files/file_util.h" | 9 #include "base/files/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_management.h" | 14 #include "chrome/browser/extensions/extension_management.h" |
| 15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/extensions/extension_util.h" |
| 16 #include "chrome/browser/extensions/permissions_updater.h" | 17 #include "chrome/browser/extensions/permissions_updater.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/extensions/extension_install_ui_factory.h" | 19 #include "chrome/browser/ui/extensions/extension_install_ui_factory.h" |
| 19 #include "chrome/common/extensions/api/plugins/plugins_handler.h" | 20 #include "chrome/common/extensions/api/plugins/plugins_handler.h" |
| 20 #include "components/crx_file/id_util.h" | 21 #include "components/crx_file/id_util.h" |
| 21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 22 #include "extensions/browser/extension_prefs.h" | 23 #include "extensions/browser/extension_prefs.h" |
| 23 #include "extensions/browser/extension_registry.h" | 24 #include "extensions/browser/extension_registry.h" |
| 24 #include "extensions/browser/install/extension_install_ui.h" | 25 #include "extensions/browser/install/extension_install_ui.h" |
| 25 #include "extensions/browser/install_flag.h" | 26 #include "extensions/browser/install_flag.h" |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 } | 252 } |
| 252 | 253 |
| 253 int UnpackedInstaller::GetFlags() { | 254 int UnpackedInstaller::GetFlags() { |
| 254 std::string id = crx_file::id_util::GenerateIdForPath(extension_path_); | 255 std::string id = crx_file::id_util::GenerateIdForPath(extension_path_); |
| 255 bool allow_file_access = | 256 bool allow_file_access = |
| 256 Manifest::ShouldAlwaysAllowFileAccess(Manifest::UNPACKED); | 257 Manifest::ShouldAlwaysAllowFileAccess(Manifest::UNPACKED); |
| 257 ExtensionPrefs* prefs = ExtensionPrefs::Get(service_weak_->profile()); | 258 ExtensionPrefs* prefs = ExtensionPrefs::Get(service_weak_->profile()); |
| 258 if (prefs->HasAllowFileAccessSetting(id)) | 259 if (prefs->HasAllowFileAccessSetting(id)) |
| 259 allow_file_access = prefs->AllowFileAccess(id); | 260 allow_file_access = prefs->AllowFileAccess(id); |
| 260 | 261 |
| 262 bool installed_by_custodian = |
| 263 extensions::util::WasInstalledByCustodian(id, service_weak_->profile()); |
| 264 |
| 261 int result = Extension::FOLLOW_SYMLINKS_ANYWHERE; | 265 int result = Extension::FOLLOW_SYMLINKS_ANYWHERE; |
| 262 if (allow_file_access) | 266 if (allow_file_access) |
| 263 result |= Extension::ALLOW_FILE_ACCESS; | 267 result |= Extension::ALLOW_FILE_ACCESS; |
| 268 if (installed_by_custodian) |
| 269 result |= Extension::WAS_INSTALLED_BY_CUSTODIAN; |
| 264 if (require_modern_manifest_version_) | 270 if (require_modern_manifest_version_) |
| 265 result |= Extension::REQUIRE_MODERN_MANIFEST_VERSION; | 271 result |= Extension::REQUIRE_MODERN_MANIFEST_VERSION; |
| 266 | 272 |
| 267 return result; | 273 return result; |
| 268 } | 274 } |
| 269 | 275 |
| 270 bool UnpackedInstaller::IsLoadingUnpackedAllowed() const { | 276 bool UnpackedInstaller::IsLoadingUnpackedAllowed() const { |
| 271 if (!service_weak_.get()) | 277 if (!service_weak_.get()) |
| 272 return true; | 278 return true; |
| 273 // If there is a "*" in the extension blacklist, then no extensions should be | 279 // If there is a "*" in the extension blacklist, then no extensions should be |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 service_weak_->OnExtensionInstalled( | 367 service_weak_->OnExtensionInstalled( |
| 362 extension(), syncer::StringOrdinal(), kInstallFlagInstallImmediately); | 368 extension(), syncer::StringOrdinal(), kInstallFlagInstallImmediately); |
| 363 | 369 |
| 364 if (!callback_.is_null()) { | 370 if (!callback_.is_null()) { |
| 365 callback_.Run(extension(), extension_path_, std::string()); | 371 callback_.Run(extension(), extension_path_, std::string()); |
| 366 callback_.Reset(); | 372 callback_.Reset(); |
| 367 } | 373 } |
| 368 } | 374 } |
| 369 | 375 |
| 370 } // namespace extensions | 376 } // namespace extensions |
| OLD | NEW |