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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/prefs/scoped_user_pref_update.h" | 8 #include "base/prefs/scoped_user_pref_update.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 std::string BuildForceInstallPolicyValue(const char* extension_id, | 50 std::string BuildForceInstallPolicyValue(const char* extension_id, |
51 const char* update_url) { | 51 const char* update_url) { |
52 return base::StringPrintf("%s;%s", extension_id, update_url); | 52 return base::StringPrintf("%s;%s", extension_id, update_url); |
53 } | 53 } |
54 | 54 |
55 } // namespace | 55 } // namespace |
56 | 56 |
57 class ExtensionManagementTest : public ExtensionBrowserTest { | 57 class ExtensionManagementTest : public ExtensionBrowserTest { |
58 public: | 58 public: |
59 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 59 virtual void SetUpInProcessBrowserTestFixture() override { |
60 EXPECT_CALL(policy_provider_, IsInitializationComplete(_)) | 60 EXPECT_CALL(policy_provider_, IsInitializationComplete(_)) |
61 .WillRepeatedly(Return(true)); | 61 .WillRepeatedly(Return(true)); |
62 policy::BrowserPolicyConnector::SetPolicyProviderForTesting( | 62 policy::BrowserPolicyConnector::SetPolicyProviderForTesting( |
63 &policy_provider_); | 63 &policy_provider_); |
64 } | 64 } |
65 | 65 |
66 protected: | 66 protected: |
67 void UpdateProviderPolicy(const PolicyMap& policy) { | 67 void UpdateProviderPolicy(const PolicyMap& policy) { |
68 policy_provider_.UpdateChromePolicy(policy); | 68 policy_provider_.UpdateChromePolicy(policy); |
69 base::RunLoop().RunUntilIdle(); | 69 base::RunLoop().RunUntilIdle(); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 226 |
227 void Reset() { | 227 void Reset() { |
228 started_ = false; | 228 started_ = false; |
229 finished_ = false; | 229 finished_ = false; |
230 updates_.clear(); | 230 updates_.clear(); |
231 } | 231 } |
232 | 232 |
233 // Implements content::NotificationObserver interface. | 233 // Implements content::NotificationObserver interface. |
234 virtual void Observe(int type, | 234 virtual void Observe(int type, |
235 const content::NotificationSource& source, | 235 const content::NotificationSource& source, |
236 const content::NotificationDetails& details) OVERRIDE { | 236 const content::NotificationDetails& details) override { |
237 switch (type) { | 237 switch (type) { |
238 case extensions::NOTIFICATION_EXTENSION_UPDATING_STARTED: { | 238 case extensions::NOTIFICATION_EXTENSION_UPDATING_STARTED: { |
239 EXPECT_FALSE(started_); | 239 EXPECT_FALSE(started_); |
240 started_ = true; | 240 started_ = true; |
241 break; | 241 break; |
242 } | 242 } |
243 case extensions::NOTIFICATION_EXTENSION_UPDATE_FOUND: { | 243 case extensions::NOTIFICATION_EXTENSION_UPDATE_FOUND: { |
244 const std::string& id = | 244 const std::string& id = |
245 content::Details<extensions::UpdateDetails>(details)->id; | 245 content::Details<extensions::UpdateDetails>(details)->id; |
246 updates_.insert(id); | 246 updates_.insert(id); |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 UpdateProviderPolicy(policies); | 706 UpdateProviderPolicy(policies); |
707 | 707 |
708 ASSERT_TRUE(WaitForExtensionInstall()); | 708 ASSERT_TRUE(WaitForExtensionInstall()); |
709 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); | 709 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); |
710 extension = service->GetExtensionById(kExtensionId, false); | 710 extension = service->GetExtensionById(kExtensionId, false); |
711 ASSERT_TRUE(extension); | 711 ASSERT_TRUE(extension); |
712 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); | 712 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); |
713 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); | 713 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); |
714 EXPECT_TRUE(registry->disabled_extensions().is_empty()); | 714 EXPECT_TRUE(registry->disabled_extensions().is_empty()); |
715 } | 715 } |
OLD | NEW |