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.
5 #ifndef EXTENSIONS_BROWSER_EXTERNAL_PROVIDER_INTERFACE_H_
6 #define EXTENSIONS_BROWSER_EXTERNAL_PROVIDER_INTERFACE_H_
10 #include "base/memory/linked_ptr.h"
11 #include "extensions/common/manifest.h"
20 namespace extensions
{
22 // This class is an abstract class for implementing external extensions
24 class ExternalProviderInterface
{
26 // ExternalProvider uses this interface to communicate back to the
27 // caller what extensions are registered, and which |id|, |version| and |path|
28 // they have. See also VisitRegisteredExtension below. Ownership of |version|
29 // is not transferred to the visitor. Callers of the methods below must
30 // ensure that |id| is a valid extension id (use
31 // crx_file::id_util::IdIsValid(id)).
32 class VisitorInterface
{
34 // Return true if the extension install will proceed. Install will not
35 // proceed if the extension is already installed from a higher priority
37 virtual bool OnExternalExtensionFileFound(
38 const std::string
& id
,
39 const base::Version
* version
,
40 const base::FilePath
& path
,
41 Manifest::Location location
,
43 bool mark_acknowledged
) = 0;
45 // Return true if the extension install will proceed. Install might not
46 // proceed if the extension is already installed from a higher priority
48 virtual bool OnExternalExtensionUpdateUrlFound(
49 const std::string
& id
,
50 const std::string
& install_parameter
,
51 const GURL
& update_url
,
52 Manifest::Location location
,
54 bool mark_acknowledged
) = 0;
56 // Called after all the external extensions have been reported
57 // through the above two methods. |provider| is a pointer to the
58 // provider that is now ready (typically this), and the
59 // implementation of OnExternalProviderReady() should be able to
60 // safely assert that provider->IsReady().
61 virtual void OnExternalProviderReady(
62 const ExternalProviderInterface
* provider
) = 0;
65 virtual ~VisitorInterface() {}
68 virtual ~ExternalProviderInterface() {}
70 // The visitor (ExtensionsService) calls this function before it goes away.
71 virtual void ServiceShutdown() = 0;
73 // Enumerate registered extensions, calling
74 // OnExternalExtension(File|UpdateUrl)Found on the |visitor| object for each
75 // registered extension found.
76 virtual void VisitRegisteredExtension() = 0;
78 // Test if this provider has an extension with id |id| registered.
79 virtual bool HasExtension(const std::string
& id
) const = 0;
81 // Gets details of an extension by its id. Output params will be set only
82 // if they are not NULL. If an output parameter is not specified by the
83 // provider type, it will not be changed.
84 // This function is no longer used outside unit tests.
85 virtual bool GetExtensionDetails(
86 const std::string
& id
,
87 Manifest::Location
* location
,
88 scoped_ptr
<base::Version
>* version
) const = 0;
90 // Determines if this provider had loaded the list of external extensions
92 virtual bool IsReady() const = 0;
95 typedef std::vector
<linked_ptr
<ExternalProviderInterface
> >
98 } // namespace extensions
100 #endif // EXTENSIONS_BROWSER_EXTERNAL_PROVIDER_INTERFACE_H_