| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1295 forcelist.Append(base::Value::CreateStringValue(base::StringPrintf( | 1295 forcelist.Append(base::Value::CreateStringValue(base::StringPrintf( |
| 1296 "%s;%s", kGoodCrxId, url.spec().c_str()))); | 1296 "%s;%s", kGoodCrxId, url.spec().c_str()))); |
| 1297 PolicyMap policies; | 1297 PolicyMap policies; |
| 1298 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY, | 1298 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY, |
| 1299 POLICY_SCOPE_USER, forcelist.DeepCopy()); | 1299 POLICY_SCOPE_USER, forcelist.DeepCopy()); |
| 1300 content::WindowedNotificationObserver observer( | 1300 content::WindowedNotificationObserver observer( |
| 1301 chrome::NOTIFICATION_EXTENSION_INSTALLED, | 1301 chrome::NOTIFICATION_EXTENSION_INSTALLED, |
| 1302 content::NotificationService::AllSources()); | 1302 content::NotificationService::AllSources()); |
| 1303 UpdateProviderPolicy(policies); | 1303 UpdateProviderPolicy(policies); |
| 1304 observer.Wait(); | 1304 observer.Wait(); |
| 1305 content::Details<const extensions::Extension> details = observer.details(); | 1305 content::Details<const extensions::InstalledExtensionInfo> details = |
| 1306 EXPECT_EQ(kGoodCrxId, details->id()); | 1306 observer.details(); |
| 1307 EXPECT_EQ(details.ptr(), service->GetExtensionById(kGoodCrxId, true)); | 1307 const extensions::Extension* extension = details->extension; |
| 1308 EXPECT_EQ(kGoodCrxId, extension->id()); |
| 1309 EXPECT_EQ(extension, service->GetExtensionById(kGoodCrxId, true)); |
| 1308 // The user is not allowed to uninstall force-installed extensions. | 1310 // The user is not allowed to uninstall force-installed extensions. |
| 1309 UninstallExtension(kGoodCrxId, false); | 1311 UninstallExtension(kGoodCrxId, false); |
| 1310 } | 1312 } |
| 1311 | 1313 |
| 1312 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionAllowedTypes) { | 1314 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionAllowedTypes) { |
| 1313 // Verifies that extensions are blocked if policy specifies an allowed types | 1315 // Verifies that extensions are blocked if policy specifies an allowed types |
| 1314 // list and the extension's type is not on that list. | 1316 // list and the extension's type is not on that list. |
| 1315 ExtensionService* service = extension_service(); | 1317 ExtensionService* service = extension_service(); |
| 1316 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1318 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
| 1317 ASSERT_FALSE(service->GetExtensionById(kHostedAppCrxId, true)); | 1319 ASSERT_FALSE(service->GetExtensionById(kHostedAppCrxId, true)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1368 policies.Set(key::kExtensionInstallSources, POLICY_LEVEL_MANDATORY, | 1370 policies.Set(key::kExtensionInstallSources, POLICY_LEVEL_MANDATORY, |
| 1369 POLICY_SCOPE_USER, install_sources.DeepCopy()); | 1371 POLICY_SCOPE_USER, install_sources.DeepCopy()); |
| 1370 UpdateProviderPolicy(policies); | 1372 UpdateProviderPolicy(policies); |
| 1371 | 1373 |
| 1372 content::WindowedNotificationObserver observer( | 1374 content::WindowedNotificationObserver observer( |
| 1373 chrome::NOTIFICATION_EXTENSION_INSTALLED, | 1375 chrome::NOTIFICATION_EXTENSION_INSTALLED, |
| 1374 content::NotificationService::AllSources()); | 1376 content::NotificationService::AllSources()); |
| 1375 PerformClick(1, 0); | 1377 PerformClick(1, 0); |
| 1376 observer.Wait(); | 1378 observer.Wait(); |
| 1377 | 1379 |
| 1378 content::Details<const extensions::Extension> details = observer.details(); | 1380 content::Details<const extensions::InstalledExtensionInfo> details = |
| 1379 EXPECT_EQ(kAdBlockCrxId, details->id()); | 1381 observer.details(); |
| 1382 EXPECT_EQ(kAdBlockCrxId, details->extension->id()); |
| 1380 | 1383 |
| 1381 // The first extension shouldn't be present, the second should be there. | 1384 // The first extension shouldn't be present, the second should be there. |
| 1382 EXPECT_FALSE(extension_service()->GetExtensionById(kGoodCrxId, true)); | 1385 EXPECT_FALSE(extension_service()->GetExtensionById(kGoodCrxId, true)); |
| 1383 EXPECT_TRUE(extension_service()->GetExtensionById(kAdBlockCrxId, false)); | 1386 EXPECT_TRUE(extension_service()->GetExtensionById(kAdBlockCrxId, false)); |
| 1384 } | 1387 } |
| 1385 | 1388 |
| 1386 IN_PROC_BROWSER_TEST_F(PolicyTest, HomepageLocation) { | 1389 IN_PROC_BROWSER_TEST_F(PolicyTest, HomepageLocation) { |
| 1387 // Verifies that the homepage can be configured with policies. | 1390 // Verifies that the homepage can be configured with policies. |
| 1388 // Set a default, and check that the home button navigates there. | 1391 // Set a default, and check that the home button navigates there. |
| 1389 browser()->profile()->GetPrefs()->SetString( | 1392 browser()->profile()->GetPrefs()->SetString( |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2070 GetDefaultVariationsServerURLForTesting(); | 2073 GetDefaultVariationsServerURLForTesting(); |
| 2071 | 2074 |
| 2072 // Policy is applied and pref is already updated in local state. | 2075 // Policy is applied and pref is already updated in local state. |
| 2073 EXPECT_EQ(default_variations_url + "?restrict=restricted", | 2076 EXPECT_EQ(default_variations_url + "?restrict=restricted", |
| 2074 chrome_variations::VariationsService::GetVariationsServerURL( | 2077 chrome_variations::VariationsService::GetVariationsServerURL( |
| 2075 g_browser_process->local_state()).spec()); | 2078 g_browser_process->local_state()).spec()); |
| 2076 } | 2079 } |
| 2077 #endif | 2080 #endif |
| 2078 | 2081 |
| 2079 } // namespace policy | 2082 } // namespace policy |
| OLD | NEW |