| 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" |
| 11 #include "extensions/browser/extension_registry_observer.h" | 11 #include "extensions/browser/extension_registry_observer.h" |
| 12 #include "extensions/common/extension.h" | 12 #include "extensions/browser/uninstall_reason.h" |
| 13 #include "extensions/common/test_util.h" | 13 #include "extensions/common/test_util.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 namespace extensions { | 16 namespace extensions { |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 typedef testing::Test ExtensionRegistryTest; | 19 typedef testing::Test ExtensionRegistryTest; |
| 20 | 20 |
| 21 testing::AssertionResult HasSingleExtension( | 21 testing::AssertionResult HasSingleExtension( |
| 22 const ExtensionList& list, | 22 const ExtensionList& list, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 virtual void OnExtensionWillBeInstalled( | 63 virtual void OnExtensionWillBeInstalled( |
| 64 content::BrowserContext* browser_context, | 64 content::BrowserContext* browser_context, |
| 65 const Extension* extension, | 65 const Extension* extension, |
| 66 bool is_update, | 66 bool is_update, |
| 67 bool from_ephemeral, | 67 bool from_ephemeral, |
| 68 const std::string& old_name) OVERRIDE { | 68 const std::string& old_name) OVERRIDE { |
| 69 installed_.push_back(extension); | 69 installed_.push_back(extension); |
| 70 } | 70 } |
| 71 | 71 |
| 72 virtual void OnExtensionUninstalled(content::BrowserContext* browser_context, | 72 virtual void OnExtensionUninstalled( |
| 73 const Extension* extension) OVERRIDE { | 73 content::BrowserContext* browser_context, |
| 74 const Extension* extension, |
| 75 extensions::UninstallReason reason) OVERRIDE { |
| 74 uninstalled_.push_back(extension); | 76 uninstalled_.push_back(extension); |
| 75 } | 77 } |
| 76 | 78 |
| 77 virtual void OnShutdown(extensions::ExtensionRegistry* registry) OVERRIDE { | 79 virtual void OnShutdown(extensions::ExtensionRegistry* registry) OVERRIDE { |
| 78 Reset(); | 80 Reset(); |
| 79 } | 81 } |
| 80 | 82 |
| 81 ExtensionList loaded_; | 83 ExtensionList loaded_; |
| 82 ExtensionList unloaded_; | 84 ExtensionList unloaded_; |
| 83 ExtensionList installed_; | 85 ExtensionList installed_; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 EXPECT_TRUE(observer.unloaded().empty()); | 260 EXPECT_TRUE(observer.unloaded().empty()); |
| 259 registry.Shutdown(); | 261 registry.Shutdown(); |
| 260 | 262 |
| 261 registry.RemoveEnabled(extension->id()); | 263 registry.RemoveEnabled(extension->id()); |
| 262 registry.TriggerOnUnloaded(extension, UnloadedExtensionInfo::REASON_DISABLE); | 264 registry.TriggerOnUnloaded(extension, UnloadedExtensionInfo::REASON_DISABLE); |
| 263 | 265 |
| 264 EXPECT_TRUE(observer.loaded().empty()); | 266 EXPECT_TRUE(observer.loaded().empty()); |
| 265 EXPECT_TRUE(HasSingleExtension(observer.unloaded(), extension.get())); | 267 EXPECT_TRUE(HasSingleExtension(observer.unloaded(), extension.get())); |
| 266 registry.Shutdown(); | 268 registry.Shutdown(); |
| 267 | 269 |
| 268 registry.TriggerOnUninstalled(extension); | 270 registry.TriggerOnUninstalled(extension, |
| 271 extensions::UNINSTALL_REASON_FOR_TESTING); |
| 269 EXPECT_TRUE(observer.installed().empty()); | 272 EXPECT_TRUE(observer.installed().empty()); |
| 270 EXPECT_TRUE(HasSingleExtension(observer.uninstalled(), extension.get())); | 273 EXPECT_TRUE(HasSingleExtension(observer.uninstalled(), extension.get())); |
| 271 | 274 |
| 272 registry.RemoveObserver(&observer); | 275 registry.RemoveObserver(&observer); |
| 273 } | 276 } |
| 274 | 277 |
| 275 } // namespace | 278 } // namespace |
| 276 } // namespace extensions | 279 } // namespace extensions |
| OLD | NEW |