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 <map> |
9 #include <string> | 10 #include <string> |
10 | 11 |
11 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/time/time.h" |
13 #include "chrome/browser/extensions/pending_extension_info.h" | 15 #include "chrome/browser/extensions/pending_extension_info.h" |
| 16 #include "extensions/common/extension_id.h" |
14 #include "extensions/common/manifest.h" | 17 #include "extensions/common/manifest.h" |
15 | 18 |
16 class GURL; | 19 class GURL; |
17 | 20 |
18 namespace base { | 21 namespace base { |
19 class Version; | 22 class Version; |
20 } | 23 } |
21 | 24 |
22 namespace content { | 25 namespace content { |
23 class BrowserContext; | 26 class BrowserContext; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 63 |
61 // Is |id| in the set of pending extensions? | 64 // Is |id| in the set of pending extensions? |
62 bool IsIdPending(const std::string& id) const; | 65 bool IsIdPending(const std::string& id) const; |
63 | 66 |
64 // Returns true if there are any extensions pending. | 67 // Returns true if there are any extensions pending. |
65 bool HasPendingExtensions() const; | 68 bool HasPendingExtensions() const; |
66 | 69 |
67 // Whether there is pending extension install from sync. | 70 // Whether there is pending extension install from sync. |
68 bool HasPendingExtensionFromSync() const; | 71 bool HasPendingExtensionFromSync() const; |
69 | 72 |
| 73 // Notifies the manager that we are reinstalling the policy force-installed |
| 74 // extension with |id| because we detected corruption in the current copy. |
| 75 void ExpectPolicyReinstallForCorruption(const ExtensionId& id); |
| 76 |
| 77 // Are we expecting a reinstall of the extension with |id| due to corruption? |
| 78 bool IsPolicyReinstallForCorruptionExpected(const ExtensionId& id) const; |
| 79 |
70 // Adds an extension in a pending state; the extension with the | 80 // Adds an extension in a pending state; the extension with the |
71 // given info will be installed on the next auto-update cycle. | 81 // given info will be installed on the next auto-update cycle. |
72 // Return true if the extension was added. Will return false | 82 // Return true if the extension was added. Will return false |
73 // if the extension is pending from another source which overrides | 83 // if the extension is pending from another source which overrides |
74 // sync installs (such as a policy extension) or if the extension | 84 // sync installs (such as a policy extension) or if the extension |
75 // is already installed. | 85 // is already installed. |
76 // After installation, the extension will be granted permissions iff | 86 // After installation, the extension will be granted permissions iff |
77 // |version| is valid and matches the actual installed version. | 87 // |version| is valid and matches the actual installed version. |
78 bool AddFromSync( | 88 bool AddFromSync( |
79 const std::string& id, | 89 const std::string& id, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // Add a pending extension record directly. Used for unit tests that need | 143 // Add a pending extension record directly. Used for unit tests that need |
134 // to set an inital state. Use friendship to allow the tests to call this | 144 // to set an inital state. Use friendship to allow the tests to call this |
135 // method. | 145 // method. |
136 void AddForTesting(const PendingExtensionInfo& pending_extension_info); | 146 void AddForTesting(const PendingExtensionInfo& pending_extension_info); |
137 | 147 |
138 // The BrowserContext with which the manager is associated. | 148 // The BrowserContext with which the manager is associated. |
139 content::BrowserContext* context_; | 149 content::BrowserContext* context_; |
140 | 150 |
141 PendingExtensionList pending_extension_list_; | 151 PendingExtensionList pending_extension_list_; |
142 | 152 |
| 153 // A set of policy force-installed extension ids that are being reinstalled |
| 154 // due to corruption, mapped to the time we detected the corruption. |
| 155 std::map<ExtensionId, base::TimeTicks> expected_policy_reinstalls_; |
| 156 |
143 FRIEND_TEST_ALL_PREFIXES(::ExtensionServiceTest, | 157 FRIEND_TEST_ALL_PREFIXES(::ExtensionServiceTest, |
144 UpdatePendingExtensionAlreadyInstalled); | 158 UpdatePendingExtensionAlreadyInstalled); |
145 friend class ExtensionUpdaterTest; | 159 friend class ExtensionUpdaterTest; |
146 friend void SetupPendingExtensionManagerForTest( | 160 friend void SetupPendingExtensionManagerForTest( |
147 int count, const GURL& update_url, | 161 int count, const GURL& update_url, |
148 PendingExtensionManager* pending_extension_manager); | 162 PendingExtensionManager* pending_extension_manager); |
149 | 163 |
150 DISALLOW_COPY_AND_ASSIGN(PendingExtensionManager); | 164 DISALLOW_COPY_AND_ASSIGN(PendingExtensionManager); |
151 }; | 165 }; |
152 | 166 |
153 } // namespace extensions | 167 } // namespace extensions |
154 | 168 |
155 #endif // CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_MANAGER_H_ | 169 #endif // CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_MANAGER_H_ |
OLD | NEW |