Chromium Code Reviews| Index: chrome/browser/chromeos/app_mode/kiosk_external_updater.h |
| diff --git a/chrome/browser/chromeos/app_mode/kiosk_external_updater.h b/chrome/browser/chromeos/app_mode/kiosk_external_updater.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..746aa7ec9ebdd7ba0cea22ab2633d043fe551080 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/app_mode/kiosk_external_updater.h |
| @@ -0,0 +1,127 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_EXTERNAL_UPDATER_H_ |
| +#define CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_EXTERNAL_UPDATER_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/files/file_path.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/sequenced_task_runner.h" |
| +#include "chrome/browser/chromeos/app_mode/kiosk_external_update_validator.h" |
| +#include "chromeos/disks/disk_mount_manager.h" |
| + |
| +namespace chromeos { |
| + |
| +class KioskExternalUpdateNotification; |
| + |
| +// Observes the disk mount/unmount events, scans the usb stick for external |
| +// kiosk app updates, validates the external crx, and updates the cache. |
| +class KioskExternalUpdater : public disks::DiskMountManager::Observer, |
| + public KioskExternalUpdateValidatorDelegate { |
| + public: |
| + KioskExternalUpdater( |
| + const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner, |
| + const base::FilePath& crx_cache_dir, |
| + const base::FilePath& crx_unpack_dir); |
| + |
| + private: |
| + enum ExternalUpdateStatus { |
| + PENDING, |
| + SUCCESS, |
| + FAILED, |
| + }; |
| + struct ExternalUpdate { |
| + std::string app_name; |
| + base::FilePath external_crx; |
| + ExternalUpdateStatus update_status; |
| + base::string16 error; |
| + |
| + ExternalUpdate(); |
|
xiyuan
2014/08/23 18:11:58
ctor before members
jennyz
2014/08/27 00:58:42
Done.
|
| + }; |
| + |
| + virtual ~KioskExternalUpdater(); |
| + |
| + // disks::DiskMountManager::Observer overrides. |
| + virtual void OnDiskEvent(disks::DiskMountManager::DiskEvent event, |
| + const disks::DiskMountManager::Disk* disk) OVERRIDE; |
| + virtual void OnDeviceEvent(disks::DiskMountManager::DeviceEvent event, |
| + const std::string& device_path) OVERRIDE; |
| + virtual void OnMountEvent( |
| + disks::DiskMountManager::MountEvent event, |
| + MountError error_code, |
| + const disks::DiskMountManager::MountPointInfo& mount_info) OVERRIDE; |
| + virtual void OnFormatEvent(disks::DiskMountManager::FormatEvent event, |
| + FormatError error_code, |
| + const std::string& device_path) OVERRIDE; |
| + |
| + // KioskExternalUpdateValidatorDelegate overrides: |
| + virtual void OnExtenalUpdateUnpackSuccess( |
| + const std::string& app_id, |
| + const base::FilePath& temp_dir, |
| + const extensions::Extension* extension) OVERRIDE; |
| + virtual void OnExternalUpdateUnpackFailure( |
| + const std::string& app_id) OVERRIDE; |
| + |
| + // Loads the external extension update manifest file from |
| + // |external_update_dir|. |
| + void LoadExternalUpdateManifest(const base::FilePath& external_update_dir); |
| + |
| + // Validates the external updates. |
| + void ValidateExternalUpdates(); |
| + |
| + // Caches the external crx to |target_file|. |
| + void CacheExternalCrx(const std::string& app_id, |
| + const base::FilePath& target_file); |
| + |
| + // Returns true if there are any external updates pending. |
| + bool IsExternalUpdatePending(); |
| + |
| + // Returns true if the app with |app_id| should be updated to |
| + // |external_extension|. |
| + bool ShouldDoExternalUpdate(const std::string& app_id, |
| + const extensions::Extension* external_extension); |
| + |
| + void ShowKioskUpdateProgressOnUI(const base::string16& message); |
| + |
| + // Notifies the kiosk update status with UI and KioskAppUpdateService, if |
| + // there is no kiosk external updates pending. |
| + void MayBeNotifyKioskAppUpdate(); |
| + |
| + void NotifyKioskAppUpdateAvailable(); |
| + |
| + void ShowKioskUpdateProgress(const base::string16& message); |
| + |
| + // Dismisses the UI notification for kiosk updates. |
| + void DismissKioskUpdateNotificationOnUIThread(); |
| + void DismissKioskUpdateNotification(); |
| + |
| + // Return a detailed message for kiosk updating status. |
| + base::string16 GetUpdateReportMessage(); |
| + |
| + // Task runner for executing file I/O tasks. |
| + const scoped_refptr<base::SequencedTaskRunner> backend_task_runner_; |
| + |
| + // The directory where kiosk crx files are cached. |
| + const base::FilePath crx_cache_dir_; |
| + |
| + // The directory used by SandBoxedUnpacker for unpack extensions. |
| + const base::FilePath crx_unpack_dir_; |
| + |
| + // The path where external crx files resides(usb stick mount path). |
| + base::FilePath external_update_path_; |
| + |
| + // map of app_id: ExternalUpdate |
| + typedef std::map<std::string, ExternalUpdate> ExternalUpdateMap; |
| + ExternalUpdateMap external_updates_; |
| + scoped_ptr<KioskExternalUpdateNotification> notification_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(KioskExternalUpdater); |
| +}; |
| + |
| +} // namespace chromeos |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_EXTERNAL_UPDATER_H_ |