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