Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/extensions/extension_assets_manager.h" | |
| 6 | |
| 7 #include "base/memory/singleton.h" | |
| 8 #include "extensions/common/extension.h" | |
| 9 #include "extensions/common/file_util.h" | |
| 10 | |
| 11 #if defined(OS_CHROMEOS) | |
| 12 #include "chrome/browser/extensions/extension_assets_manager_chromeos.h" | |
| 13 #endif | |
| 14 | |
| 15 namespace extensions { | |
| 16 namespace { | |
| 17 | |
| 18 class ExtensionAssetsManagerImpl : public ExtensionAssetsManager { | |
| 19 public: | |
| 20 // Copy extension assets to final location. This location could be under | |
| 21 // |local_install_dir| or some common location shared for multiple users. | |
|
asargent_no_longer_on_chrome
2014/05/20 21:20:25
looks like this comment is out of date?
Dmitry Polukhin
2014/05/20 23:42:16
Done.
| |
| 22 virtual void InstallExtension(const Extension* extension, | |
| 23 const base::FilePath& unpacked_extension_root, | |
| 24 const base::FilePath& local_install_dir, | |
| 25 Profile* profile, | |
| 26 InstallExtensionCallback callback) OVERRIDE { | |
| 27 callback.Run(file_util::InstallExtension( | |
| 28 unpacked_extension_root, | |
| 29 extension->id(), | |
| 30 extension->VersionString(), | |
| 31 local_install_dir)); | |
| 32 } | |
| 33 | |
| 34 // Remove extension assets if it is not used by anyone else. | |
| 35 virtual void UninstallExtension( | |
| 36 const std::string& id, | |
| 37 Profile* profile, | |
| 38 const base::FilePath& local_install_dir, | |
| 39 const base::FilePath& extension_root) OVERRIDE { | |
| 40 file_util::UninstallExtension(local_install_dir, id); | |
| 41 } | |
| 42 | |
| 43 private: | |
| 44 friend struct DefaultSingletonTraits<ExtensionAssetsManagerImpl>; | |
| 45 | |
| 46 ExtensionAssetsManagerImpl() {} | |
| 47 virtual ~ExtensionAssetsManagerImpl() {} | |
| 48 | |
| 49 DISALLOW_COPY_AND_ASSIGN(ExtensionAssetsManagerImpl); | |
| 50 }; | |
| 51 | |
| 52 } // namespace | |
| 53 | |
| 54 // static | |
| 55 ExtensionAssetsManager* ExtensionAssetsManager::GetInstance() { | |
| 56 #if defined(OS_CHROMEOS) | |
| 57 return ExtensionAssetsManagerChromeOS::GetInstance(); | |
| 58 #else | |
| 59 // If not Chrome OS, use trivial implementation that doesn't share anything. | |
| 60 return ExtensionAssetsManagerImpl::GetInstance(); | |
| 61 #endif // OS_CHROMEOS | |
| 62 } | |
| 63 | |
| 64 } // namespace extensions | |
| OLD | NEW |