Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 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_CHROMEOS_APP_MODE_KIOSK_EXTERNAL_UPDATER_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_EXTERNAL_UPDATER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/files/file_path.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "base/sequenced_task_runner.h" | |
| 14 #include "chrome/browser/chromeos/app_mode/kiosk_external_update_validator.h" | |
| 15 #include "chromeos/disks/disk_mount_manager.h" | |
| 16 | |
| 17 namespace chromeos { | |
| 18 | |
| 19 class KioskExternalUpdateNotification; | |
| 20 | |
| 21 // Observes the disk mount/unmount events, scans the usb stick for external | |
| 22 // kiosk app updates, validates the external crx, and updates the cache. | |
| 23 class KioskExternalUpdater : public disks::DiskMountManager::Observer, | |
| 24 public KioskExternalUpdateValidatorDelegate { | |
| 25 public: | |
| 26 KioskExternalUpdater( | |
| 27 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner, | |
| 28 const base::FilePath& crx_cache_dir, | |
| 29 const base::FilePath& crx_unpack_dir); | |
| 30 | |
| 31 private: | |
| 32 enum ExternalUpdateStatus { | |
| 33 PENDING, | |
| 34 SUCCESS, | |
| 35 FAILED, | |
| 36 }; | |
| 37 struct ExternalUpdate { | |
| 38 std::string app_name; | |
| 39 base::FilePath external_crx; | |
| 40 ExternalUpdateStatus update_status; | |
| 41 base::string16 error; | |
| 42 | |
| 43 ExternalUpdate(); | |
|
xiyuan
2014/08/23 18:11:58
ctor before members
jennyz
2014/08/27 00:58:42
Done.
| |
| 44 }; | |
| 45 | |
| 46 virtual ~KioskExternalUpdater(); | |
| 47 | |
| 48 // disks::DiskMountManager::Observer overrides. | |
| 49 virtual void OnDiskEvent(disks::DiskMountManager::DiskEvent event, | |
| 50 const disks::DiskMountManager::Disk* disk) OVERRIDE; | |
| 51 virtual void OnDeviceEvent(disks::DiskMountManager::DeviceEvent event, | |
| 52 const std::string& device_path) OVERRIDE; | |
| 53 virtual void OnMountEvent( | |
| 54 disks::DiskMountManager::MountEvent event, | |
| 55 MountError error_code, | |
| 56 const disks::DiskMountManager::MountPointInfo& mount_info) OVERRIDE; | |
| 57 virtual void OnFormatEvent(disks::DiskMountManager::FormatEvent event, | |
| 58 FormatError error_code, | |
| 59 const std::string& device_path) OVERRIDE; | |
| 60 | |
| 61 // KioskExternalUpdateValidatorDelegate overrides: | |
| 62 virtual void OnExtenalUpdateUnpackSuccess( | |
| 63 const std::string& app_id, | |
| 64 const base::FilePath& temp_dir, | |
| 65 const extensions::Extension* extension) OVERRIDE; | |
| 66 virtual void OnExternalUpdateUnpackFailure( | |
| 67 const std::string& app_id) OVERRIDE; | |
| 68 | |
| 69 // Loads the external extension update manifest file from | |
| 70 // |external_update_dir|. | |
| 71 void LoadExternalUpdateManifest(const base::FilePath& external_update_dir); | |
| 72 | |
| 73 // Validates the external updates. | |
| 74 void ValidateExternalUpdates(); | |
| 75 | |
| 76 // Caches the external crx to |target_file|. | |
| 77 void CacheExternalCrx(const std::string& app_id, | |
| 78 const base::FilePath& target_file); | |
| 79 | |
| 80 // Returns true if there are any external updates pending. | |
| 81 bool IsExternalUpdatePending(); | |
| 82 | |
| 83 // Returns true if the app with |app_id| should be updated to | |
| 84 // |external_extension|. | |
| 85 bool ShouldDoExternalUpdate(const std::string& app_id, | |
| 86 const extensions::Extension* external_extension); | |
| 87 | |
| 88 void ShowKioskUpdateProgressOnUI(const base::string16& message); | |
| 89 | |
| 90 // Notifies the kiosk update status with UI and KioskAppUpdateService, if | |
| 91 // there is no kiosk external updates pending. | |
| 92 void MayBeNotifyKioskAppUpdate(); | |
| 93 | |
| 94 void NotifyKioskAppUpdateAvailable(); | |
| 95 | |
| 96 void ShowKioskUpdateProgress(const base::string16& message); | |
| 97 | |
| 98 // Dismisses the UI notification for kiosk updates. | |
| 99 void DismissKioskUpdateNotificationOnUIThread(); | |
| 100 void DismissKioskUpdateNotification(); | |
| 101 | |
| 102 // Return a detailed message for kiosk updating status. | |
| 103 base::string16 GetUpdateReportMessage(); | |
| 104 | |
| 105 // Task runner for executing file I/O tasks. | |
| 106 const scoped_refptr<base::SequencedTaskRunner> backend_task_runner_; | |
| 107 | |
| 108 // The directory where kiosk crx files are cached. | |
| 109 const base::FilePath crx_cache_dir_; | |
| 110 | |
| 111 // The directory used by SandBoxedUnpacker for unpack extensions. | |
| 112 const base::FilePath crx_unpack_dir_; | |
| 113 | |
| 114 // The path where external crx files resides(usb stick mount path). | |
| 115 base::FilePath external_update_path_; | |
| 116 | |
| 117 // map of app_id: ExternalUpdate | |
| 118 typedef std::map<std::string, ExternalUpdate> ExternalUpdateMap; | |
| 119 ExternalUpdateMap external_updates_; | |
| 120 scoped_ptr<KioskExternalUpdateNotification> notification_; | |
| 121 | |
| 122 DISALLOW_COPY_AND_ASSIGN(KioskExternalUpdater); | |
| 123 }; | |
| 124 | |
| 125 } // namespace chromeos | |
| 126 | |
| 127 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_EXTERNAL_UPDATER_H_ | |
| OLD | NEW |