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.
5 #include "chrome/browser/extensions/extension_assets_manager.h"
7 #include "base/memory/singleton.h"
8 #include "extensions/common/extension.h"
9 #include "extensions/common/file_util.h"
11 #if defined(OS_CHROMEOS)
12 #include "chrome/browser/extensions/extension_assets_manager_chromeos.h"
15 namespace extensions
{
18 class ExtensionAssetsManagerImpl
: public ExtensionAssetsManager
{
20 static ExtensionAssetsManagerImpl
* GetInstance() {
21 return Singleton
<ExtensionAssetsManagerImpl
>::get();
24 // Override from ExtensionAssetsManager.
25 void InstallExtension(const Extension
* extension
,
26 const base::FilePath
& unpacked_extension_root
,
27 const base::FilePath
& local_install_dir
,
29 InstallExtensionCallback callback
) override
{
30 callback
.Run(file_util::InstallExtension(
31 unpacked_extension_root
,
33 extension
->VersionString(),
37 void UninstallExtension(const std::string
& id
,
39 const base::FilePath
& local_install_dir
,
40 const base::FilePath
& extension_root
) override
{
41 file_util::UninstallExtension(local_install_dir
, id
);
45 friend struct DefaultSingletonTraits
<ExtensionAssetsManagerImpl
>;
47 ExtensionAssetsManagerImpl() {}
48 ~ExtensionAssetsManagerImpl() override
{}
50 DISALLOW_COPY_AND_ASSIGN(ExtensionAssetsManagerImpl
);
56 ExtensionAssetsManager
* ExtensionAssetsManager::GetInstance() {
57 #if defined(OS_CHROMEOS)
58 return ExtensionAssetsManagerChromeOS::GetInstance();
60 // If not Chrome OS, use trivial implementation that doesn't share anything.
61 return ExtensionAssetsManagerImpl::GetInstance();
65 } // namespace extensions