Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(485)

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

Issue 14238037: Made it possible to tell whether an extension is being installed or updated. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rename already_installed to is_update. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 forcelist.Append(base::Value::CreateStringValue(base::StringPrintf( 1296 forcelist.Append(base::Value::CreateStringValue(base::StringPrintf(
1297 "%s;%s", kGoodCrxId, url.spec().c_str()))); 1297 "%s;%s", kGoodCrxId, url.spec().c_str())));
1298 PolicyMap policies; 1298 PolicyMap policies;
1299 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY, 1299 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY,
1300 POLICY_SCOPE_USER, forcelist.DeepCopy()); 1300 POLICY_SCOPE_USER, forcelist.DeepCopy());
1301 content::WindowedNotificationObserver observer( 1301 content::WindowedNotificationObserver observer(
1302 chrome::NOTIFICATION_EXTENSION_INSTALLED, 1302 chrome::NOTIFICATION_EXTENSION_INSTALLED,
1303 content::NotificationService::AllSources()); 1303 content::NotificationService::AllSources());
1304 UpdateProviderPolicy(policies); 1304 UpdateProviderPolicy(policies);
1305 observer.Wait(); 1305 observer.Wait();
1306 content::Details<const extensions::Extension> details = observer.details(); 1306 content::Details<const extensions::InstalledExtensionInfo> details =
1307 EXPECT_EQ(kGoodCrxId, details->id()); 1307 observer.details();
1308 EXPECT_EQ(details.ptr(), service->GetExtensionById(kGoodCrxId, true)); 1308 const extensions::Extension* extension = details->extension;
1309 EXPECT_EQ(kGoodCrxId, extension->id());
1310 EXPECT_EQ(extension, service->GetExtensionById(kGoodCrxId, true));
1309 // The user is not allowed to uninstall force-installed extensions. 1311 // The user is not allowed to uninstall force-installed extensions.
1310 UninstallExtension(kGoodCrxId, false); 1312 UninstallExtension(kGoodCrxId, false);
1311 } 1313 }
1312 1314
1313 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionAllowedTypes) { 1315 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionAllowedTypes) {
1314 // Verifies that extensions are blocked if policy specifies an allowed types 1316 // Verifies that extensions are blocked if policy specifies an allowed types
1315 // list and the extension's type is not on that list. 1317 // list and the extension's type is not on that list.
1316 ExtensionService* service = extension_service(); 1318 ExtensionService* service = extension_service();
1317 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); 1319 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true));
1318 ASSERT_FALSE(service->GetExtensionById(kHostedAppCrxId, true)); 1320 ASSERT_FALSE(service->GetExtensionById(kHostedAppCrxId, true));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 policies.Set(key::kExtensionInstallSources, POLICY_LEVEL_MANDATORY, 1371 policies.Set(key::kExtensionInstallSources, POLICY_LEVEL_MANDATORY,
1370 POLICY_SCOPE_USER, install_sources.DeepCopy()); 1372 POLICY_SCOPE_USER, install_sources.DeepCopy());
1371 UpdateProviderPolicy(policies); 1373 UpdateProviderPolicy(policies);
1372 1374
1373 content::WindowedNotificationObserver observer( 1375 content::WindowedNotificationObserver observer(
1374 chrome::NOTIFICATION_EXTENSION_INSTALLED, 1376 chrome::NOTIFICATION_EXTENSION_INSTALLED,
1375 content::NotificationService::AllSources()); 1377 content::NotificationService::AllSources());
1376 PerformClick(1, 0); 1378 PerformClick(1, 0);
1377 observer.Wait(); 1379 observer.Wait();
1378 1380
1379 content::Details<const extensions::Extension> details = observer.details(); 1381 content::Details<const extensions::InstalledExtensionInfo> details =
1380 EXPECT_EQ(kAdBlockCrxId, details->id()); 1382 observer.details();
1383 EXPECT_EQ(kAdBlockCrxId, details->extension->id());
1381 1384
1382 // The first extension shouldn't be present, the second should be there. 1385 // The first extension shouldn't be present, the second should be there.
1383 EXPECT_FALSE(extension_service()->GetExtensionById(kGoodCrxId, true)); 1386 EXPECT_FALSE(extension_service()->GetExtensionById(kGoodCrxId, true));
1384 EXPECT_TRUE(extension_service()->GetExtensionById(kAdBlockCrxId, false)); 1387 EXPECT_TRUE(extension_service()->GetExtensionById(kAdBlockCrxId, false));
1385 } 1388 }
1386 1389
1387 IN_PROC_BROWSER_TEST_F(PolicyTest, HomepageLocation) { 1390 IN_PROC_BROWSER_TEST_F(PolicyTest, HomepageLocation) {
1388 // Verifies that the homepage can be configured with policies. 1391 // Verifies that the homepage can be configured with policies.
1389 // Set a default, and check that the home button navigates there. 1392 // Set a default, and check that the home button navigates there.
1390 browser()->profile()->GetPrefs()->SetString( 1393 browser()->profile()->GetPrefs()->SetString(
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
2075 GetDefaultVariationsServerURLForTesting(); 2078 GetDefaultVariationsServerURLForTesting();
2076 2079
2077 // Policy is applied and pref is already updated in local state. 2080 // Policy is applied and pref is already updated in local state.
2078 EXPECT_EQ(default_variations_url + "?restrict=restricted", 2081 EXPECT_EQ(default_variations_url + "?restrict=restricted",
2079 chrome_variations::VariationsService::GetVariationsServerURL( 2082 chrome_variations::VariationsService::GetVariationsServerURL(
2080 g_browser_process->local_state()).spec()); 2083 g_browser_process->local_state()).spec());
2081 } 2084 }
2082 #endif 2085 #endif
2083 2086
2084 } // namespace policy 2087 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698