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