[email protected] | ef9d274 | 2013-02-26 12:48:35 | [diff] [blame] | 1 | // Copyright 2013 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_EXTENSIONS_INSTALL_OBSERVER_H_ |
| 6 | #define CHROME_BROWSER_EXTENSIONS_INSTALL_OBSERVER_H_ |
| 7 | |
[email protected] | 919b2f8 | 2013-10-04 03:11:26 | [diff] [blame] | 8 | #include <string> |
| 9 | |
[email protected] | fa517d0 | 2013-11-18 09:33:09 | [diff] [blame] | 10 | #include "ui/gfx/image/image_skia.h" |
[email protected] | ef9d274 | 2013-02-26 12:48:35 | [diff] [blame] | 11 | |
| 12 | namespace extensions { |
| 13 | |
[email protected] | 67e0a26 | 2013-03-15 13:14:49 | [diff] [blame] | 14 | class Extension; |
| 15 | |
[email protected] | ef9d274 | 2013-02-26 12:48:35 | [diff] [blame] | 16 | class InstallObserver { |
| 17 | public: |
[email protected] | fa517d0 | 2013-11-18 09:33:09 | [diff] [blame] | 18 | struct ExtensionInstallParams { |
| 19 | ExtensionInstallParams( |
| 20 | std::string extension_id, |
| 21 | std::string extension_name, |
| 22 | gfx::ImageSkia installing_icon, |
| 23 | bool is_app, |
| 24 | bool is_platform_app); |
| 25 | |
| 26 | std::string extension_id; |
| 27 | std::string extension_name; |
| 28 | gfx::ImageSkia installing_icon; |
| 29 | bool is_app; |
| 30 | bool is_platform_app; |
| 31 | }; |
| 32 | |
[email protected] | 243c2e52 | 2014-02-27 06:26:27 | [diff] [blame] | 33 | // Called at the beginning of the complete installation process, i.e., this |
| 34 | // is called before the extension download begins. |
[email protected] | c80fe5f | 2014-03-26 04:36:30 | [diff] [blame] | 35 | virtual void OnBeginExtensionInstall(const ExtensionInstallParams& params) {} |
| 36 | |
| 37 | // Called when the Extension begins the download process. This typically |
| 38 | // happens right after OnBeginExtensionInstall(), unless the extension has |
| 39 | // already been downloaded. |
| 40 | virtual void OnBeginExtensionDownload(const std::string& extension_id) {} |
[email protected] | ef9d274 | 2013-02-26 12:48:35 | [diff] [blame] | 41 | |
[email protected] | 243c2e52 | 2014-02-27 06:26:27 | [diff] [blame] | 42 | // Called whenever the extension download is updated. |
| 43 | // Note: Some extensions have multiple modules, so the percent included here |
| 44 | // is a simple calculation of: |
| 45 | // (finished_files * 100 + current_file_progress) / (total files * 100). |
[email protected] | ef9d274 | 2013-02-26 12:48:35 | [diff] [blame] | 46 | virtual void OnDownloadProgress(const std::string& extension_id, |
[email protected] | c80fe5f | 2014-03-26 04:36:30 | [diff] [blame] | 47 | int percent_downloaded) {} |
| 48 | |
| 49 | // Called when the necessary downloads have completed, and the crx |
| 50 | // installation is due to start. |
| 51 | virtual void OnBeginCrxInstall(const std::string& extension_id) {} |
[email protected] | ef9d274 | 2013-02-26 12:48:35 | [diff] [blame] | 52 | |
[email protected] | 73cd487c | 2014-04-16 05:22:50 | [diff] [blame] | 53 | // Called when installation of a crx has completed (either successfully or |
| 54 | // not). |
| 55 | virtual void OnFinishCrxInstall(const std::string& extension_id, |
| 56 | bool success) {} |
| 57 | |
[email protected] | 243c2e52 | 2014-02-27 06:26:27 | [diff] [blame] | 58 | // Called if the extension fails to install. |
[email protected] | c80fe5f | 2014-03-26 04:36:30 | [diff] [blame] | 59 | virtual void OnInstallFailure(const std::string& extension_id) {} |
[email protected] | ef9d274 | 2013-02-26 12:48:35 | [diff] [blame] | 60 | |
[email protected] | b8e45df | 2014-06-11 19:32:36 | [diff] [blame] | 61 | // Called when an extension or an app is installed to the app list. These are |
| 62 | // simply forwarded from the chrome::NOTIFICATIONs. |
[email protected] | c80fe5f | 2014-03-26 04:36:30 | [diff] [blame] | 63 | virtual void OnDisabledExtensionUpdated(const Extension* extension) {} |
[email protected] | 243c2e52 | 2014-02-27 06:26:27 | [diff] [blame] | 64 | |
| 65 | // Called when the app list is reordered. |
[email protected] | c80fe5f | 2014-03-26 04:36:30 | [diff] [blame] | 66 | virtual void OnAppsReordered() {} |
[email protected] | 67e0a26 | 2013-03-15 13:14:49 | [diff] [blame] | 67 | |
[email protected] | 523352c92 | 2013-02-28 01:38:52 | [diff] [blame] | 68 | // Notifies observers that the observed object is going away. |
[email protected] | c80fe5f | 2014-03-26 04:36:30 | [diff] [blame] | 69 | virtual void OnShutdown() {} |
[email protected] | 523352c92 | 2013-02-28 01:38:52 | [diff] [blame] | 70 | |
[email protected] | ef9d274 | 2013-02-26 12:48:35 | [diff] [blame] | 71 | protected: |
| 72 | virtual ~InstallObserver() {} |
| 73 | }; |
| 74 | |
| 75 | } // namespace extensions |
| 76 | |
| 77 | #endif // CHROME_BROWSER_EXTENSIONS_INSTALL_OBSERVER_H_ |