OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PENDING_EXTENSION_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_MANAGER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_MANAGER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_MANAGER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "chrome/browser/extensions/pending_extension_info.h" | 11 #include "chrome/browser/extensions/pending_extension_info.h" |
12 #include "extensions/common/manifest.h" | 12 #include "extensions/common/manifest.h" |
13 | 13 |
14 class ExtensionServiceInterface; | 14 class ExtensionServiceInterface; |
15 class GURL; | 15 class GURL; |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class Version; | 18 class Version; |
19 } | 19 } |
20 | 20 |
| 21 namespace content { |
| 22 class BrowserContext; |
| 23 } |
| 24 |
21 FORWARD_DECLARE_TEST(ExtensionServiceTest, | 25 FORWARD_DECLARE_TEST(ExtensionServiceTest, |
22 UpdatePendingExtensionAlreadyInstalled); | 26 UpdatePendingExtensionAlreadyInstalled); |
23 | 27 |
24 namespace extensions { | 28 namespace extensions { |
25 class Extension; | 29 class Extension; |
26 class PendingExtensionManager; | 30 class PendingExtensionManager; |
27 | 31 |
28 class ExtensionUpdaterTest; | 32 class ExtensionUpdaterTest; |
29 void SetupPendingExtensionManagerForTest( | 33 void SetupPendingExtensionManagerForTest( |
30 int count, const GURL& update_url, | 34 int count, const GURL& update_url, |
31 PendingExtensionManager* pending_extension_manager); | 35 PendingExtensionManager* pending_extension_manager); |
32 | 36 |
33 // Class PendingExtensionManager manages the set of extensions which are | 37 // Class PendingExtensionManager manages the set of extensions which are |
34 // being installed or updated. In general, installation and updates take | 38 // being installed or updated. In general, installation and updates take |
35 // time, because they involve downloading, unpacking, and installing. | 39 // time, because they involve downloading, unpacking, and installing. |
36 // This class allows us to avoid race cases where multiple sources install | 40 // This class allows us to avoid race cases where multiple sources install |
37 // the same extension. | 41 // the same extension. |
38 // The extensions service creates an instance of this class, and manages | 42 // The extensions service creates an instance of this class, and manages |
39 // its lifetime. This class should only be used from the UI thread. | 43 // its lifetime. This class should only be used from the UI thread. |
40 class PendingExtensionManager { | 44 class PendingExtensionManager { |
41 public: | 45 public: |
42 // |service| is a reference to the ExtensionService whose pending | 46 // |service| is a reference to the ExtensionService whose pending |
43 // extensions we are managing. The service creates an instance of | 47 // extensions we are managing. The service creates an instance of |
44 // this class on construction, and destroys it on destruction. | 48 // this class on construction, and destroys it on destruction. |
45 // The service remains valid over the entire lifetime of this class. | 49 // The service remains valid over the entire lifetime of this class. |
46 explicit PendingExtensionManager(const ExtensionServiceInterface& service); | 50 explicit PendingExtensionManager(const ExtensionServiceInterface& service, |
| 51 content::BrowserContext* context); |
47 ~PendingExtensionManager(); | 52 ~PendingExtensionManager(); |
48 | 53 |
49 // TODO(skerner): Many of these methods can be private once code in | 54 // TODO(skerner): Many of these methods can be private once code in |
50 // ExtensionService is moved into methods of this class. | 55 // ExtensionService is moved into methods of this class. |
51 | 56 |
52 // Remove extension with id |id| from the set of pending extensions. Returns | 57 // Remove extension with id |id| from the set of pending extensions. Returns |
53 // true if such an extension was found and removed, false otherwise. | 58 // true if such an extension was found and removed, false otherwise. |
54 bool Remove(const std::string& id); | 59 bool Remove(const std::string& id); |
55 | 60 |
56 // Get the information for a pending extension. Returns a pointer to the | 61 // Get the information for a pending extension. Returns a pointer to the |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // to set an inital state. Use friendship to allow the tests to call this | 138 // to set an inital state. Use friendship to allow the tests to call this |
134 // method. | 139 // method. |
135 void AddForTesting(const PendingExtensionInfo& pending_extension_info); | 140 void AddForTesting(const PendingExtensionInfo& pending_extension_info); |
136 | 141 |
137 // Reference to the extension service whose pending extensions this class is | 142 // Reference to the extension service whose pending extensions this class is |
138 // managing. Because this class is a member of |service_|, it is created | 143 // managing. Because this class is a member of |service_|, it is created |
139 // and destroyed with |service_|. We only use methods from the interface | 144 // and destroyed with |service_|. We only use methods from the interface |
140 // ExtensionServiceInterface. | 145 // ExtensionServiceInterface. |
141 const ExtensionServiceInterface& service_; | 146 const ExtensionServiceInterface& service_; |
142 | 147 |
| 148 // The BrowserContext with which the manager is associated. |
| 149 content::BrowserContext* context_; |
| 150 |
143 PendingExtensionList pending_extension_list_; | 151 PendingExtensionList pending_extension_list_; |
144 | 152 |
145 FRIEND_TEST_ALL_PREFIXES(::ExtensionServiceTest, | 153 FRIEND_TEST_ALL_PREFIXES(::ExtensionServiceTest, |
146 UpdatePendingExtensionAlreadyInstalled); | 154 UpdatePendingExtensionAlreadyInstalled); |
147 friend class ExtensionUpdaterTest; | 155 friend class ExtensionUpdaterTest; |
148 friend void SetupPendingExtensionManagerForTest( | 156 friend void SetupPendingExtensionManagerForTest( |
149 int count, const GURL& update_url, | 157 int count, const GURL& update_url, |
150 PendingExtensionManager* pending_extension_manager); | 158 PendingExtensionManager* pending_extension_manager); |
151 | 159 |
152 DISALLOW_COPY_AND_ASSIGN(PendingExtensionManager); | 160 DISALLOW_COPY_AND_ASSIGN(PendingExtensionManager); |
153 }; | 161 }; |
154 | 162 |
155 } // namespace extensions | 163 } // namespace extensions |
156 | 164 |
157 #endif // CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_MANAGER_H_ | 165 #endif // CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_MANAGER_H_ |
OLD | NEW |