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

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

Issue 273193006: Install Chrome OS apps to shared location (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added multi-profile support Created 6 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 | Annotate | Revision Log
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/extension_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <set> 9 #include <set>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/threading/sequenced_worker_pool.h" 16 #include "base/threading/sequenced_worker_pool.h"
17 #include "base/threading/thread_restrictions.h" 17 #include "base/threading/thread_restrictions.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/chrome_notification_types.h" 20 #include "chrome/browser/chrome_notification_types.h"
21 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 21 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
22 #include "chrome/browser/extensions/component_loader.h" 22 #include "chrome/browser/extensions/component_loader.h"
23 #include "chrome/browser/extensions/crx_installer.h" 23 #include "chrome/browser/extensions/crx_installer.h"
24 #include "chrome/browser/extensions/data_deleter.h" 24 #include "chrome/browser/extensions/data_deleter.h"
25 #include "chrome/browser/extensions/extension_assets_manager.h"
25 #include "chrome/browser/extensions/extension_disabled_ui.h" 26 #include "chrome/browser/extensions/extension_disabled_ui.h"
26 #include "chrome/browser/extensions/extension_error_controller.h" 27 #include "chrome/browser/extensions/extension_error_controller.h"
27 #include "chrome/browser/extensions/extension_install_ui.h" 28 #include "chrome/browser/extensions/extension_install_ui.h"
28 #include "chrome/browser/extensions/extension_special_storage_policy.h" 29 #include "chrome/browser/extensions/extension_special_storage_policy.h"
29 #include "chrome/browser/extensions/extension_sync_service.h" 30 #include "chrome/browser/extensions/extension_sync_service.h"
30 #include "chrome/browser/extensions/extension_util.h" 31 #include "chrome/browser/extensions/extension_util.h"
31 #include "chrome/browser/extensions/external_install_ui.h" 32 #include "chrome/browser/extensions/external_install_ui.h"
32 #include "chrome/browser/extensions/external_provider_impl.h" 33 #include "chrome/browser/extensions/external_provider_impl.h"
33 #include "chrome/browser/extensions/install_verifier.h" 34 #include "chrome/browser/extensions/install_verifier.h"
34 #include "chrome/browser/extensions/installed_loader.h" 35 #include "chrome/browser/extensions/installed_loader.h"
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 "Extensions.Permissions_Uninstall"); 724 "Extensions.Permissions_Uninstall");
724 725
725 // Unload before doing more cleanup to ensure that nothing is hanging on to 726 // Unload before doing more cleanup to ensure that nothing is hanging on to
726 // any of these resources. 727 // any of these resources.
727 UnloadExtension(extension_id, UnloadedExtensionInfo::REASON_UNINSTALL); 728 UnloadExtension(extension_id, UnloadedExtensionInfo::REASON_UNINSTALL);
728 729
729 // Tell the backend to start deleting installed extensions on the file thread. 730 // Tell the backend to start deleting installed extensions on the file thread.
730 if (!Manifest::IsUnpackedLocation(extension->location())) { 731 if (!Manifest::IsUnpackedLocation(extension->location())) {
731 if (!GetFileTaskRunner()->PostTask( 732 if (!GetFileTaskRunner()->PostTask(
732 FROM_HERE, 733 FROM_HERE,
733 base::Bind(&extensions::file_util::UninstallExtension, 734 base::Bind(&ExtensionService::UninstallExtensionOnFileThread,
735 extension_id,
736 profile_,
734 install_directory_, 737 install_directory_,
735 extension_id))) 738 extension->path())))
736 NOTREACHED(); 739 NOTREACHED();
737 } 740 }
738 741
739 // Do not remove the data of ephemeral apps. They will be garbage collected by 742 // Do not remove the data of ephemeral apps. They will be garbage collected by
740 // EphemeralAppService. 743 // EphemeralAppService.
741 if (!extension->is_ephemeral()) 744 if (!extension->is_ephemeral())
742 extensions::DataDeleter::StartDeleting(profile_, extension.get()); 745 extensions::DataDeleter::StartDeleting(profile_, extension.get());
743 746
744 UntrackTerminatedExtension(extension_id); 747 UntrackTerminatedExtension(extension_id);
745 748
(...skipping 12 matching lines...) Expand all
758 761
759 extension_prefs_->OnExtensionUninstalled(extension_id, extension->location(), 762 extension_prefs_->OnExtensionUninstalled(extension_id, extension->location(),
760 external_uninstall); 763 external_uninstall);
761 764
762 // Track the uninstallation. 765 // Track the uninstallation.
763 UMA_HISTOGRAM_ENUMERATION("Extensions.ExtensionUninstalled", 1, 2); 766 UMA_HISTOGRAM_ENUMERATION("Extensions.ExtensionUninstalled", 1, 2);
764 767
765 return true; 768 return true;
766 } 769 }
767 770
771 // static
772 void ExtensionService::UninstallExtensionOnFileThread(
773 const std::string& id,
774 Profile* profile,
775 const base::FilePath& install_dir,
776 const base::FilePath& extension_path) {
777 extensions::ExtensionAssetsManager* assets_manager =
778 extensions::ExtensionAssetsManager::GetInstance();
779 assets_manager->UninstallExtension(id, profile, install_dir, extension_path);
780 }
781
768 bool ExtensionService::IsExtensionEnabled( 782 bool ExtensionService::IsExtensionEnabled(
769 const std::string& extension_id) const { 783 const std::string& extension_id) const {
770 if (registry_->enabled_extensions().Contains(extension_id) || 784 if (registry_->enabled_extensions().Contains(extension_id) ||
771 registry_->terminated_extensions().Contains(extension_id)) { 785 registry_->terminated_extensions().Contains(extension_id)) {
772 return true; 786 return true;
773 } 787 }
774 788
775 if (registry_->disabled_extensions().Contains(extension_id) || 789 if (registry_->disabled_extensions().Contains(extension_id) ||
776 registry_->blacklisted_extensions().Contains(extension_id)) { 790 registry_->blacklisted_extensions().Contains(extension_id)) {
777 return false; 791 return false;
(...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after
2437 } 2451 }
2438 2452
2439 void ExtensionService::OnProfileDestructionStarted() { 2453 void ExtensionService::OnProfileDestructionStarted() {
2440 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); 2454 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2441 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); 2455 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2442 it != ids_to_unload.end(); 2456 it != ids_to_unload.end();
2443 ++it) { 2457 ++it) {
2444 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); 2458 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2445 } 2459 }
2446 } 2460 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698