| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ASSETS_MANAGER_CHROMEOS_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ASSETS_MANAGER_CHROMEOS_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ASSETS_MANAGER_CHROMEOS_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ASSETS_MANAGER_CHROMEOS_H_ |
| 7 | 7 |
| 8 #include <map> |
| 9 |
| 8 #include "chrome/browser/extensions/extension_assets_manager.h" | 10 #include "chrome/browser/extensions/extension_assets_manager.h" |
| 9 | 11 |
| 10 template <typename T> struct DefaultSingletonTraits; | 12 template <typename T> struct DefaultSingletonTraits; |
| 11 class PrefRegistrySimple; | 13 class PrefRegistrySimple; |
| 12 | 14 |
| 13 namespace base { | 15 namespace base { |
| 16 class DictionaryValue; |
| 14 class SequencedTaskRunner; | 17 class SequencedTaskRunner; |
| 15 } | 18 } |
| 16 | 19 |
| 17 namespace extensions { | 20 namespace extensions { |
| 18 | 21 |
| 19 // Chrome OS specific implementation of assets manager that shares default apps | 22 // Chrome OS specific implementation of assets manager that shares default apps |
| 20 // between all users on the machine. | 23 // between all users on the machine. |
| 21 class ExtensionAssetsManagerChromeOS : public ExtensionAssetsManager { | 24 class ExtensionAssetsManagerChromeOS : public ExtensionAssetsManager { |
| 22 public: | 25 public: |
| 23 static ExtensionAssetsManagerChromeOS* GetInstance(); | 26 static ExtensionAssetsManagerChromeOS* GetInstance(); |
| 24 | 27 |
| 25 // Path to shared extensions install dir. | 28 // A dictionary that maps shared extension IDs to version/paths/users. |
| 26 static const char kSharedExtensionsDir[]; | 29 static const char kSharedExtensions[]; |
| 30 |
| 31 // Name of path attribute in shared extensions map. |
| 32 static const char kSharedExtensionPath[]; |
| 33 |
| 34 // Name of users attribute (list of user emails) in shared extensions map. |
| 35 static const char kSharedExtensionUsers[]; |
| 27 | 36 |
| 28 // Register shared assets related preferences. | 37 // Register shared assets related preferences. |
| 29 static void RegisterPrefs(PrefRegistrySimple* registry); | 38 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 30 | 39 |
| 31 // Override from ExtensionAssetsManager. | 40 // Override from ExtensionAssetsManager. |
| 32 virtual void InstallExtension(const Extension* extension, | 41 virtual void InstallExtension(const Extension* extension, |
| 33 const base::FilePath& unpacked_extension_root, | 42 const base::FilePath& unpacked_extension_root, |
| 34 const base::FilePath& local_install_dir, | 43 const base::FilePath& local_install_dir, |
| 35 Profile* profile, | 44 Profile* profile, |
| 36 InstallExtensionCallback callback) OVERRIDE; | 45 InstallExtensionCallback callback) OVERRIDE; |
| 37 virtual void UninstallExtension( | 46 virtual void UninstallExtension( |
| 38 const std::string& id, | 47 const std::string& id, |
| 39 Profile* profile, | 48 Profile* profile, |
| 40 const base::FilePath& local_install_dir, | 49 const base::FilePath& local_install_dir, |
| 41 const base::FilePath& extension_root) OVERRIDE; | 50 const base::FilePath& extension_root) OVERRIDE; |
| 42 | 51 |
| 52 // Return shared install dir. |
| 53 static base::FilePath GetSharedInstallDir(); |
| 54 |
| 55 // Cleans up shared extensions list in preferences and returns list of |
| 56 // extension IDs and version paths that are in use in |live_extension_paths|. |
| 57 // Files on disk are not removed. Must be called on UI thread. |
| 58 // Returns |false| in case of errors. |
| 59 static bool CleanUpSharedExtensions( |
| 60 std::multimap<std::string, base::FilePath>* live_extension_paths); |
| 61 |
| 43 static void SetSharedInstallDirForTesting(const base::FilePath& install_dir); | 62 static void SetSharedInstallDirForTesting(const base::FilePath& install_dir); |
| 44 | 63 |
| 45 private: | 64 private: |
| 46 friend struct DefaultSingletonTraits<ExtensionAssetsManagerChromeOS>; | 65 friend struct DefaultSingletonTraits<ExtensionAssetsManagerChromeOS>; |
| 47 | 66 |
| 48 ExtensionAssetsManagerChromeOS(); | 67 ExtensionAssetsManagerChromeOS(); |
| 49 virtual ~ExtensionAssetsManagerChromeOS(); | 68 virtual ~ExtensionAssetsManagerChromeOS(); |
| 50 | 69 |
| 51 // Should be called on UI thread to get associated file task runner for | 70 // Should be called on UI thread to get associated file task runner for |
| 52 // the profile. | 71 // the profile. |
| 53 static base::SequencedTaskRunner* GetFileTaskRunner(Profile* profile); | 72 static base::SequencedTaskRunner* GetFileTaskRunner(Profile* profile); |
| 54 | 73 |
| 55 // Return shared install dir. | |
| 56 static base::FilePath GetSharedInstallDir(); | |
| 57 | |
| 58 // Return |true| if |extension| can be installed in a shared place for all | 74 // Return |true| if |extension| can be installed in a shared place for all |
| 59 // users on the device. | 75 // users on the device. |
| 60 static bool CanShareAssets(const Extension* extension); | 76 static bool CanShareAssets(const Extension* extension); |
| 61 | 77 |
| 62 // Called on the UI thread to check if a given version of the |extension| | 78 // Called on the UI thread to check if a given version of the |extension| |
| 63 // already exists at the shared location. | 79 // already exists at the shared location. |
| 64 static void CheckSharedExtension( | 80 static void CheckSharedExtension( |
| 65 const std::string& id, | 81 const std::string& id, |
| 66 const std::string& version, | 82 const std::string& version, |
| 67 const base::FilePath& unpacked_extension_root, | 83 const base::FilePath& unpacked_extension_root, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 90 const base::FilePath& local_install_dir, | 106 const base::FilePath& local_install_dir, |
| 91 InstallExtensionCallback callback); | 107 InstallExtensionCallback callback); |
| 92 | 108 |
| 93 // Called on UI thread to mark that shared version is not used. | 109 // Called on UI thread to mark that shared version is not used. |
| 94 static void MarkSharedExtensionUnused(const std::string& id, | 110 static void MarkSharedExtensionUnused(const std::string& id, |
| 95 Profile* profile); | 111 Profile* profile); |
| 96 | 112 |
| 97 // Called on task runner thread to remove shared version. | 113 // Called on task runner thread to remove shared version. |
| 98 static void DeleteSharedVersion(const base::FilePath& shared_version_dir); | 114 static void DeleteSharedVersion(const base::FilePath& shared_version_dir); |
| 99 | 115 |
| 116 // Clean shared extension with given |id|. |
| 117 static bool CleanUpExtension( |
| 118 const std::string& id, |
| 119 base::DictionaryValue* extension_info, |
| 120 std::multimap<std::string, base::FilePath>* live_extension_paths); |
| 121 |
| 100 DISALLOW_COPY_AND_ASSIGN(ExtensionAssetsManagerChromeOS); | 122 DISALLOW_COPY_AND_ASSIGN(ExtensionAssetsManagerChromeOS); |
| 101 }; | 123 }; |
| 102 | 124 |
| 103 } // namespace extensions | 125 } // namespace extensions |
| 104 | 126 |
| 105 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ASSETS_MANAGER_CHROMEOS_H_ | 127 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ASSETS_MANAGER_CHROMEOS_H_ |
| OLD | NEW |