OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 EXTENSIONS_BROWSER_PENDING_EXTENSION_MANAGER_H_ | 5 #ifndef EXTENSIONS_BROWSER_PENDING_EXTENSION_MANAGER_H_ |
6 #define EXTENSIONS_BROWSER_PENDING_EXTENSION_MANAGER_H_ | 6 #define EXTENSIONS_BROWSER_PENDING_EXTENSION_MANAGER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "extensions/browser/pending_extension_info.h" | 11 #include "extensions/browser/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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // to set an inital state. Use friendship to allow the tests to call this | 136 // to set an inital state. Use friendship to allow the tests to call this |
132 // method. | 137 // method. |
133 void AddForTesting(const PendingExtensionInfo& pending_extension_info); | 138 void AddForTesting(const PendingExtensionInfo& pending_extension_info); |
134 | 139 |
135 // Reference to the extension service whose pending extensions this class is | 140 // Reference to the extension service whose pending extensions this class is |
136 // managing. Because this class is a member of |service_|, it is created | 141 // managing. Because this class is a member of |service_|, it is created |
137 // and destroyed with |service_|. We only use methods from the interface | 142 // and destroyed with |service_|. We only use methods from the interface |
138 // ExtensionServiceInterface. | 143 // ExtensionServiceInterface. |
139 const ExtensionServiceInterface& service_; | 144 const ExtensionServiceInterface& service_; |
140 | 145 |
| 146 // The BrowserContext with which the manager is associated. |
| 147 content::BrowserContext* context_; |
| 148 |
141 PendingExtensionList pending_extension_list_; | 149 PendingExtensionList pending_extension_list_; |
142 | 150 |
143 FRIEND_TEST_ALL_PREFIXES(::ExtensionServiceTest, | 151 FRIEND_TEST_ALL_PREFIXES(::ExtensionServiceTest, |
144 UpdatePendingExtensionAlreadyInstalled); | 152 UpdatePendingExtensionAlreadyInstalled); |
145 friend class ExtensionUpdaterTest; | 153 friend class ExtensionUpdaterTest; |
146 friend void SetupPendingExtensionManagerForTest( | 154 friend void SetupPendingExtensionManagerForTest( |
147 int count, const GURL& update_url, | 155 int count, const GURL& update_url, |
148 PendingExtensionManager* pending_extension_manager); | 156 PendingExtensionManager* pending_extension_manager); |
149 | 157 |
150 DISALLOW_COPY_AND_ASSIGN(PendingExtensionManager); | 158 DISALLOW_COPY_AND_ASSIGN(PendingExtensionManager); |
151 }; | 159 }; |
152 | 160 |
153 } // namespace extensions | 161 } // namespace extensions |
154 | 162 |
155 #endif // EXTENSIONS_BROWSER_PENDING_EXTENSION_MANAGER_H_ | 163 #endif // EXTENSIONS_BROWSER_PENDING_EXTENSION_MANAGER_H_ |
OLD | NEW |