Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / install_observer.h
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
12 namespace extensions {
13
14 class Extension;
15
16 class 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 if the installation succeeds.
63   virtual void OnExtensionInstalled(const Extension* extension) {}
64
65   // Called when an extension is [Loaded, Unloaded, Uninstalled] or an app is
66   // installed to the app list. These are simply forwarded from the
67   // chrome::NOTIFICATIONs.
68   virtual void OnExtensionLoaded(const Extension* extension) {}
69   virtual void OnExtensionUnloaded(const Extension* extension) {}
70   virtual void OnExtensionUninstalled(const Extension* extension) {}
71   virtual void OnDisabledExtensionUpdated(const Extension* extension) {}
72   virtual void OnAppInstalledToAppList(const std::string& extension_id) {}
73
74   // Called when the app list is reordered.
75   virtual void OnAppsReordered() {}
76
77   // Notifies observers that the observed object is going away.
78   virtual void OnShutdown() {}
79
80  protected:
81   virtual ~InstallObserver() {}
82 };
83
84 }  // namespace extensions
85
86 #endif  // CHROME_BROWSER_EXTENSIONS_INSTALL_OBSERVER_H_