| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "base/version.h" | 9 #include "base/version.h" |
| 10 #include "chrome/browser/extensions/external_policy_extension_provider.h" | 10 #include "chrome/browser/extensions/external_policy_extension_provider.h" |
| 11 #include "chrome/common/extensions/extension.h" | 11 #include "chrome/common/extensions/extension.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 class ExternalPolicyExtensionProviderTest : public testing::Test { | 14 class ExternalPolicyExtensionProviderTest : public testing::Test { |
| 15 }; | 15 }; |
| 16 | 16 |
| 17 class MockExternalPolicyExtensionProviderVisitor | 17 class MockExternalPolicyExtensionProviderVisitor |
| 18 : public ExternalExtensionProvider::Visitor { | 18 : public ExternalExtensionProvider::Visitor { |
| 19 public: | 19 public: |
| 20 MockExternalPolicyExtensionProviderVisitor() { | 20 MockExternalPolicyExtensionProviderVisitor() { |
| 21 } | 21 } |
| 22 | 22 |
| 23 // Initialize a provider with |policy_forcelist|, and check that it parses | 23 // Initialize a provider with |policy_forcelist|, and check that it parses |
| 24 // exactly those extensions, that are specified in |policy_validlist|. | 24 // exactly those extensions, that are specified in |policy_validlist|. |
| 25 void Visit(ListValue* policy_forcelist, | 25 void Visit(ListValue* policy_forcelist, |
| 26 ListValue* policy_validlist, | 26 ListValue* policy_validlist, |
| 27 const std::set<std::string>& ignore_list) { | 27 const std::set<std::string>& ignore_list) { |
| 28 provider_.reset(new ExternalPolicyExtensionProvider()); | 28 provider_.reset(new ExternalPolicyExtensionProvider(policy_forcelist)); |
| 29 // Give the list extensions to the provider. | |
| 30 provider_->SetPreferences(policy_forcelist); | |
| 31 | 29 |
| 32 // Extensions will be removed from this list as they visited, | 30 // Extensions will be removed from this list as they visited, |
| 33 // so it should be emptied by the end. | 31 // so it should be emptied by the end. |
| 34 remaining_extensions = policy_validlist; | 32 remaining_extensions = policy_validlist; |
| 35 provider_->VisitRegisteredExtension(this); | 33 provider_->VisitRegisteredExtension(this); |
| 36 EXPECT_EQ(0u, remaining_extensions->GetSize()); | 34 EXPECT_EQ(0u, remaining_extensions->GetSize()); |
| 37 } | 35 } |
| 38 | 36 |
| 39 virtual void OnExternalExtensionFileFound(const std::string& id, | 37 virtual void OnExternalExtensionFileFound(const std::string& id, |
| 40 const Version* version, | 38 const Version* version, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;http#//www.example.com/crx")); | 102 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;http#//www.example.com/crx")); |
| 105 forced_extensions.Append(Value::CreateStringValue( | 103 forced_extensions.Append(Value::CreateStringValue( |
| 106 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); | 104 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); |
| 107 forced_extensions.Append(Value::CreateStringValue( | 105 forced_extensions.Append(Value::CreateStringValue( |
| 108 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaahttp#//www.example.com/crx")); | 106 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaahttp#//www.example.com/crx")); |
| 109 | 107 |
| 110 MockExternalPolicyExtensionProviderVisitor mv; | 108 MockExternalPolicyExtensionProviderVisitor mv; |
| 111 std::set<std::string> empty; | 109 std::set<std::string> empty; |
| 112 mv.Visit(&forced_extensions, &valid_extensions, empty); | 110 mv.Visit(&forced_extensions, &valid_extensions, empty); |
| 113 } | 111 } |
| OLD | NEW |