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#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ASSETS_MANAGER_H_ 6#define CHROME_BROWSER_EXTENSIONS_EXTENSION_ASSETS_MANAGER_H_ 7 8#include <string> 9 10#include "base/callback.h" 11#include "base/files/file_path.h" 12 13class Profile; 14 15namespace extensions { 16 17class Extension; 18 19// Assets manager for installed extensions. Some extensions can be installed in 20// a shared place for multiple profiles (users). This class manages install and 21// uninstall. At the time being shared location is used for default apps on 22// Chrome OS only. This class must be used only from the extension file task 23// runner thread. 24class ExtensionAssetsManager { 25 public: 26 // Callback that is invoked when the extension assets are installed. 27 // |file_path| is destination directory on success or empty in case of error. 28 typedef base::Callback<void(const base::FilePath& file_path)> 29 InstallExtensionCallback; 30 31 static ExtensionAssetsManager* GetInstance(); 32 33 // Copy extension assets to final location. This location could be under 34 // |local_install_dir| or some common location shared for multiple users. 35 virtual void InstallExtension(const Extension* extension, 36 const base::FilePath& unpacked_extension_root, 37 const base::FilePath& local_install_dir, 38 Profile* profile, 39 InstallExtensionCallback callback) = 0; 40 41 // Remove extension assets if it is not used by anyone else. 42 virtual void UninstallExtension(const std::string& id, 43 Profile* profile, 44 const base::FilePath& local_install_dir, 45 const base::FilePath& extension_root) = 0; 46 47 protected: 48 virtual ~ExtensionAssetsManager() {} 49}; 50 51} // namespace extensions 52 53#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ASSETS_MANAGER_H_ 54