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 #include "extensions/browser/extension_registry.h" | 5 #include "extensions/browser/extension_registry.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 const ExtensionList& uninstalled() { return uninstalled_; } | 52 const ExtensionList& uninstalled() { return uninstalled_; } |
53 | 53 |
54 private: | 54 private: |
55 void OnExtensionLoaded(content::BrowserContext* browser_context, | 55 void OnExtensionLoaded(content::BrowserContext* browser_context, |
56 const Extension* extension) override { | 56 const Extension* extension) override { |
57 loaded_.push_back(extension); | 57 loaded_.push_back(extension); |
58 } | 58 } |
59 | 59 |
60 void OnExtensionUnloaded(content::BrowserContext* browser_context, | 60 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
61 const Extension* extension, | 61 const Extension* extension, |
62 UnloadedExtensionInfo::Reason reason) override { | 62 UnloadedExtensionReason reason) override { |
63 unloaded_.push_back(extension); | 63 unloaded_.push_back(extension); |
64 } | 64 } |
65 | 65 |
66 void OnExtensionWillBeInstalled(content::BrowserContext* browser_context, | 66 void OnExtensionWillBeInstalled(content::BrowserContext* browser_context, |
67 const Extension* extension, | 67 const Extension* extension, |
68 bool is_update, | 68 bool is_update, |
69 const std::string& old_name) override { | 69 const std::string& old_name) override { |
70 installed_.push_back(extension); | 70 installed_.push_back(extension); |
71 } | 71 } |
72 | 72 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 registry.AddEnabled(extension); | 252 registry.AddEnabled(extension); |
253 registry.TriggerOnLoaded(extension.get()); | 253 registry.TriggerOnLoaded(extension.get()); |
254 | 254 |
255 registry.TriggerOnWillBeInstalled(extension.get(), true, "foo"); | 255 registry.TriggerOnWillBeInstalled(extension.get(), true, "foo"); |
256 | 256 |
257 EXPECT_TRUE(HasSingleExtension(observer.loaded(), extension.get())); | 257 EXPECT_TRUE(HasSingleExtension(observer.loaded(), extension.get())); |
258 EXPECT_TRUE(observer.unloaded().empty()); | 258 EXPECT_TRUE(observer.unloaded().empty()); |
259 registry.Shutdown(); | 259 registry.Shutdown(); |
260 | 260 |
261 registry.RemoveEnabled(extension->id()); | 261 registry.RemoveEnabled(extension->id()); |
262 registry.TriggerOnUnloaded(extension.get(), | 262 registry.TriggerOnUnloaded(extension.get(), UnloadedExtensionReason::DISABLE); |
263 UnloadedExtensionInfo::REASON_DISABLE); | |
264 | 263 |
265 EXPECT_TRUE(observer.loaded().empty()); | 264 EXPECT_TRUE(observer.loaded().empty()); |
266 EXPECT_TRUE(HasSingleExtension(observer.unloaded(), extension.get())); | 265 EXPECT_TRUE(HasSingleExtension(observer.unloaded(), extension.get())); |
267 registry.Shutdown(); | 266 registry.Shutdown(); |
268 | 267 |
269 registry.TriggerOnUninstalled(extension.get(), UNINSTALL_REASON_FOR_TESTING); | 268 registry.TriggerOnUninstalled(extension.get(), UNINSTALL_REASON_FOR_TESTING); |
270 EXPECT_TRUE(observer.installed().empty()); | 269 EXPECT_TRUE(observer.installed().empty()); |
271 EXPECT_TRUE(HasSingleExtension(observer.uninstalled(), extension.get())); | 270 EXPECT_TRUE(HasSingleExtension(observer.uninstalled(), extension.get())); |
272 | 271 |
273 registry.RemoveObserver(&observer); | 272 registry.RemoveObserver(&observer); |
274 } | 273 } |
275 | 274 |
276 } // namespace | 275 } // namespace |
277 } // namespace extensions | 276 } // namespace extensions |
OLD | NEW |