Chromium Code Reviews| 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 |live_extension_paths|. | |
|
asargent_no_longer_on_chrome
2014/05/29 19:32:00
nit: "that are in use |live_extension_paths|"
co
Dmitry Polukhin
2014/05/29 22:38:37
Done.
| |
| 57 // Must be called on UI thread. Returns |false| in case of errors. | |
| 58 static bool CleanUpSharedExtensions( | |
| 59 std::multimap<std::string, base::FilePath>* live_extension_paths); | |
| 60 | |
| 43 static void SetSharedInstallDirForTesting(const base::FilePath& install_dir); | 61 static void SetSharedInstallDirForTesting(const base::FilePath& install_dir); |
| 44 | 62 |
| 45 private: | 63 private: |
| 46 friend struct DefaultSingletonTraits<ExtensionAssetsManagerChromeOS>; | 64 friend struct DefaultSingletonTraits<ExtensionAssetsManagerChromeOS>; |
| 47 | 65 |
| 48 ExtensionAssetsManagerChromeOS(); | 66 ExtensionAssetsManagerChromeOS(); |
| 49 virtual ~ExtensionAssetsManagerChromeOS(); | 67 virtual ~ExtensionAssetsManagerChromeOS(); |
| 50 | 68 |
| 51 // Should be called on UI thread to get associated file task runner for | 69 // Should be called on UI thread to get associated file task runner for |
| 52 // the profile. | 70 // the profile. |
| 53 static base::SequencedTaskRunner* GetFileTaskRunner(Profile* profile); | 71 static base::SequencedTaskRunner* GetFileTaskRunner(Profile* profile); |
| 54 | 72 |
| 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 | 73 // Return |true| if |extension| can be installed in a shared place for all |
| 59 // users on the device. | 74 // users on the device. |
| 60 static bool CanShareAssets(const Extension* extension); | 75 static bool CanShareAssets(const Extension* extension); |
| 61 | 76 |
| 62 // Called on the UI thread to check if a given version of the |extension| | 77 // Called on the UI thread to check if a given version of the |extension| |
| 63 // already exists at the shared location. | 78 // already exists at the shared location. |
| 64 static void CheckSharedExtension( | 79 static void CheckSharedExtension( |
| 65 const std::string& id, | 80 const std::string& id, |
| 66 const std::string& version, | 81 const std::string& version, |
| 67 const base::FilePath& unpacked_extension_root, | 82 const base::FilePath& unpacked_extension_root, |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 90 const base::FilePath& local_install_dir, | 105 const base::FilePath& local_install_dir, |
| 91 InstallExtensionCallback callback); | 106 InstallExtensionCallback callback); |
| 92 | 107 |
| 93 // Called on UI thread to mark that shared version is not used. | 108 // Called on UI thread to mark that shared version is not used. |
| 94 static void MarkSharedExtensionUnused(const std::string& id, | 109 static void MarkSharedExtensionUnused(const std::string& id, |
| 95 Profile* profile); | 110 Profile* profile); |
| 96 | 111 |
| 97 // Called on task runner thread to remove shared version. | 112 // Called on task runner thread to remove shared version. |
| 98 static void DeleteSharedVersion(const base::FilePath& shared_version_dir); | 113 static void DeleteSharedVersion(const base::FilePath& shared_version_dir); |
| 99 | 114 |
| 115 // Clean shared extension with given |id|. | |
| 116 static bool CleanUpExtension( | |
| 117 const std::string& id, | |
| 118 base::DictionaryValue* extension_info, | |
| 119 std::multimap<std::string, base::FilePath>* live_extension_paths); | |
| 120 | |
| 100 DISALLOW_COPY_AND_ASSIGN(ExtensionAssetsManagerChromeOS); | 121 DISALLOW_COPY_AND_ASSIGN(ExtensionAssetsManagerChromeOS); |
| 101 }; | 122 }; |
| 102 | 123 |
| 103 } // namespace extensions | 124 } // namespace extensions |
| 104 | 125 |
| 105 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ASSETS_MANAGER_CHROMEOS_H_ | 126 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ASSETS_MANAGER_CHROMEOS_H_ |
| OLD | NEW |