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/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 installed_.clear(); | 41 installed_.clear(); |
42 uninstalled_.clear(); | 42 uninstalled_.clear(); |
43 } | 43 } |
44 | 44 |
45 const ExtensionList& loaded() { return loaded_; } | 45 const ExtensionList& loaded() { return loaded_; } |
46 const ExtensionList& unloaded() { return unloaded_; } | 46 const ExtensionList& unloaded() { return unloaded_; } |
47 const ExtensionList& installed() { return installed_; } | 47 const ExtensionList& installed() { return installed_; } |
48 const ExtensionList& uninstalled() { return uninstalled_; } | 48 const ExtensionList& uninstalled() { return uninstalled_; } |
49 | 49 |
50 private: | 50 private: |
51 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, | 51 void OnExtensionLoaded(content::BrowserContext* browser_context, |
52 const Extension* extension) override { | 52 const Extension* extension) override { |
53 loaded_.push_back(extension); | 53 loaded_.push_back(extension); |
54 } | 54 } |
55 | 55 |
56 virtual void OnExtensionUnloaded(content::BrowserContext* browser_context, | 56 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
57 const Extension* extension, | 57 const Extension* extension, |
58 UnloadedExtensionInfo::Reason reason) | 58 UnloadedExtensionInfo::Reason reason) override { |
59 override { | |
60 unloaded_.push_back(extension); | 59 unloaded_.push_back(extension); |
61 } | 60 } |
62 | 61 |
63 virtual void OnExtensionWillBeInstalled( | 62 void OnExtensionWillBeInstalled(content::BrowserContext* browser_context, |
64 content::BrowserContext* browser_context, | 63 const Extension* extension, |
65 const Extension* extension, | 64 bool is_update, |
66 bool is_update, | 65 bool from_ephemeral, |
67 bool from_ephemeral, | 66 const std::string& old_name) override { |
68 const std::string& old_name) override { | |
69 installed_.push_back(extension); | 67 installed_.push_back(extension); |
70 } | 68 } |
71 | 69 |
72 virtual void OnExtensionUninstalled( | 70 void OnExtensionUninstalled(content::BrowserContext* browser_context, |
73 content::BrowserContext* browser_context, | 71 const Extension* extension, |
74 const Extension* extension, | 72 extensions::UninstallReason reason) override { |
75 extensions::UninstallReason reason) override { | |
76 uninstalled_.push_back(extension); | 73 uninstalled_.push_back(extension); |
77 } | 74 } |
78 | 75 |
79 virtual void OnShutdown(extensions::ExtensionRegistry* registry) override { | 76 void OnShutdown(extensions::ExtensionRegistry* registry) override { Reset(); } |
80 Reset(); | |
81 } | |
82 | 77 |
83 ExtensionList loaded_; | 78 ExtensionList loaded_; |
84 ExtensionList unloaded_; | 79 ExtensionList unloaded_; |
85 ExtensionList installed_; | 80 ExtensionList installed_; |
86 ExtensionList uninstalled_; | 81 ExtensionList uninstalled_; |
87 }; | 82 }; |
88 | 83 |
89 TEST_F(ExtensionRegistryTest, FillAndClearRegistry) { | 84 TEST_F(ExtensionRegistryTest, FillAndClearRegistry) { |
90 ExtensionRegistry registry(NULL); | 85 ExtensionRegistry registry(NULL); |
91 scoped_refptr<Extension> extension1 = test_util::CreateEmptyExtension("id1"); | 86 scoped_refptr<Extension> extension1 = test_util::CreateEmptyExtension("id1"); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 registry.TriggerOnUninstalled(extension.get(), | 265 registry.TriggerOnUninstalled(extension.get(), |
271 extensions::UNINSTALL_REASON_FOR_TESTING); | 266 extensions::UNINSTALL_REASON_FOR_TESTING); |
272 EXPECT_TRUE(observer.installed().empty()); | 267 EXPECT_TRUE(observer.installed().empty()); |
273 EXPECT_TRUE(HasSingleExtension(observer.uninstalled(), extension.get())); | 268 EXPECT_TRUE(HasSingleExtension(observer.uninstalled(), extension.get())); |
274 | 269 |
275 registry.RemoveObserver(&observer); | 270 registry.RemoveObserver(&observer); |
276 } | 271 } |
277 | 272 |
278 } // namespace | 273 } // namespace |
279 } // namespace extensions | 274 } // namespace extensions |
OLD | NEW |