Chromium Code Reviews| Index: chrome/browser/extensions/extension_assets_manager.cc |
| diff --git a/chrome/browser/extensions/extension_assets_manager.cc b/chrome/browser/extensions/extension_assets_manager.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ad3271087636791e49ef29421a61af180ef465bb |
| --- /dev/null |
| +++ b/chrome/browser/extensions/extension_assets_manager.cc |
| @@ -0,0 +1,64 @@ |
| +// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/extensions/extension_assets_manager.h" |
| + |
| +#include "base/memory/singleton.h" |
| +#include "extensions/common/extension.h" |
| +#include "extensions/common/file_util.h" |
| + |
| +#if defined(OS_CHROMEOS) |
| +#include "chrome/browser/extensions/extension_assets_manager_chromeos.h" |
| +#endif |
| + |
| +namespace extensions { |
| +namespace { |
| + |
| +class ExtensionAssetsManagerImpl : public ExtensionAssetsManager { |
| + public: |
| + // Copy extension assets to final location. This location could be under |
| + // |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.
|
| + virtual void InstallExtension(const Extension* extension, |
| + const base::FilePath& unpacked_extension_root, |
| + const base::FilePath& local_install_dir, |
| + Profile* profile, |
| + InstallExtensionCallback callback) OVERRIDE { |
| + callback.Run(file_util::InstallExtension( |
| + unpacked_extension_root, |
| + extension->id(), |
| + extension->VersionString(), |
| + local_install_dir)); |
| + } |
| + |
| + // Remove extension assets if it is not used by anyone else. |
| + virtual void UninstallExtension( |
| + const std::string& id, |
| + Profile* profile, |
| + const base::FilePath& local_install_dir, |
| + const base::FilePath& extension_root) OVERRIDE { |
| + file_util::UninstallExtension(local_install_dir, id); |
| + } |
| + |
| + private: |
| + friend struct DefaultSingletonTraits<ExtensionAssetsManagerImpl>; |
| + |
| + ExtensionAssetsManagerImpl() {} |
| + virtual ~ExtensionAssetsManagerImpl() {} |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ExtensionAssetsManagerImpl); |
| +}; |
| + |
| +} // namespace |
| + |
| +// static |
| +ExtensionAssetsManager* ExtensionAssetsManager::GetInstance() { |
| +#if defined(OS_CHROMEOS) |
| + return ExtensionAssetsManagerChromeOS::GetInstance(); |
| +#else |
| + // If not Chrome OS, use trivial implementation that doesn't share anything. |
| + return ExtensionAssetsManagerImpl::GetInstance(); |
| +#endif // OS_CHROMEOS |
| +} |
| + |
| +} // namespace extensions |