| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/extensions/component_loader.h" | 5 #include "chrome/browser/extensions/component_loader.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 unloaded_count_(0), | 44 unloaded_count_(0), |
| 45 registry_(ExtensionRegistry::Get(profile)) {} | 45 registry_(ExtensionRegistry::Get(profile)) {} |
| 46 | 46 |
| 47 void AddComponentExtension(const Extension* extension) override { | 47 void AddComponentExtension(const Extension* extension) override { |
| 48 EXPECT_FALSE(registry_->enabled_extensions().Contains(extension->id())); | 48 EXPECT_FALSE(registry_->enabled_extensions().Contains(extension->id())); |
| 49 // ExtensionService must become the owner of the extension object. | 49 // ExtensionService must become the owner of the extension object. |
| 50 registry_->AddEnabled(extension); | 50 registry_->AddEnabled(extension); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void UnloadExtension(const std::string& extension_id, | 53 void UnloadExtension(const std::string& extension_id, |
| 54 UnloadedExtensionInfo::Reason reason) override { | 54 UnloadedExtensionReason reason) override { |
| 55 ASSERT_TRUE(registry_->enabled_extensions().Contains(extension_id)); | 55 ASSERT_TRUE(registry_->enabled_extensions().Contains(extension_id)); |
| 56 // Remove the extension with the matching id. | 56 // Remove the extension with the matching id. |
| 57 registry_->RemoveEnabled(extension_id); | 57 registry_->RemoveEnabled(extension_id); |
| 58 unloaded_count_++; | 58 unloaded_count_++; |
| 59 } | 59 } |
| 60 | 60 |
| 61 void RemoveComponentExtension(const std::string& extension_id) override { | 61 void RemoveComponentExtension(const std::string& extension_id) override { |
| 62 UnloadExtension(extension_id, UnloadedExtensionInfo::REASON_DISABLE); | 62 UnloadExtension(extension_id, UnloadedExtensionReason::REASON_DISABLE); |
| 63 } | 63 } |
| 64 | 64 |
| 65 bool is_ready() override { return ready_; } | 65 bool is_ready() override { return ready_; } |
| 66 | 66 |
| 67 void set_ready(bool ready) { | 67 void set_ready(bool ready) { |
| 68 ready_ = ready; | 68 ready_ = ready; |
| 69 } | 69 } |
| 70 | 70 |
| 71 size_t unloaded_count() const { | 71 size_t unloaded_count() const { |
| 72 return unloaded_count_; | 72 return unloaded_count_; |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 component_loader_.AddOrReplace(known_extension); | 278 component_loader_.AddOrReplace(known_extension); |
| 279 EXPECT_EQ(default_count + 1, registry->enabled_extensions().size()); | 279 EXPECT_EQ(default_count + 1, registry->enabled_extensions().size()); |
| 280 EXPECT_EQ(1u, extension_service_.unloaded_count()); | 280 EXPECT_EQ(1u, extension_service_.unloaded_count()); |
| 281 | 281 |
| 282 // Add an invalid component extension. | 282 // Add an invalid component extension. |
| 283 std::string extension_id = component_loader_.AddOrReplace(invalid_extension); | 283 std::string extension_id = component_loader_.AddOrReplace(invalid_extension); |
| 284 EXPECT_TRUE(extension_id.empty()); | 284 EXPECT_TRUE(extension_id.empty()); |
| 285 } | 285 } |
| 286 | 286 |
| 287 } // namespace extensions | 287 } // namespace extensions |
| OLD | NEW |