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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "base/version.h" | 11 #include "base/version.h" |
| 12 #include "chrome/browser/extensions/extension_management.h" |
12 #include "chrome/browser/extensions/external_policy_loader.h" | 13 #include "chrome/browser/extensions/external_policy_loader.h" |
13 #include "chrome/browser/extensions/external_provider_impl.h" | 14 #include "chrome/browser/extensions/external_provider_impl.h" |
14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
15 #include "chrome/test/base/testing_pref_service_syncable.h" | 16 #include "chrome/test/base/testing_pref_service_syncable.h" |
16 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
17 #include "content/public/test/test_browser_thread.h" | 18 #include "content/public/test/test_browser_thread.h" |
18 #include "extensions/browser/external_provider_interface.h" | 19 #include "extensions/browser/external_provider_interface.h" |
19 #include "extensions/browser/pref_names.h" | 20 #include "extensions/browser/pref_names.h" |
20 #include "extensions/common/extension.h" | 21 #include "extensions/common/extension.h" |
21 #include "extensions/common/manifest.h" | 22 #include "extensions/common/manifest.h" |
(...skipping 25 matching lines...) Expand all Loading... |
47 | 48 |
48 // Initialize a provider with |policy_forcelist|, and check that it installs | 49 // Initialize a provider with |policy_forcelist|, and check that it installs |
49 // exactly the extensions specified in |expected_extensions|. | 50 // exactly the extensions specified in |expected_extensions|. |
50 void Visit(const base::DictionaryValue& policy_forcelist, | 51 void Visit(const base::DictionaryValue& policy_forcelist, |
51 const std::set<std::string>& expected_extensions) { | 52 const std::set<std::string>& expected_extensions) { |
52 profile_.reset(new TestingProfile); | 53 profile_.reset(new TestingProfile); |
53 profile_->GetTestingPrefService()->SetManagedPref( | 54 profile_->GetTestingPrefService()->SetManagedPref( |
54 pref_names::kInstallForceList, policy_forcelist.DeepCopy()); | 55 pref_names::kInstallForceList, policy_forcelist.DeepCopy()); |
55 provider_.reset(new ExternalProviderImpl( | 56 provider_.reset(new ExternalProviderImpl( |
56 this, | 57 this, |
57 new ExternalPolicyLoader(profile_.get()), | 58 new ExternalPolicyLoader( |
| 59 ExtensionManagementFactory::GetForBrowserContext(profile_.get())), |
58 profile_.get(), | 60 profile_.get(), |
59 Manifest::INVALID_LOCATION, | 61 Manifest::INVALID_LOCATION, |
60 Manifest::EXTERNAL_POLICY_DOWNLOAD, | 62 Manifest::EXTERNAL_POLICY_DOWNLOAD, |
61 Extension::NO_FLAGS)); | 63 Extension::NO_FLAGS)); |
62 | 64 |
63 // Extensions will be removed from this list as they visited, | 65 // Extensions will be removed from this list as they visited, |
64 // so it should be emptied by the end. | 66 // so it should be emptied by the end. |
65 expected_extensions_ = expected_extensions; | 67 expected_extensions_ = expected_extensions; |
66 provider_->VisitRegisteredExtension(); | 68 provider_->VisitRegisteredExtension(); |
67 EXPECT_TRUE(expected_extensions_.empty()); | 69 EXPECT_TRUE(expected_extensions_.empty()); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 forced_extensions.SetString("invalid", "http://www.example.com/crx"); | 146 forced_extensions.SetString("invalid", "http://www.example.com/crx"); |
145 forced_extensions.SetString("dddddddddddddddddddddddddddddddd", | 147 forced_extensions.SetString("dddddddddddddddddddddddddddddddd", |
146 std::string()); | 148 std::string()); |
147 forced_extensions.SetString("invalid", "bad"); | 149 forced_extensions.SetString("invalid", "bad"); |
148 | 150 |
149 MockExternalPolicyProviderVisitor mv; | 151 MockExternalPolicyProviderVisitor mv; |
150 mv.Visit(forced_extensions, expected_extensions); | 152 mv.Visit(forced_extensions, expected_extensions); |
151 } | 153 } |
152 | 154 |
153 } // namespace extensions | 155 } // namespace extensions |
OLD | NEW |