| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
| 6 #include "base/stl_util-inl.h" | 6 #include "base/stl_util-inl.h" |
| 7 #include "chrome/browser/extensions/autoupdate_interceptor.h" | 7 #include "chrome/browser/extensions/autoupdate_interceptor.h" |
| 8 #include "chrome/browser/extensions/extension_browsertest.h" | 8 #include "chrome/browser/extensions/extension_browsertest.h" |
| 9 #include "chrome/browser/extensions/extension_host.h" | 9 #include "chrome/browser/extensions/extension_host.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 const size_t size_before = service->extensions()->size(); | 117 const size_t size_before = service->extensions()->size(); |
| 118 ASSERT_TRUE(InstallExtension( | 118 ASSERT_TRUE(InstallExtension( |
| 119 test_data_dir_.AppendASCII("install/install.crx"), 1)); | 119 test_data_dir_.AppendASCII("install/install.crx"), 1)); |
| 120 | 120 |
| 121 // Cancel this install. | 121 // Cancel this install. |
| 122 StartInstallButCancel(test_data_dir_.AppendASCII("install/install_v2.crx")); | 122 StartInstallButCancel(test_data_dir_.AppendASCII("install/install_v2.crx")); |
| 123 EXPECT_TRUE(IsExtensionAtVersion(service->extensions()->at(size_before), | 123 EXPECT_TRUE(IsExtensionAtVersion(service->extensions()->at(size_before), |
| 124 "1.0")); | 124 "1.0")); |
| 125 } | 125 } |
| 126 | 126 |
| 127 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, InstallRequiresConfirm) { |
| 128 // Installing the extension without an auto confirming UI should fail |
| 129 // since good.crx has permissions that require approval. |
| 130 ASSERT_TRUE(InstallExtension(test_data_dir_.AppendASCII("good.crx"), 0)); |
| 131 UninstallExtension("ldnnhddmnhbkjipkidpdiheffobcpfmf"); |
| 132 |
| 133 // And the install should succeed when the permissions are accepted. |
| 134 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( |
| 135 test_data_dir_.AppendASCII("good.crx"), 1, browser()->profile())); |
| 136 UninstallExtension("ldnnhddmnhbkjipkidpdiheffobcpfmf"); |
| 137 } |
| 138 |
| 127 // Tests that installing and uninstalling extensions don't crash with an | 139 // Tests that installing and uninstalling extensions don't crash with an |
| 128 // incognito window open. | 140 // incognito window open. |
| 129 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, Incognito) { | 141 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, Incognito) { |
| 130 // Open an incognito window to the extensions management page. We just | 142 // Open an incognito window to the extensions management page. We just |
| 131 // want to make sure that we don't crash while playing with extensions when | 143 // want to make sure that we don't crash while playing with extensions when |
| 132 // this guy is around. | 144 // this guy is around. |
| 133 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), | 145 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), |
| 134 GURL(chrome::kChromeUIExtensionsURL)); | 146 GURL(chrome::kChromeUIExtensionsURL)); |
| 135 | 147 |
| 136 ASSERT_TRUE(InstallExtension(test_data_dir_.AppendASCII("good.crx"), 1)); | 148 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( |
| 149 test_data_dir_.AppendASCII("good.crx"), 1, browser()->profile())); |
| 137 UninstallExtension("ldnnhddmnhbkjipkidpdiheffobcpfmf"); | 150 UninstallExtension("ldnnhddmnhbkjipkidpdiheffobcpfmf"); |
| 138 } | 151 } |
| 139 | 152 |
| 140 // Tests the process of updating an extension to one that requires higher | 153 // Tests the process of updating an extension to one that requires higher |
| 141 // permissions. | 154 // permissions. |
| 142 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, UpdatePermissions) { | 155 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, UpdatePermissions) { |
| 143 ExtensionService* service = browser()->profile()->GetExtensionService(); | 156 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 144 ASSERT_TRUE(InstallAndUpdateIncreasingPermissionsExtension()); | 157 ASSERT_TRUE(InstallAndUpdateIncreasingPermissionsExtension()); |
| 145 const size_t size_before = service->extensions()->size(); | 158 const size_t size_before = service->extensions()->size(); |
| 146 | 159 |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 | 493 |
| 481 // Check that emptying the list triggers uninstall. | 494 // Check that emptying the list triggers uninstall. |
| 482 { | 495 { |
| 483 prefs->ClearPref(prefs::kExtensionInstallForceList); | 496 prefs->ClearPref(prefs::kExtensionInstallForceList); |
| 484 } | 497 } |
| 485 EXPECT_EQ(size_before + 1, extensions->size()); | 498 EXPECT_EQ(size_before + 1, extensions->size()); |
| 486 ExtensionList::const_iterator i; | 499 ExtensionList::const_iterator i; |
| 487 for (i = extensions->begin(); i != extensions->end(); ++i) | 500 for (i = extensions->begin(); i != extensions->end(); ++i) |
| 488 EXPECT_NE(kExtensionId, (*i)->id()); | 501 EXPECT_NE(kExtensionId, (*i)->id()); |
| 489 } | 502 } |
| OLD | NEW |