| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_EXTENSIONS_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
| 13 #include "base/task.h" | 13 #include "base/task.h" |
| 14 #include "chrome/browser/extensions/extension.h" | 14 #include "chrome/browser/extensions/extension.h" |
| 15 | 15 |
| 16 typedef std::vector<Extension*> ExtensionList; | 16 typedef std::vector<Extension*> ExtensionList; |
| 17 class ExtensionsServiceBackend; | 17 class ExtensionsServiceBackend; |
| 18 class UserScriptMaster; |
| 18 | 19 |
| 19 // Interface for the frontend to implement. Typically, this will be | 20 // Interface for the frontend to implement. Typically, this will be |
| 20 // ExtensionsService, but it can also be a test harness. | 21 // ExtensionsService, but it can also be a test harness. |
| 21 class ExtensionsServiceFrontendInterface | 22 class ExtensionsServiceFrontendInterface |
| 22 : public base::RefCountedThreadSafe<ExtensionsServiceFrontendInterface> { | 23 : public base::RefCountedThreadSafe<ExtensionsServiceFrontendInterface> { |
| 23 public: | 24 public: |
| 24 virtual ~ExtensionsServiceFrontendInterface(){} | 25 virtual ~ExtensionsServiceFrontendInterface(){} |
| 25 | 26 |
| 26 // The message loop to invoke the frontend's methods on. | 27 // The message loop to invoke the frontend's methods on. |
| 27 virtual MessageLoop* GetMessageLoop() = 0; | 28 virtual MessageLoop* GetMessageLoop() = 0; |
| 28 | 29 |
| 29 // Called when loading an extension fails. | 30 // Called when loading an extension fails. |
| 30 virtual void OnExtensionLoadError(const std::string& message) = 0; | 31 virtual void OnExtensionLoadError(const std::string& message) = 0; |
| 31 | 32 |
| 32 // Called with results from LoadExtensionsFromDirectory(). The frontend | 33 // Called with results from LoadExtensionsFromDirectory(). The frontend |
| 33 // takes ownership of the list. | 34 // takes ownership of the list. |
| 34 virtual void OnExtensionsLoadedFromDirectory(ExtensionList* extensions) = 0; | 35 virtual void OnExtensionsLoadedFromDirectory(ExtensionList* extensions) = 0; |
| 35 }; | 36 }; |
| 36 | 37 |
| 37 | 38 |
| 38 // Manages installed and running Chromium extensions. | 39 // Manages installed and running Chromium extensions. |
| 39 class ExtensionsService : public ExtensionsServiceFrontendInterface { | 40 class ExtensionsService : public ExtensionsServiceFrontendInterface { |
| 40 public: | 41 public: |
| 41 ExtensionsService(const FilePath& profile_directory); | 42 ExtensionsService(const FilePath& profile_directory, |
| 43 UserScriptMaster* user_script_master); |
| 42 ~ExtensionsService(); | 44 ~ExtensionsService(); |
| 43 | 45 |
| 44 // Gets the list of currently installed extensions. | 46 // Gets the list of currently installed extensions. |
| 45 const ExtensionList* extensions() const { | 47 const ExtensionList* extensions() const { |
| 46 return &extensions_; | 48 return &extensions_; |
| 47 } | 49 } |
| 48 | 50 |
| 49 // Initialize and start all installed extensions. | 51 // Initialize and start all installed extensions. |
| 50 bool Init(); | 52 bool Init(); |
| 51 | 53 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 64 | 66 |
| 65 // The backend that will do IO on behalf of this instance. | 67 // The backend that will do IO on behalf of this instance. |
| 66 scoped_refptr<ExtensionsServiceBackend> backend_; | 68 scoped_refptr<ExtensionsServiceBackend> backend_; |
| 67 | 69 |
| 68 // The current list of installed extensions. | 70 // The current list of installed extensions. |
| 69 ExtensionList extensions_; | 71 ExtensionList extensions_; |
| 70 | 72 |
| 71 // The full path to the directory where extensions are installed. | 73 // The full path to the directory where extensions are installed. |
| 72 FilePath install_directory_; | 74 FilePath install_directory_; |
| 73 | 75 |
| 76 // The user script master for this profile. |
| 77 scoped_refptr<UserScriptMaster> user_script_master_; |
| 78 |
| 74 DISALLOW_COPY_AND_ASSIGN(ExtensionsService); | 79 DISALLOW_COPY_AND_ASSIGN(ExtensionsService); |
| 75 }; | 80 }; |
| 76 | 81 |
| 77 // Implements IO for the ExtensionsService. | 82 // Implements IO for the ExtensionsService. |
| 78 // TODO(aa): Extract an interface out of this for testing the frontend, once the | 83 // TODO(aa): Extract an interface out of this for testing the frontend, once the |
| 79 // frontend has significant logic to test. | 84 // frontend has significant logic to test. |
| 80 class ExtensionsServiceBackend | 85 class ExtensionsServiceBackend |
| 81 : public base::RefCountedThreadSafe<ExtensionsServiceBackend> { | 86 : public base::RefCountedThreadSafe<ExtensionsServiceBackend> { |
| 82 public: | 87 public: |
| 83 ExtensionsServiceBackend(){}; | 88 ExtensionsServiceBackend(){}; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 98 const std::string& error); | 103 const std::string& error); |
| 99 | 104 |
| 100 // Notify a frontend that extensions were loaded. | 105 // Notify a frontend that extensions were loaded. |
| 101 void ReportExtensionsLoaded(ExtensionsServiceFrontendInterface* frontend, | 106 void ReportExtensionsLoaded(ExtensionsServiceFrontendInterface* frontend, |
| 102 ExtensionList* extensions); | 107 ExtensionList* extensions); |
| 103 | 108 |
| 104 DISALLOW_COPY_AND_ASSIGN(ExtensionsServiceBackend); | 109 DISALLOW_COPY_AND_ASSIGN(ExtensionsServiceBackend); |
| 105 }; | 110 }; |
| 106 | 111 |
| 107 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ | 112 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ |
| OLD | NEW |