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
8#include <string>
9
10#include "ui/gfx/image/image_skia.h"
11
12namespace extensions {
13
14class Extension;
15
16class InstallObserver {
17 public:
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    bool is_ephemeral;
32  };
33
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) {}
37
38  // Called when the Extension begins the download process. This typically
39  // happens right after OnBeginExtensionInstall(), unless the extension has
40  // already been downloaded.
41  virtual void OnBeginExtensionDownload(const std::string& extension_id) {}
42
43  // Called whenever the extension download is updated.
44  // Note: Some extensions have multiple modules, so the percent included here
45  // is a simple calculation of:
46  // (finished_files * 100 + current_file_progress) / (total files * 100).
47  virtual void OnDownloadProgress(const std::string& extension_id,
48                                  int percent_downloaded) {}
49
50  // Called when the necessary downloads have completed, and the crx
51  // installation is due to start.
52  virtual void OnBeginCrxInstall(const std::string& extension_id) {}
53
54  // Called when installation of a crx has completed (either successfully or
55  // not).
56  virtual void OnFinishCrxInstall(const std::string& extension_id,
57                                  bool success) {}
58
59  // Called if the extension fails to install.
60  virtual void OnInstallFailure(const std::string& extension_id) {}
61
62  // Called when an extension or an app is installed to the app list. These are
63  // simply forwarded from the chrome::NOTIFICATIONs.
64  virtual void OnDisabledExtensionUpdated(const Extension* extension) {}
65  virtual void OnAppInstalledToAppList(const std::string& extension_id) {}
66
67  // Called when the app list is reordered.
68  virtual void OnAppsReordered() {}
69
70  // Notifies observers that the observed object is going away.
71  virtual void OnShutdown() {}
72
73 protected:
74  virtual ~InstallObserver() {}
75};
76
77}  // namespace extensions
78
79#endif  // CHROME_BROWSER_EXTENSIONS_INSTALL_OBSERVER_H_
80