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