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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
| 10 #include <list> |
10 | 11 |
11 #include "base/file_path.h" | 12 #include "base/file_path.h" |
12 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
13 #include "base/ref_counted.h" | 14 #include "base/ref_counted.h" |
14 #include "base/task.h" | 15 #include "base/task.h" |
15 #include "base/values.h" | 16 #include "base/values.h" |
16 | 17 |
17 class Browser; | 18 class Browser; |
18 class BrowsingInstance; | 19 class BrowsingInstance; |
19 class Extension; | 20 class Extension; |
| 21 class ExtensionHost; |
20 class ExtensionView; | 22 class ExtensionView; |
21 class ExtensionsServiceBackend; | 23 class ExtensionsServiceBackend; |
22 class GURL; | 24 class GURL; |
23 class Profile; | 25 class Profile; |
24 class SiteInstance; | 26 class SiteInstance; |
25 class UserScriptMaster; | 27 class UserScriptMaster; |
26 typedef std::vector<Extension*> ExtensionList; | 28 typedef std::vector<Extension*> ExtensionList; |
27 | 29 |
28 // Interface for the frontend to implement. Typically, this will be | 30 // Interface for the frontend to implement. Typically, this will be |
29 // ExtensionsService, but it can also be a test harness. | 31 // ExtensionsService, but it can also be a test harness. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 virtual void LoadExtension(const FilePath& extension_path); | 77 virtual void LoadExtension(const FilePath& extension_path); |
76 virtual void OnExtensionsLoaded(ExtensionList* extensions); | 78 virtual void OnExtensionsLoaded(ExtensionList* extensions); |
77 virtual void OnExtensionInstalled(FilePath path, bool is_update); | 79 virtual void OnExtensionInstalled(FilePath path, bool is_update); |
78 | 80 |
79 // Creates a new ExtensionView, grouping it in the appropriate SiteInstance | 81 // Creates a new ExtensionView, grouping it in the appropriate SiteInstance |
80 // (and therefore process) based on the URL and profile. | 82 // (and therefore process) based on the URL and profile. |
81 ExtensionView* CreateView(Extension* extension, | 83 ExtensionView* CreateView(Extension* extension, |
82 const GURL& url, | 84 const GURL& url, |
83 Browser* browser); | 85 Browser* browser); |
84 | 86 |
| 87 // Creates a new UI-less extension instance. Like CreateView, but not |
| 88 // displayed anywhere. |
| 89 void CreateBackgroundHost(Extension* extension, const GURL& url); |
| 90 |
85 // Returns the SiteInstance that the given URL belongs to. | 91 // Returns the SiteInstance that the given URL belongs to. |
86 SiteInstance* GetSiteInstanceForURL(const GURL& url); | 92 SiteInstance* GetSiteInstanceForURL(const GURL& url); |
87 | 93 |
88 // The name of the file that the current active version number is stored in. | 94 // The name of the file that the current active version number is stored in. |
89 static const char* kCurrentVersionFileName; | 95 static const char* kCurrentVersionFileName; |
90 | 96 |
91 private: | 97 private: |
92 // The name of the directory inside the profile where extensions are | 98 // The name of the directory inside the profile where extensions are |
93 // installed to. | 99 // installed to. |
94 static const char* kInstallDirectoryName; | 100 static const char* kInstallDirectoryName; |
(...skipping 10 matching lines...) Expand all Loading... |
105 // The backend that will do IO on behalf of this instance. | 111 // The backend that will do IO on behalf of this instance. |
106 scoped_refptr<ExtensionsServiceBackend> backend_; | 112 scoped_refptr<ExtensionsServiceBackend> backend_; |
107 | 113 |
108 // The user script master for this profile. | 114 // The user script master for this profile. |
109 scoped_refptr<UserScriptMaster> user_script_master_; | 115 scoped_refptr<UserScriptMaster> user_script_master_; |
110 | 116 |
111 // The BrowsingInstance shared by all extensions in this profile. This | 117 // The BrowsingInstance shared by all extensions in this profile. This |
112 // controls process grouping. | 118 // controls process grouping. |
113 scoped_refptr<BrowsingInstance> browsing_instance_; | 119 scoped_refptr<BrowsingInstance> browsing_instance_; |
114 | 120 |
| 121 // The list of running viewless background extensions. |
| 122 typedef std::list<ExtensionHost*> ExtensionHostList; |
| 123 ExtensionHostList background_hosts_; |
| 124 |
115 DISALLOW_COPY_AND_ASSIGN(ExtensionsService); | 125 DISALLOW_COPY_AND_ASSIGN(ExtensionsService); |
116 }; | 126 }; |
117 | 127 |
118 // Implements IO for the ExtensionsService. | 128 // Implements IO for the ExtensionsService. |
119 // TODO(aa): Extract an interface out of this for testing the frontend, once the | 129 // TODO(aa): Extract an interface out of this for testing the frontend, once the |
120 // frontend has significant logic to test. | 130 // frontend has significant logic to test. |
121 class ExtensionsServiceBackend | 131 class ExtensionsServiceBackend |
122 : public base::RefCountedThreadSafe<ExtensionsServiceBackend> { | 132 : public base::RefCountedThreadSafe<ExtensionsServiceBackend> { |
123 public: | 133 public: |
124 explicit ExtensionsServiceBackend(const FilePath& install_directory) | 134 explicit ExtensionsServiceBackend(const FilePath& install_directory) |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 // The top-level extensions directory being installed to. | 247 // The top-level extensions directory being installed to. |
238 FilePath install_directory_; | 248 FilePath install_directory_; |
239 | 249 |
240 // Whether errors result in noisy alerts. | 250 // Whether errors result in noisy alerts. |
241 bool alert_on_error_; | 251 bool alert_on_error_; |
242 | 252 |
243 DISALLOW_COPY_AND_ASSIGN(ExtensionsServiceBackend); | 253 DISALLOW_COPY_AND_ASSIGN(ExtensionsServiceBackend); |
244 }; | 254 }; |
245 | 255 |
246 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ | 256 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ |
OLD | NEW |