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/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 Loading... | |
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 Loading... | |
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_)) { | |
Matt Perry
2013/04/25 20:16:31
What if you uninstall a shared module that somethi
elijahtaylor1
2013/04/25 21:01:28
In the final version we had talked about making sh
Matt Perry
2013/04/25 21:07:23
Oh yeah, that's right. Makes sense. Leave as-is.
| |
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 imported_module->version()->CompareTo(version_required) < 0) { | |
424 ReportFailureFromUIThread( | |
425 CrxInstallerError(l10n_util::GetStringFUTF16( | |
426 IDS_EXTENSION_INSTALL_DEPENDENCY_NOT_FOUND, | |
427 ASCIIToUTF16(i->extension_id), | |
428 ASCIIToUTF16(i->minimum_version)))); | |
429 return; | |
430 } | |
431 if (!SharedModuleInfo::IsSharedModule(imported_module)) { | |
432 ReportFailureFromUIThread( | |
433 CrxInstallerError(l10n_util::GetStringFUTF16( | |
434 IDS_EXTENSION_INSTALL_DEPENDENCY_NOT_SHARED_MODULE, | |
435 ASCIIToUTF16(i->extension_id)))); | |
436 return; | |
437 } | |
438 } | |
439 } | |
411 AddRef(); // Balanced in OnRequirementsChecked(). | 440 AddRef(); // Balanced in OnRequirementsChecked(). |
412 requirements_checker_->Check(extension_, | 441 requirements_checker_->Check(extension_, |
413 base::Bind(&CrxInstaller::OnRequirementsChecked, | 442 base::Bind(&CrxInstaller::OnRequirementsChecked, |
414 this)); | 443 this)); |
415 } | 444 } |
416 | 445 |
417 void CrxInstaller::OnRequirementsChecked( | 446 void CrxInstaller::OnRequirementsChecked( |
418 std::vector<std::string> requirement_errors) { | 447 std::vector<std::string> requirement_errors) { |
419 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 448 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
420 Release(); // Balanced in CheckRequirements(). | 449 Release(); // Balanced in CheckImportsAndRequirements(). |
421 if (!requirement_errors.empty()) { | 450 if (!requirement_errors.empty()) { |
422 if (error_on_unsupported_requirements_) { | 451 if (error_on_unsupported_requirements_) { |
423 ReportFailureFromUIThread(CrxInstallerError( | 452 ReportFailureFromUIThread(CrxInstallerError( |
424 UTF8ToUTF16(JoinString(requirement_errors, ' ')))); | 453 UTF8ToUTF16(JoinString(requirement_errors, ' ')))); |
425 return; | 454 return; |
426 } | 455 } |
427 has_requirement_errors_ = true; | 456 has_requirement_errors_ = true; |
428 } | 457 } |
429 | 458 |
430 #if defined(ENABLE_MANAGED_USERS) && !defined(OS_CHROMEOS) | 459 #if defined(ENABLE_MANAGED_USERS) && !defined(OS_CHROMEOS) |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
813 if (!prefs->DidExtensionEscalatePermissions(extension_->id())) | 842 if (!prefs->DidExtensionEscalatePermissions(extension_->id())) |
814 return; | 843 return; |
815 | 844 |
816 if (client_) { | 845 if (client_) { |
817 AddRef(); // Balanced in InstallUIProceed() and InstallUIAbort(). | 846 AddRef(); // Balanced in InstallUIProceed() and InstallUIAbort(). |
818 client_->ConfirmReEnable(this, extension_.get()); | 847 client_->ConfirmReEnable(this, extension_.get()); |
819 } | 848 } |
820 } | 849 } |
821 | 850 |
822 } // namespace extensions | 851 } // namespace extensions |
OLD | NEW |