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

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

Issue 13971005: Basic multi-module support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix copyright for presubmit Created 7 years, 7 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
OLDNEW
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/crx_installer.h" 5 #include "chrome/browser/extensions/crx_installer.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 24 matching lines...) Expand all
35 #include "chrome/browser/profiles/profile.h" 35 #include "chrome/browser/profiles/profile.h"
36 #include "chrome/browser/web_applications/web_app.h" 36 #include "chrome/browser/web_applications/web_app.h"
37 #include "chrome/common/chrome_notification_types.h" 37 #include "chrome/common/chrome_notification_types.h"
38 #include "chrome/common/chrome_paths.h" 38 #include "chrome/common/chrome_paths.h"
39 #include "chrome/common/extensions/extension_constants.h" 39 #include "chrome/common/extensions/extension_constants.h"
40 #include "chrome/common/extensions/extension_file_util.h" 40 #include "chrome/common/extensions/extension_file_util.h"
41 #include "chrome/common/extensions/extension_icon_set.h" 41 #include "chrome/common/extensions/extension_icon_set.h"
42 #include "chrome/common/extensions/feature_switch.h" 42 #include "chrome/common/extensions/feature_switch.h"
43 #include "chrome/common/extensions/manifest.h" 43 #include "chrome/common/extensions/manifest.h"
44 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" 44 #include "chrome/common/extensions/manifest_handlers/icons_handler.h"
45 #include "chrome/common/extensions/manifest_handlers/shared_module_info.h"
45 #include "content/public/browser/browser_thread.h" 46 #include "content/public/browser/browser_thread.h"
46 #include "content/public/browser/notification_service.h" 47 #include "content/public/browser/notification_service.h"
47 #include "content/public/browser/resource_dispatcher_host.h" 48 #include "content/public/browser/resource_dispatcher_host.h"
48 #include "content/public/browser/user_metrics.h" 49 #include "content/public/browser/user_metrics.h"
49 #include "grit/chromium_strings.h" 50 #include "grit/chromium_strings.h"
50 #include "grit/generated_resources.h" 51 #include "grit/generated_resources.h"
51 #include "grit/theme_resources.h" 52 #include "grit/theme_resources.h"
52 #include "third_party/skia/include/core/SkBitmap.h" 53 #include "third_party/skia/include/core/SkBitmap.h"
53 #include "ui/base/l10n/l10n_util.h" 54 #include "ui/base/l10n/l10n_util.h"
54 #include "ui/base/resource/resource_bundle.h" 55 #include "ui/base/resource/resource_bundle.h"
55 56
56 #if defined(ENABLE_MANAGED_USERS) 57 #if defined(ENABLE_MANAGED_USERS)
57 #include "chrome/browser/managed_mode/managed_user_service.h" 58 #include "chrome/browser/managed_mode/managed_user_service.h"
58 #include "chrome/browser/managed_mode/managed_user_service_factory.h" 59 #include "chrome/browser/managed_mode/managed_user_service_factory.h"
59 #endif 60 #endif
60 61
61 using content::BrowserThread; 62 using content::BrowserThread;
62 using content::UserMetricsAction; 63 using content::UserMetricsAction;
64 using extensions::SharedModuleInfo;
63 65
64 namespace extensions { 66 namespace extensions {
65 67
66 namespace { 68 namespace {
67 69
68 // Used in histograms; do not change order. 70 // Used in histograms; do not change order.
69 enum OffStoreInstallDecision { 71 enum OffStoreInstallDecision {
70 OnStoreInstall, 72 OnStoreInstall,
71 OffStoreInstallAllowed, 73 OffStoreInstallAllowed,
72 OffStoreInstallDisallowed, 74 OffStoreInstallDisallowed,
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 395
394 if (client_) { 396 if (client_) {
395 IconsInfo::DecodeIcon(extension_.get(), 397 IconsInfo::DecodeIcon(extension_.get(),
396 extension_misc::EXTENSION_ICON_LARGE, 398 extension_misc::EXTENSION_ICON_LARGE,
397 ExtensionIconSet::MATCH_BIGGER, 399 ExtensionIconSet::MATCH_BIGGER,
398 &install_icon_); 400 &install_icon_);
399 } 401 }
400 402
401 if (!BrowserThread::PostTask( 403 if (!BrowserThread::PostTask(
402 BrowserThread::UI, FROM_HERE, 404 BrowserThread::UI, FROM_HERE,
403 base::Bind(&CrxInstaller::CheckRequirements, this))) 405 base::Bind(&CrxInstaller::CheckImportsAndRequirements, this)))
404 NOTREACHED(); 406 NOTREACHED();
405 } 407 }
406 408
407 void CrxInstaller::CheckRequirements() { 409 void CrxInstaller::CheckImportsAndRequirements() {
408 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 410 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
409 if (!frontend_weak_.get() || frontend_weak_->browser_terminating()) 411 if (!frontend_weak_.get() || frontend_weak_->browser_terminating())
410 return; 412 return;
413
414 if (SharedModuleInfo::ImportsModules(extension_)) {
415 const std::vector<SharedModuleInfo::ImportInfo>& imports =
416 SharedModuleInfo::GetImports(extension_);
417 std::vector<SharedModuleInfo::ImportInfo>::const_iterator i;
418 for (i = imports.begin(); i != imports.end(); ++i) {
419 Version version_required(i->minimum_version);
420 const Extension* imported_module =
421 frontend_weak_->GetExtensionById(i->extension_id, true);
422 if (!imported_module ||
423 (version_required.IsValid() &&
424 imported_module->version()->CompareTo(version_required) < 0)) {
425 ReportFailureFromUIThread(
426 CrxInstallerError(l10n_util::GetStringFUTF16(
427 IDS_EXTENSION_INSTALL_DEPENDENCY_NOT_FOUND,
428 ASCIIToUTF16(i->extension_id),
429 ASCIIToUTF16(i->minimum_version))));
430 return;
431 }
432 if (!SharedModuleInfo::IsSharedModule(imported_module)) {
433 ReportFailureFromUIThread(
434 CrxInstallerError(l10n_util::GetStringFUTF16(
435 IDS_EXTENSION_INSTALL_DEPENDENCY_NOT_SHARED_MODULE,
436 ASCIIToUTF16(i->extension_id))));
437 return;
438 }
439 }
440 }
411 AddRef(); // Balanced in OnRequirementsChecked(). 441 AddRef(); // Balanced in OnRequirementsChecked().
412 requirements_checker_->Check(extension_, 442 requirements_checker_->Check(extension_,
413 base::Bind(&CrxInstaller::OnRequirementsChecked, 443 base::Bind(&CrxInstaller::OnRequirementsChecked,
414 this)); 444 this));
415 } 445 }
416 446
417 void CrxInstaller::OnRequirementsChecked( 447 void CrxInstaller::OnRequirementsChecked(
418 std::vector<std::string> requirement_errors) { 448 std::vector<std::string> requirement_errors) {
419 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 449 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
420 Release(); // Balanced in CheckRequirements(). 450 Release(); // Balanced in CheckImportsAndRequirements().
421 if (!requirement_errors.empty()) { 451 if (!requirement_errors.empty()) {
422 if (error_on_unsupported_requirements_) { 452 if (error_on_unsupported_requirements_) {
423 ReportFailureFromUIThread(CrxInstallerError( 453 ReportFailureFromUIThread(CrxInstallerError(
424 UTF8ToUTF16(JoinString(requirement_errors, ' ')))); 454 UTF8ToUTF16(JoinString(requirement_errors, ' '))));
425 return; 455 return;
426 } 456 }
427 has_requirement_errors_ = true; 457 has_requirement_errors_ = true;
428 } 458 }
429 459
430 #if defined(ENABLE_MANAGED_USERS) && !defined(OS_CHROMEOS) 460 #if defined(ENABLE_MANAGED_USERS) && !defined(OS_CHROMEOS)
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 if (!prefs->DidExtensionEscalatePermissions(extension_->id())) 843 if (!prefs->DidExtensionEscalatePermissions(extension_->id()))
814 return; 844 return;
815 845
816 if (client_) { 846 if (client_) {
817 AddRef(); // Balanced in InstallUIProceed() and InstallUIAbort(). 847 AddRef(); // Balanced in InstallUIProceed() and InstallUIAbort().
818 client_->ConfirmReEnable(this, extension_.get()); 848 client_->ConfirmReEnable(this, extension_.get());
819 } 849 }
820 } 850 }
821 851
822 } // namespace extensions 852 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/crx_installer.h ('k') | chrome/browser/extensions/extension_protocols.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698