blob: 31573b66a214cef9215e614484acef6450cc75a8 [file] [log] [blame]
[email protected]45f5b7d2014-01-22 23:47:131// 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 EXTENSIONS_BROWSER_EXTENSION_REGISTRY_OBSERVER_H_
6#define EXTENSIONS_BROWSER_EXTENSION_REGISTRY_OBSERVER_H_
7
[email protected]e43c61f2014-07-20 21:46:348#include "extensions/browser/uninstall_reason.h"
[email protected]e51232f32014-04-18 20:05:369#include "extensions/common/extension.h"
10
[email protected]50703fc2014-04-08 04:01:0611namespace content {
12class BrowserContext;
13}
14
[email protected]45f5b7d2014-01-22 23:47:1315namespace extensions {
16
17class Extension;
[email protected]a9b55a12014-06-06 14:08:4518class ExtensionRegistry;
[email protected]e51232f32014-04-18 20:05:3619struct UnloadedExtensionInfo;
[email protected]45f5b7d2014-01-22 23:47:1320
21// Observer for ExtensionRegistry. Exists in a separate header file to reduce
22// the include file burden for typical clients of ExtensionRegistry.
23class ExtensionRegistryObserver {
24 public:
25 virtual ~ExtensionRegistryObserver() {}
26
[email protected]dcc47642014-03-26 22:03:4927 // Called after an extension is loaded. The extension will exclusively exist
28 // in the enabled_extensions set of ExtensionRegistry.
[email protected]50703fc2014-04-08 04:01:0629 virtual void OnExtensionLoaded(
30 content::BrowserContext* browser_context,
31 const Extension* extension) {}
[email protected]dcc47642014-03-26 22:03:4932
[email protected]45f5b7d2014-01-22 23:47:1333 // Called after an extension is unloaded. The extension no longer exists in
34 // any of the ExtensionRegistry sets (enabled, disabled, etc.).
[email protected]e51232f32014-04-18 20:05:3635 virtual void OnExtensionUnloaded(content::BrowserContext* browser_context,
36 const Extension* extension,
37 UnloadedExtensionInfo::Reason reason) {}
[email protected]17f07822014-05-22 08:45:1538
39 // Called when |extension| is about to be installed. |is_update| is true if
40 // the installation is the result of it updating, in which case |old_name| is
41 // the name of the extension's previous version.
[email protected]760f743b2014-05-28 13:52:0242 // If true, |from_ephemeral| indicates that the extension was previously
43 // installed ephemerally and has been promoted to a regular installed
44 // extension. |is_update| will be true, although the version has not
45 // necessarily changed.
[email protected]17f07822014-05-22 08:45:1546 // The ExtensionRegistry will not be tracking |extension| at the time this
47 // event is fired, but will be immediately afterwards (note: not necessarily
48 // enabled; it might be installed in the disabled or even blacklisted sets,
49 // for example).
50 // Note that it's much more common to care about extensions being loaded
51 // (OnExtensionLoaded).
[email protected]760f743b2014-05-28 13:52:0252 //
53 // TODO(tmdiep): We should stash the state of the previous extension version
54 // somewhere and have observers retrieve it. |is_update|, |from_ephemeral|
55 // and |old_name| can be removed when this is done.
[email protected]17f07822014-05-22 08:45:1556 virtual void OnExtensionWillBeInstalled(
57 content::BrowserContext* browser_context,
58 const Extension* extension,
59 bool is_update,
[email protected]760f743b2014-05-28 13:52:0260 bool from_ephemeral,
[email protected]17f07822014-05-22 08:45:1561 const std::string& old_name) {}
[email protected]1d7f2482014-05-24 00:11:5162
[email protected]bc44b5da2014-06-12 14:20:0063 // Called when the installation of |extension| is complete. At this point the
64 // extension is tracked in one of the ExtensionRegistry sets, but is not
65 // necessarily enabled.
66 virtual void OnExtensionInstalled(content::BrowserContext* browser_context,
[email protected]38e872532014-07-16 23:27:5167 const Extension* extension,
68 bool is_update) {}
[email protected]bc44b5da2014-06-12 14:20:0069
70 // Called after an extension is uninstalled. The extension no longer exists in
[email protected]1d7f2482014-05-24 00:11:5171 // any of the ExtensionRegistry sets (enabled, disabled, etc.).
72 virtual void OnExtensionUninstalled(content::BrowserContext* browser_context,
[email protected]e43c61f2014-07-20 21:46:3473 const Extension* extension,
74 UninstallReason reason) {}
[email protected]a9b55a12014-06-06 14:08:4575
76 // Notifies observers that the observed object is going away.
77 virtual void OnShutdown(ExtensionRegistry* registry) {}
[email protected]45f5b7d2014-01-22 23:47:1378};
79
[email protected]50703fc2014-04-08 04:01:0680} // namespace extensions
[email protected]45f5b7d2014-01-22 23:47:1381
82#endif // EXTENSIONS_BROWSER_EXTENSION_REGISTRY_OBSERVER_H_