Chromium Code Reviews| 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_POLICY_APP_PACK_UPDATER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_APP_PACK_UPDATER_H_ |
| 6 #define CHROME_BROWSER_POLICY_APP_PACK_UPDATER_H_ | 6 #define CHROME_BROWSER_POLICY_APP_PACK_UPDATER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/threading/sequenced_worker_pool.h" | 17 #include "base/threading/sequenced_worker_pool.h" |
| 18 #include "chrome/browser/extensions/updater/extension_downloader_delegate.h" | 18 #include "chrome/browser/extensions/updater/extension_downloader_delegate.h" |
| 19 #include "chrome/browser/policy/cloud_policy_subsystem.h" | 19 #include "chrome/browser/policy/cloud_policy_subsystem.h" |
| 20 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
| 21 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
| 22 #include "net/base/network_change_notifier.h" | 22 #include "net/base/network_change_notifier.h" |
| 23 | 23 |
| 24 class CrxInstaller; | 24 class CrxInstaller; |
| 25 class ExternalExtensionLoader; | |
| 26 class FilePath; | 25 class FilePath; |
|
Joao da Silva
2012/07/16 08:08:47
Nit: "base/file_path.h" is already included
Devlin
2012/07/16 15:40:30
Done.
| |
| 27 class GURL; | 26 class GURL; |
| 28 | 27 |
| 29 namespace extensions { | 28 namespace extensions { |
| 30 class ExtensionDownloader; | 29 class ExtensionDownloader; |
| 30 class ExternalLoader; | |
| 31 } | 31 } |
| 32 | 32 |
| 33 namespace net { | 33 namespace net { |
| 34 class URLRequestContextGetter; | 34 class URLRequestContextGetter; |
| 35 } | 35 } |
| 36 | 36 |
| 37 namespace tracked_objects { | 37 namespace tracked_objects { |
| 38 class Location; | 38 class Location; |
| 39 } | 39 } |
| 40 | 40 |
| 41 namespace policy { | 41 namespace policy { |
| 42 | 42 |
| 43 class AppPackExternalExtensionLoader; | 43 class AppPackExternalLoader; |
| 44 class BrowserPolicyConnector; | 44 class BrowserPolicyConnector; |
| 45 | 45 |
| 46 // The AppPackUpdater manages a set of extensions that are configured via a | 46 // The AppPackUpdater manages a set of extensions that are configured via a |
| 47 // device policy to be locally cached and installed into the Demo user account | 47 // device policy to be locally cached and installed into the Demo user account |
| 48 // at login time. | 48 // at login time. |
| 49 class AppPackUpdater : public CloudPolicySubsystem::Observer, | 49 class AppPackUpdater : public CloudPolicySubsystem::Observer, |
| 50 public content::NotificationObserver, | 50 public content::NotificationObserver, |
| 51 public net::NetworkChangeNotifier::IPAddressObserver, | 51 public net::NetworkChangeNotifier::IPAddressObserver, |
| 52 public extensions::ExtensionDownloaderDelegate { | 52 public extensions::ExtensionDownloaderDelegate { |
| 53 public: | 53 public: |
| 54 // Callback to listen for updates to the screensaver extension's path. | 54 // Callback to listen for updates to the screensaver extension's path. |
| 55 typedef base::Callback<void(const FilePath&)> ScreenSaverUpdateCallback; | 55 typedef base::Callback<void(const FilePath&)> ScreenSaverUpdateCallback; |
| 56 | 56 |
| 57 // Keys for the entries in the AppPack dictionary policy. | 57 // Keys for the entries in the AppPack dictionary policy. |
| 58 static const char kExtensionId[]; | 58 static const char kExtensionId[]; |
| 59 static const char kUpdateUrl[]; | 59 static const char kUpdateUrl[]; |
| 60 | 60 |
| 61 // The |request_context| is used for the update checks. | 61 // The |request_context| is used for the update checks. |
| 62 AppPackUpdater(net::URLRequestContextGetter* request_context, | 62 AppPackUpdater(net::URLRequestContextGetter* request_context, |
| 63 BrowserPolicyConnector* connector); | 63 BrowserPolicyConnector* connector); |
| 64 virtual ~AppPackUpdater(); | 64 virtual ~AppPackUpdater(); |
| 65 | 65 |
| 66 // Creates an ExternalExtensionLoader that will load the crx files downloaded | 66 // Creates an extensions::ExternalLoader that will load the crx files |
| 67 // by the AppPackUpdater. This can be called at most once, and the caller | 67 // downloaded by the AppPackUpdater. This can be called at most once, and the |
| 68 // owns the returned value. | 68 // caller owns the returned value. |
| 69 ExternalExtensionLoader* CreateExternalExtensionLoader(); | 69 extensions::ExternalLoader* CreateExternalLoader(); |
| 70 | 70 |
| 71 // |callback| will be invoked whenever the screen saver extension's path | 71 // |callback| will be invoked whenever the screen saver extension's path |
| 72 // changes. It will be invoked "soon" after this call if a valid path already | 72 // changes. It will be invoked "soon" after this call if a valid path already |
| 73 // exists. Subsequent calls will override the previous |callback|. A null | 73 // exists. Subsequent calls will override the previous |callback|. A null |
| 74 // |callback| can be used to remove a previous callback. | 74 // |callback| can be used to remove a previous callback. |
| 75 void SetScreenSaverUpdateCallback(const ScreenSaverUpdateCallback& callback); | 75 void SetScreenSaverUpdateCallback(const ScreenSaverUpdateCallback& callback); |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 struct AppPackEntry { | 78 struct AppPackEntry { |
| 79 std::string update_url; | 79 std::string update_url; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 std::string screen_saver_id_; | 215 std::string screen_saver_id_; |
| 216 FilePath screen_saver_path_; | 216 FilePath screen_saver_path_; |
| 217 | 217 |
| 218 // Callback to invoke whenever the screen saver's extension path changes. | 218 // Callback to invoke whenever the screen saver's extension path changes. |
| 219 // Can be null. | 219 // Can be null. |
| 220 ScreenSaverUpdateCallback screen_saver_update_callback_; | 220 ScreenSaverUpdateCallback screen_saver_update_callback_; |
| 221 | 221 |
| 222 // The extension loader wires the AppPackUpdater to the extensions system, and | 222 // The extension loader wires the AppPackUpdater to the extensions system, and |
| 223 // makes it install the currently cached extensions. | 223 // makes it install the currently cached extensions. |
| 224 bool created_extension_loader_; | 224 bool created_extension_loader_; |
| 225 base::WeakPtr<AppPackExternalExtensionLoader> extension_loader_; | 225 base::WeakPtr<AppPackExternalLoader> extension_loader_; |
| 226 | 226 |
| 227 // Used to download the extensions configured via policy, and to check for | 227 // Used to download the extensions configured via policy, and to check for |
| 228 // updates. | 228 // updates. |
| 229 scoped_ptr<extensions::ExtensionDownloader> downloader_; | 229 scoped_ptr<extensions::ExtensionDownloader> downloader_; |
| 230 | 230 |
| 231 // Request context used by the |downloader_|. | 231 // Request context used by the |downloader_|. |
| 232 net::URLRequestContextGetter* request_context_; | 232 net::URLRequestContextGetter* request_context_; |
| 233 | 233 |
| 234 DISALLOW_COPY_AND_ASSIGN(AppPackUpdater); | 234 DISALLOW_COPY_AND_ASSIGN(AppPackUpdater); |
| 235 }; | 235 }; |
| 236 | 236 |
| 237 } // namespace policy | 237 } // namespace policy |
| 238 | 238 |
| 239 #endif // CHROME_BROWSER_POLICY_APP_PACK_UPDATER_H_ | 239 #endif // CHROME_BROWSER_POLICY_APP_PACK_UPDATER_H_ |
| OLD | NEW |