Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: chrome/browser/extensions/unpacked_installer.cc

Issue 2783813002: Move ChromeRequirementsChecker to //extensions as a PreloadCheck (Closed)
Patch Set: rebase? Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/extensions/requirements_checker_browsertest.cc ('k') | chrome/common/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/strings/string16.h"
11 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h"
12 #include "base/threading/thread_restrictions.h" 14 #include "base/threading/thread_restrictions.h"
13 #include "chrome/browser/extensions/extension_error_reporter.h" 15 #include "chrome/browser/extensions/extension_error_reporter.h"
14 #include "chrome/browser/extensions/extension_install_checker.h" 16 #include "chrome/browser/extensions/extension_install_checker.h"
15 #include "chrome/browser/extensions/extension_install_prompt.h" 17 #include "chrome/browser/extensions/extension_install_prompt.h"
16 #include "chrome/browser/extensions/extension_management.h" 18 #include "chrome/browser/extensions/extension_management.h"
17 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
18 #include "chrome/browser/extensions/permissions_updater.h" 20 #include "chrome/browser/extensions/permissions_updater.h"
19 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/ui/extensions/extension_install_ui_factory.h" 22 #include "chrome/browser/ui/extensions/extension_install_ui_factory.h"
21 #include "chrome/common/extensions/api/plugins/plugins_handler.h"
22 #include "components/crx_file/id_util.h" 23 #include "components/crx_file/id_util.h"
23 #include "components/sync/model/string_ordinal.h" 24 #include "components/sync/model/string_ordinal.h"
24 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
25 #include "extensions/browser/extension_prefs.h" 26 #include "extensions/browser/extension_prefs.h"
26 #include "extensions/browser/extension_registry.h" 27 #include "extensions/browser/extension_registry.h"
27 #include "extensions/browser/install/extension_install_ui.h" 28 #include "extensions/browser/install/extension_install_ui.h"
28 #include "extensions/browser/install_flag.h" 29 #include "extensions/browser/install_flag.h"
29 #include "extensions/common/extension.h" 30 #include "extensions/common/extension.h"
30 #include "extensions/common/extension_l10n_util.h" 31 #include "extensions/common/extension_l10n_util.h"
31 #include "extensions/common/file_util.h" 32 #include "extensions/common/file_util.h"
32 #include "extensions/common/manifest.h" 33 #include "extensions/common/manifest.h"
34 #include "extensions/common/manifest_handlers/plugins_handler.h"
33 #include "extensions/common/manifest_handlers/shared_module_info.h" 35 #include "extensions/common/manifest_handlers/shared_module_info.h"
34 #include "extensions/common/permissions/permissions_data.h" 36 #include "extensions/common/permissions/permissions_data.h"
35 37
36 using content::BrowserThread; 38 using content::BrowserThread;
37 using extensions::Extension; 39 using extensions::Extension;
38 using extensions::SharedModuleInfo; 40 using extensions::SharedModuleInfo;
39 41
40 namespace { 42 namespace {
41 43
42 const char kUnpackedExtensionsBlacklistedError[] = 44 const char kUnpackedExtensionsBlacklistedError[] =
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 ExtensionInstallChecker::CHECK_REQUIREMENTS | 248 ExtensionInstallChecker::CHECK_REQUIREMENTS |
247 ExtensionInstallChecker::CHECK_MANAGEMENT_POLICY, 249 ExtensionInstallChecker::CHECK_MANAGEMENT_POLICY,
248 true /* fail fast */); 250 true /* fail fast */);
249 install_checker_->Start( 251 install_checker_->Start(
250 base::Bind(&UnpackedInstaller::OnInstallChecksComplete, this)); 252 base::Bind(&UnpackedInstaller::OnInstallChecksComplete, this));
251 } 253 }
252 254
253 void UnpackedInstaller::OnInstallChecksComplete(int failed_checks) { 255 void UnpackedInstaller::OnInstallChecksComplete(int failed_checks) {
254 DCHECK_CURRENTLY_ON(BrowserThread::UI); 256 DCHECK_CURRENTLY_ON(BrowserThread::UI);
255 257
256 if (!install_checker_->policy_error().empty()) { 258 base::string16 error_message = install_checker_->policy_error();
257 ReportExtensionLoadError(install_checker_->policy_error()); 259 if (error_message.empty())
260 error_message = install_checker_->requirements_error_message();
261
262 if (!error_message.empty()) {
263 ReportExtensionLoadError(base::UTF16ToUTF8(error_message));
258 return; 264 return;
259 } 265 }
260 266
261 if (!install_checker_->requirement_errors().empty()) {
262 ReportExtensionLoadError(
263 base::JoinString(install_checker_->requirement_errors(), " "));
264 return;
265 }
266
267 InstallExtension(); 267 InstallExtension();
268 } 268 }
269 269
270 int UnpackedInstaller::GetFlags() { 270 int UnpackedInstaller::GetFlags() {
271 std::string id = crx_file::id_util::GenerateIdForPath(extension_path_); 271 std::string id = crx_file::id_util::GenerateIdForPath(extension_path_);
272 bool allow_file_access = 272 bool allow_file_access =
273 Manifest::ShouldAlwaysAllowFileAccess(Manifest::UNPACKED); 273 Manifest::ShouldAlwaysAllowFileAccess(Manifest::UNPACKED);
274 ExtensionPrefs* prefs = ExtensionPrefs::Get(service_weak_->profile()); 274 ExtensionPrefs* prefs = ExtensionPrefs::Get(service_weak_->profile());
275 if (prefs->HasAllowFileAccessSetting(id)) 275 if (prefs->HasAllowFileAccessSetting(id))
276 allow_file_access = prefs->AllowFileAccess(id); 276 allow_file_access = prefs->AllowFileAccess(id);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 service_weak_->OnExtensionInstalled( 382 service_weak_->OnExtensionInstalled(
383 extension(), syncer::StringOrdinal(), kInstallFlagInstallImmediately); 383 extension(), syncer::StringOrdinal(), kInstallFlagInstallImmediately);
384 384
385 if (!callback_.is_null()) { 385 if (!callback_.is_null()) {
386 callback_.Run(extension(), extension_path_, std::string()); 386 callback_.Run(extension(), extension_path_, std::string());
387 callback_.Reset(); 387 callback_.Reset();
388 } 388 }
389 } 389 }
390 390
391 } // namespace extensions 391 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/requirements_checker_browsertest.cc ('k') | chrome/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698