| 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 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1298 forcelist.Append(base::Value::CreateStringValue(base::StringPrintf( | 1298 forcelist.Append(base::Value::CreateStringValue(base::StringPrintf( |
| 1299 "%s;%s", kGoodCrxId, url.spec().c_str()))); | 1299 "%s;%s", kGoodCrxId, url.spec().c_str()))); |
| 1300 PolicyMap policies; | 1300 PolicyMap policies; |
| 1301 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY, | 1301 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY, |
| 1302 POLICY_SCOPE_USER, forcelist.DeepCopy()); | 1302 POLICY_SCOPE_USER, forcelist.DeepCopy()); |
| 1303 content::WindowedNotificationObserver observer( | 1303 content::WindowedNotificationObserver observer( |
| 1304 chrome::NOTIFICATION_EXTENSION_INSTALLED, | 1304 chrome::NOTIFICATION_EXTENSION_INSTALLED, |
| 1305 content::NotificationService::AllSources()); | 1305 content::NotificationService::AllSources()); |
| 1306 UpdateProviderPolicy(policies); | 1306 UpdateProviderPolicy(policies); |
| 1307 observer.Wait(); | 1307 observer.Wait(); |
| 1308 content::Details<const extensions::Extension> details = observer.details(); | 1308 // Note: Cannot check that the notification details match the expected |
| 1309 EXPECT_EQ(kGoodCrxId, details->id()); | 1309 // exception, since the details object has already been freed prior to |
| 1310 EXPECT_EQ(details.ptr(), service->GetExtensionById(kGoodCrxId, true)); | 1310 // the completion of observer.Wait(). |
| 1311 |
| 1312 EXPECT_TRUE(service->GetExtensionById(kGoodCrxId, true)); |
| 1313 |
| 1311 // The user is not allowed to uninstall force-installed extensions. | 1314 // The user is not allowed to uninstall force-installed extensions. |
| 1312 UninstallExtension(kGoodCrxId, false); | 1315 UninstallExtension(kGoodCrxId, false); |
| 1313 } | 1316 } |
| 1314 | 1317 |
| 1315 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionAllowedTypes) { | 1318 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionAllowedTypes) { |
| 1316 // Verifies that extensions are blocked if policy specifies an allowed types | 1319 // Verifies that extensions are blocked if policy specifies an allowed types |
| 1317 // list and the extension's type is not on that list. | 1320 // list and the extension's type is not on that list. |
| 1318 ExtensionService* service = extension_service(); | 1321 ExtensionService* service = extension_service(); |
| 1319 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1322 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
| 1320 ASSERT_FALSE(service->GetExtensionById(kHostedAppCrxId, true)); | 1323 ASSERT_FALSE(service->GetExtensionById(kHostedAppCrxId, true)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 PolicyMap policies; | 1373 PolicyMap policies; |
| 1371 policies.Set(key::kExtensionInstallSources, POLICY_LEVEL_MANDATORY, | 1374 policies.Set(key::kExtensionInstallSources, POLICY_LEVEL_MANDATORY, |
| 1372 POLICY_SCOPE_USER, install_sources.DeepCopy()); | 1375 POLICY_SCOPE_USER, install_sources.DeepCopy()); |
| 1373 UpdateProviderPolicy(policies); | 1376 UpdateProviderPolicy(policies); |
| 1374 | 1377 |
| 1375 content::WindowedNotificationObserver observer( | 1378 content::WindowedNotificationObserver observer( |
| 1376 chrome::NOTIFICATION_EXTENSION_INSTALLED, | 1379 chrome::NOTIFICATION_EXTENSION_INSTALLED, |
| 1377 content::NotificationService::AllSources()); | 1380 content::NotificationService::AllSources()); |
| 1378 PerformClick(1, 0); | 1381 PerformClick(1, 0); |
| 1379 observer.Wait(); | 1382 observer.Wait(); |
| 1380 | 1383 // Note: Cannot check that the notification details match the expected |
| 1381 content::Details<const extensions::Extension> details = observer.details(); | 1384 // exception, since the details object has already been freed prior to |
| 1382 EXPECT_EQ(kAdBlockCrxId, details->id()); | 1385 // the completion of observer.Wait(). |
| 1383 | 1386 |
| 1384 // The first extension shouldn't be present, the second should be there. | 1387 // The first extension shouldn't be present, the second should be there. |
| 1385 EXPECT_FALSE(extension_service()->GetExtensionById(kGoodCrxId, true)); | 1388 EXPECT_FALSE(extension_service()->GetExtensionById(kGoodCrxId, true)); |
| 1386 EXPECT_TRUE(extension_service()->GetExtensionById(kAdBlockCrxId, false)); | 1389 EXPECT_TRUE(extension_service()->GetExtensionById(kAdBlockCrxId, false)); |
| 1387 } | 1390 } |
| 1388 | 1391 |
| 1389 IN_PROC_BROWSER_TEST_F(PolicyTest, HomepageLocation) { | 1392 IN_PROC_BROWSER_TEST_F(PolicyTest, HomepageLocation) { |
| 1390 // Verifies that the homepage can be configured with policies. | 1393 // Verifies that the homepage can be configured with policies. |
| 1391 // Set a default, and check that the home button navigates there. | 1394 // Set a default, and check that the home button navigates there. |
| 1392 browser()->profile()->GetPrefs()->SetString( | 1395 browser()->profile()->GetPrefs()->SetString( |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2080 chrome_variations::VariationsService::GetVariationsServerURL( | 2083 chrome_variations::VariationsService::GetVariationsServerURL( |
| 2081 g_browser_process->local_state()); | 2084 g_browser_process->local_state()); |
| 2082 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true)); | 2085 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true)); |
| 2083 std::string value; | 2086 std::string value; |
| 2084 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); | 2087 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); |
| 2085 EXPECT_EQ("restricted", value); | 2088 EXPECT_EQ("restricted", value); |
| 2086 } | 2089 } |
| 2087 #endif | 2090 #endif |
| 2088 | 2091 |
| 2089 } // namespace policy | 2092 } // namespace policy |
| OLD | NEW |