[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; |
[email protected] | ce35418b | 2013-11-25 01:22:33 | [diff] [blame] | 31 | bool is_ephemeral; |
[email protected] | fa517d0 | 2013-11-18 09:33:09 | [diff] [blame] | 32 | }; |
| 33 | |
[email protected] | 243c2e52 | 2014-02-27 06:26:27 | [diff] [blame^] | 34 | // Called at the beginning of the complete installation process, i.e., this |
| 35 | // is called before the extension download begins. |
| 36 | virtual void OnBeginExtensionInstall(const ExtensionInstallParams& params); |
[email protected] | ef9d274 | 2013-02-26 12:48:35 | [diff] [blame] | 37 | |
[email protected] | 243c2e52 | 2014-02-27 06:26:27 | [diff] [blame^] | 38 | // Called whenever the extension download is updated. |
| 39 | // Note: Some extensions have multiple modules, so the percent included here |
| 40 | // is a simple calculation of: |
| 41 | // (finished_files * 100 + current_file_progress) / (total files * 100). |
[email protected] | ef9d274 | 2013-02-26 12:48:35 | [diff] [blame] | 42 | virtual void OnDownloadProgress(const std::string& extension_id, |
[email protected] | 243c2e52 | 2014-02-27 06:26:27 | [diff] [blame^] | 43 | int percent_downloaded); |
[email protected] | ef9d274 | 2013-02-26 12:48:35 | [diff] [blame] | 44 | |
[email protected] | 243c2e52 | 2014-02-27 06:26:27 | [diff] [blame^] | 45 | // Called if the extension fails to install. |
| 46 | virtual void OnInstallFailure(const std::string& extension_id); |
[email protected] | ef9d274 | 2013-02-26 12:48:35 | [diff] [blame] | 47 | |
[email protected] | 243c2e52 | 2014-02-27 06:26:27 | [diff] [blame^] | 48 | // Called if the installation succeeds. |
| 49 | virtual void OnExtensionInstalled(const Extension* extension); |
| 50 | |
| 51 | // Called when an extension is [Loaded, Unloaded, Uninstalled] or an app is |
| 52 | // installed to the app list. These are simply forwarded from the |
| 53 | // chrome::NOTIFICATIONs. |
| 54 | virtual void OnExtensionLoaded(const Extension* extension); |
| 55 | virtual void OnExtensionUnloaded(const Extension* extension); |
| 56 | virtual void OnExtensionUninstalled(const Extension* extension); |
| 57 | virtual void OnAppInstalledToAppList(const std::string& extension_id); |
| 58 | |
| 59 | // Called when the app list is reordered. |
| 60 | virtual void OnAppsReordered(); |
[email protected] | 67e0a26 | 2013-03-15 13:14:49 | [diff] [blame] | 61 | |
[email protected] | 523352c92 | 2013-02-28 01:38:52 | [diff] [blame] | 62 | // Notifies observers that the observed object is going away. |
[email protected] | 243c2e52 | 2014-02-27 06:26:27 | [diff] [blame^] | 63 | virtual void OnShutdown(); |
[email protected] | 523352c92 | 2013-02-28 01:38:52 | [diff] [blame] | 64 | |
[email protected] | ef9d274 | 2013-02-26 12:48:35 | [diff] [blame] | 65 | protected: |
| 66 | virtual ~InstallObserver() {} |
| 67 | }; |
| 68 | |
| 69 | } // namespace extensions |
| 70 | |
| 71 | #endif // CHROME_BROWSER_EXTENSIONS_INSTALL_OBSERVER_H_ |