OLD | NEW |
(Empty) | |
| 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_CHROMEOS_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ASSETS_MANAGER_CHROMEOS_H_ |
| 7 |
| 8 #include "base/memory/weak_ptr.h" |
| 9 #include "chrome/browser/extensions/extension_assets_manager.h" |
| 10 |
| 11 template <typename T> struct DefaultSingletonTraits; |
| 12 class PrefRegistrySimple; |
| 13 |
| 14 namespace base { |
| 15 class SequencedTaskRunner; |
| 16 } |
| 17 |
| 18 namespace extensions { |
| 19 |
| 20 // Chrome OS specific implementation assets manager that share default apps |
| 21 // between all users on the machine. |
| 22 class ExtensionAssetsManagerChromeOS : public ExtensionAssetsManager { |
| 23 public: |
| 24 static ExtensionAssetsManagerChromeOS* GetInstance(); |
| 25 |
| 26 // Path to shared extensions install dir. |
| 27 static const char kSharedExtensionsDir[]; |
| 28 |
| 29 // Register shared assets related preferences. |
| 30 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 31 |
| 32 // Override from ExtensionAssetsManager. |
| 33 virtual void InstallExtension(const Extension* extension, |
| 34 const base::FilePath& unpacked_extension_root, |
| 35 const base::FilePath& local_install_dir, |
| 36 Profile* profile, |
| 37 InstallExtensionCallback callback) OVERRIDE; |
| 38 virtual void UninstallExtension( |
| 39 const std::string& id, |
| 40 Profile* profile, |
| 41 const base::FilePath& local_install_dir, |
| 42 const base::FilePath& extension_root) OVERRIDE; |
| 43 |
| 44 void SetSharedInstallDirForTesting(const base::FilePath& install_dir); |
| 45 |
| 46 private: |
| 47 friend struct DefaultSingletonTraits<ExtensionAssetsManagerChromeOS>; |
| 48 |
| 49 ExtensionAssetsManagerChromeOS(); |
| 50 virtual ~ExtensionAssetsManagerChromeOS(); |
| 51 |
| 52 // Should be called on UI thread to get associated file task runner for |
| 53 // the profile. |
| 54 static base::SequencedTaskRunner* GetFileTaskRunner(Profile* profile); |
| 55 |
| 56 // Return |true| if |extension| can be installed in shared place for all users |
| 57 // on the device. |
| 58 static bool CanShareAssets(const Extension* extension); |
| 59 |
| 60 // Called in UI thread to check if given version of the |extension| already |
| 61 // exists at shared location. |
| 62 static void CheckSharedExtension( |
| 63 base::WeakPtr<ExtensionAssetsManagerChromeOS> object, |
| 64 const Extension* extension, |
| 65 const base::FilePath& unpacked_extension_root, |
| 66 const base::FilePath& local_install_dir, |
| 67 Profile* profile, |
| 68 InstallExtensionCallback callback); |
| 69 |
| 70 // Called on task runner thread when version found in shared location. |
| 71 static void SharedExtensionFound(const base::FilePath& shared_version_dir, |
| 72 InstallExtensionCallback callback); |
| 73 |
| 74 // Called on task runner thread when there is no version in shared location. |
| 75 void SharedExtensionNotFound( |
| 76 const Extension* extension, |
| 77 const base::FilePath& unpacked_extension_root, |
| 78 const base::FilePath& local_install_dir, |
| 79 Profile* profile, |
| 80 InstallExtensionCallback callback); |
| 81 |
| 82 // Called on UI thread to mark that shared version is in use. |
| 83 static void MarkSharedExtensionUsed( |
| 84 const std::string& id, |
| 85 const std::string& version, |
| 86 const base::FilePath& shared_version_dir, |
| 87 Profile* profile); |
| 88 |
| 89 // Called on UI thread to mark that shared version is not used. |
| 90 static void MarkSharedExtensionUnused( |
| 91 base::WeakPtr<ExtensionAssetsManagerChromeOS> object, |
| 92 const std::string& id, |
| 93 Profile* profile); |
| 94 |
| 95 // Called on task runner thread to remove shared version. |
| 96 void DeleteSharedVersion(const base::FilePath& shared_version_dir); |
| 97 |
| 98 // Weak factory for callbacks. |
| 99 base::WeakPtrFactory<ExtensionAssetsManagerChromeOS> weak_ptr_factory_; |
| 100 |
| 101 // Shared install dir, set to some temporary dir in tests. |
| 102 base::FilePath shared_install_dir_; |
| 103 |
| 104 DISALLOW_COPY_AND_ASSIGN(ExtensionAssetsManagerChromeOS); |
| 105 }; |
| 106 |
| 107 } // namespace extensions |
| 108 |
| 109 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ASSETS_MANAGER_CHROMEOS_H_ |
OLD | NEW |