Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: chrome/browser/chromeos/app_mode/kiosk_external_updater.h

Issue 491403003: Update cached kiosk app crx from usb stick. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor optimization in test. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 enum ExternalUpdateErrorCode {
27 ERROR_NONE,
28 ERROR_NO_MANIFEST,
29 ERROR_INVALID_MANIFEST,
30 };
31
32 KioskExternalUpdater(
33 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner,
34 const base::FilePath& crx_cache_dir,
35 const base::FilePath& crx_unpack_dir);
36
37 virtual ~KioskExternalUpdater();
38
39 private:
40 enum ExternalUpdateStatus {
41 PENDING,
42 SUCCESS,
43 FAILED,
44 };
45 struct ExternalUpdate {
46 ExternalUpdate();
47
48 std::string app_name;
49 base::FilePath external_crx;
50 ExternalUpdateStatus update_status;
51 base::string16 error;
52 };
53
54 // disks::DiskMountManager::Observer overrides.
55 virtual void OnDiskEvent(disks::DiskMountManager::DiskEvent event,
56 const disks::DiskMountManager::Disk* disk) OVERRIDE;
57 virtual void OnDeviceEvent(disks::DiskMountManager::DeviceEvent event,
58 const std::string& device_path) OVERRIDE;
59 virtual void OnMountEvent(
60 disks::DiskMountManager::MountEvent event,
61 MountError error_code,
62 const disks::DiskMountManager::MountPointInfo& mount_info) OVERRIDE;
63 virtual void OnFormatEvent(disks::DiskMountManager::FormatEvent event,
64 FormatError error_code,
65 const std::string& device_path) OVERRIDE;
66
67 // KioskExternalUpdateValidatorDelegate overrides:
68 virtual void OnExtenalUpdateUnpackSuccess(
69 const std::string& app_id,
70 const std::string& version,
71 const std::string& min_browser_version,
72 const base::FilePath& temp_dir) OVERRIDE;
73 virtual void OnExternalUpdateUnpackFailure(
74 const std::string& app_id) OVERRIDE;
75
76 // Processes the parsed external update manifest, check |parsing_error| for
77 // any manifest parsing error.
78 void ProcessParsedManifest(ExternalUpdateErrorCode* parsing_error,
79 const base::FilePath& external_update_dir,
80 base::DictionaryValue* parsed_manifest);
81
82 // Returns true if |external_update_| is interrupted before the updating
83 // completes.
84 bool CheckExternalUpdateInterrupted();
85
86 // Validates the external updates.
87 void ValidateExternalUpdates();
88
89 // Returns true if there are any external updates pending.
90 bool IsExternalUpdatePending();
91
92 // Returns true if the app with |app_id| should be updated to
93 // |external_extension|.
94 bool ShouldDoExternalUpdate(const std::string& app_id,
95 const std::string& version,
96 const std::string& min_browser_version);
97
98 // Installs the validated extension into cache.
99 // |*crx_copied| indicates whether the |crx_file| is copied successfully.
100 void PutValidatedExtension(bool* crx_copied,
101 const std::string& app_id,
102 const base::FilePath& crx_file,
103 const std::string& version);
104
105 // Called upon completion of installing the validated external extension into
106 // the local cache. |success| is true if the operation succeeded.
107 void OnPutValidatedExtension(const std::string& app_id, bool success);
108
109 void NotifyKioskUpdateProgress(const base::string16& message);
110
111 void MaybeValidateNextExternalUpdate();
112
113 // Notifies the kiosk update status with UI and KioskAppUpdateService, if
114 // there is no kiosk external updates pending.
115 void MayBeNotifyKioskAppUpdate();
116
117 void NotifyKioskAppUpdateAvailable();
118
119 // Dismisses the UI notification for kiosk updates.
120 void DismissKioskUpdateNotification();
121
122 // Return a detailed message for kiosk updating status.
123 base::string16 GetUpdateReportMessage();
124
125 // Task runner for executing file I/O tasks.
126 const scoped_refptr<base::SequencedTaskRunner> backend_task_runner_;
127
128 // The directory where kiosk crx files are cached.
129 const base::FilePath crx_cache_dir_;
130
131 // The directory used by SandBoxedUnpacker for unpack extensions.
132 const base::FilePath crx_unpack_dir_;
133
134 // The path where external crx files resides(usb stick mount path).
135 base::FilePath external_update_path_;
136
137 // map of app_id: ExternalUpdate
138 typedef std::map<std::string, ExternalUpdate> ExternalUpdateMap;
139 ExternalUpdateMap external_updates_;
140 scoped_ptr<KioskExternalUpdateNotification> notification_;
141
142 base::WeakPtrFactory<KioskExternalUpdater> weak_factory_;
143
144 DISALLOW_COPY_AND_ASSIGN(KioskExternalUpdater);
145 };
146
147 } // namespace chromeos
148
149 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_EXTERNAL_UPDATER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698