| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CHROMEOS_POLICY_APP_PACK_UPDATER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_APP_PACK_UPDATER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_APP_PACK_UPDATER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_APP_PACK_UPDATER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 15 #include "chrome/browser/chromeos/extensions/external_cache.h" | 16 #include "chrome/browser/chromeos/extensions/external_cache.h" |
| 16 #include "content/public/browser/notification_observer.h" | 17 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 17 | 18 |
| 18 namespace extensions { | 19 namespace extensions { |
| 19 class ExternalLoader; | 20 class ExternalLoader; |
| 20 } | 21 } |
| 21 | 22 |
| 22 namespace net { | 23 namespace net { |
| 23 class URLRequestContextGetter; | 24 class URLRequestContextGetter; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace policy { | 27 namespace policy { |
| 27 | 28 |
| 28 class AppPackExternalLoader; | 29 class AppPackExternalLoader; |
| 29 class EnterpriseInstallAttributes; | 30 class EnterpriseInstallAttributes; |
| 30 | 31 |
| 31 // The AppPackUpdater manages a set of extensions that are configured via a | 32 // The AppPackUpdater manages a set of extensions that are configured via a |
| 32 // device policy to be locally cached and installed into the Demo user account | 33 // device policy to be locally cached and installed into the Demo user account |
| 33 // at login time. | 34 // at login time. |
| 34 class AppPackUpdater : public content::NotificationObserver, | 35 class AppPackUpdater : public chromeos::ExternalCache::Delegate { |
| 35 public chromeos::ExternalCache::Delegate { | |
| 36 public: | 36 public: |
| 37 // Callback to listen for updates to the screensaver extension's path. | 37 // Callback to listen for updates to the screensaver extension's path. |
| 38 typedef base::Callback<void(const base::FilePath&)> ScreenSaverUpdateCallback; | 38 typedef base::Callback<void(const base::FilePath&)> ScreenSaverUpdateCallback; |
| 39 | 39 |
| 40 // The |request_context| is used for the update checks. | 40 // The |request_context| is used for the update checks. |
| 41 AppPackUpdater(net::URLRequestContextGetter* request_context, | 41 AppPackUpdater(net::URLRequestContextGetter* request_context, |
| 42 EnterpriseInstallAttributes* install_attributes); | 42 EnterpriseInstallAttributes* install_attributes); |
| 43 virtual ~AppPackUpdater(); | 43 virtual ~AppPackUpdater(); |
| 44 | 44 |
| 45 // Returns true if the ExternalLoader for the app pack has already been | 45 // Returns true if the ExternalLoader for the app pack has already been |
| (...skipping 10 matching lines...) Expand all Loading... |
| 56 // exists. Subsequent calls will override the previous |callback|. A null | 56 // exists. Subsequent calls will override the previous |callback|. A null |
| 57 // |callback| can be used to remove a previous callback. | 57 // |callback| can be used to remove a previous callback. |
| 58 void SetScreenSaverUpdateCallback(const ScreenSaverUpdateCallback& callback); | 58 void SetScreenSaverUpdateCallback(const ScreenSaverUpdateCallback& callback); |
| 59 | 59 |
| 60 // If a user of one of the AppPack's extensions detects that the extension | 60 // If a user of one of the AppPack's extensions detects that the extension |
| 61 // is damaged then this method can be used to remove it from the cache and | 61 // is damaged then this method can be used to remove it from the cache and |
| 62 // retry to download it after a restart. | 62 // retry to download it after a restart. |
| 63 void OnDamagedFileDetected(const base::FilePath& path); | 63 void OnDamagedFileDetected(const base::FilePath& path); |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 // content::NotificationObserver: | |
| 67 virtual void Observe(int type, | |
| 68 const content::NotificationSource& source, | |
| 69 const content::NotificationDetails& details) OVERRIDE; | |
| 70 | |
| 71 // Implementation of ExternalCache::Delegate: | 66 // Implementation of ExternalCache::Delegate: |
| 72 virtual void OnExtensionListsUpdated( | 67 virtual void OnExtensionListsUpdated( |
| 73 const base::DictionaryValue* prefs) OVERRIDE; | 68 const base::DictionaryValue* prefs) OVERRIDE; |
| 74 | 69 |
| 70 // Called when the app pack device setting changes. |
| 71 void AppPackChanged(); |
| 72 |
| 75 // Loads the current policy and schedules a cache update. | 73 // Loads the current policy and schedules a cache update. |
| 76 void LoadPolicy(); | 74 void LoadPolicy(); |
| 77 | 75 |
| 78 // Notifies the |extension_loader_| that the cache has been updated, providing | 76 // Notifies the |extension_loader_| that the cache has been updated, providing |
| 79 // it with an updated list of app-pack extensions. | 77 // it with an updated list of app-pack extensions. |
| 80 void UpdateExtensionLoader(); | 78 void UpdateExtensionLoader(); |
| 81 | 79 |
| 82 // Sets |screen_saver_path_| and invokes |screen_saver_update_callback_| if | 80 // Sets |screen_saver_path_| and invokes |screen_saver_update_callback_| if |
| 83 // appropriate. | 81 // appropriate. |
| 84 void SetScreenSaverPath(const base::FilePath& path); | 82 void SetScreenSaverPath(const base::FilePath& path); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 98 // makes it install the currently cached extensions. | 96 // makes it install the currently cached extensions. |
| 99 bool created_extension_loader_; | 97 bool created_extension_loader_; |
| 100 base::WeakPtr<AppPackExternalLoader> extension_loader_; | 98 base::WeakPtr<AppPackExternalLoader> extension_loader_; |
| 101 | 99 |
| 102 // For checking the device mode. | 100 // For checking the device mode. |
| 103 EnterpriseInstallAttributes* install_attributes_; | 101 EnterpriseInstallAttributes* install_attributes_; |
| 104 | 102 |
| 105 // Extension cache. | 103 // Extension cache. |
| 106 chromeos::ExternalCache external_cache_; | 104 chromeos::ExternalCache external_cache_; |
| 107 | 105 |
| 106 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> |
| 107 app_pack_subscription_; |
| 108 |
| 108 DISALLOW_COPY_AND_ASSIGN(AppPackUpdater); | 109 DISALLOW_COPY_AND_ASSIGN(AppPackUpdater); |
| 109 }; | 110 }; |
| 110 | 111 |
| 111 } // namespace policy | 112 } // namespace policy |
| 112 | 113 |
| 113 #endif // CHROME_BROWSER_CHROMEOS_POLICY_APP_PACK_UPDATER_H_ | 114 #endif // CHROME_BROWSER_CHROMEOS_POLICY_APP_PACK_UPDATER_H_ |
| OLD | NEW |