Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / extensions / browser / external_provider_interface.h
blob801f4ede5640de99259898da3c2b0e22cbb9e336
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_
8 #include <vector>
10 #include "base/memory/linked_ptr.h"
11 #include "extensions/common/manifest.h"
13 class GURL;
15 namespace base {
16 class FilePath;
17 class Version;
20 namespace extensions {
22 // This class is an abstract class for implementing external extensions
23 // providers.
24 class ExternalProviderInterface {
25 public:
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 {
33 public:
34 // Return true if the extension install will proceed. Install will not
35 // proceed if the extension is already installed from a higher priority
36 // location.
37 virtual bool OnExternalExtensionFileFound(
38 const std::string& id,
39 const base::Version* version,
40 const base::FilePath& path,
41 Manifest::Location location,
42 int creation_flags,
43 bool mark_acknowledged,
44 bool install_immediately) = 0;
46 // Return true if the extension install will proceed. Install might not
47 // proceed if the extension is already installed from a higher priority
48 // location.
49 virtual bool OnExternalExtensionUpdateUrlFound(
50 const std::string& id,
51 const std::string& install_parameter,
52 const GURL& update_url,
53 Manifest::Location location,
54 int creation_flags,
55 bool mark_acknowledged) = 0;
57 // Called after all the external extensions have been reported
58 // through the above two methods. |provider| is a pointer to the
59 // provider that is now ready (typically this), and the
60 // implementation of OnExternalProviderReady() should be able to
61 // safely assert that provider->IsReady().
62 virtual void OnExternalProviderReady(
63 const ExternalProviderInterface* provider) = 0;
65 protected:
66 virtual ~VisitorInterface() {}
69 virtual ~ExternalProviderInterface() {}
71 // The visitor (ExtensionsService) calls this function before it goes away.
72 virtual void ServiceShutdown() = 0;
74 // Enumerate registered extensions, calling
75 // OnExternalExtension(File|UpdateUrl)Found on the |visitor| object for each
76 // registered extension found.
77 virtual void VisitRegisteredExtension() = 0;
79 // Test if this provider has an extension with id |id| registered.
80 virtual bool HasExtension(const std::string& id) const = 0;
82 // Gets details of an extension by its id. Output params will be set only
83 // if they are not NULL. If an output parameter is not specified by the
84 // provider type, it will not be changed.
85 // This function is no longer used outside unit tests.
86 virtual bool GetExtensionDetails(
87 const std::string& id,
88 Manifest::Location* location,
89 scoped_ptr<base::Version>* version) const = 0;
91 // Determines if this provider had loaded the list of external extensions
92 // from its source.
93 virtual bool IsReady() const = 0;
96 typedef std::vector<linked_ptr<ExternalProviderInterface> >
97 ProviderCollection;
99 } // namespace extensions
101 #endif // EXTENSIONS_BROWSER_EXTERNAL_PROVIDER_INTERFACE_H_