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

Side by Side Diff: chrome/browser/extensions/api/management/management_api_browsertest.cc

Issue 137793011: Require user confirmation for chrome.management.uninstall except when uninstalling self. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ExtensionManagementApiBrowserTest.LaunchApp Created 6 years, 11 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 | Annotate | Revision Log
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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 ExtensionService* service = ExtensionSystem::Get(browser()->profile())-> 104 ExtensionService* service = ExtensionSystem::Get(browser()->profile())->
105 extension_service(); 105 extension_service();
106 106
107 // Install an extension. 107 // Install an extension.
108 const Extension* extension = InstallExtension( 108 const Extension* extension = InstallExtension(
109 test_data_dir_.AppendASCII("api_test/management/enabled_extension"), 1); 109 test_data_dir_.AppendASCII("api_test/management/enabled_extension"), 1);
110 ASSERT_TRUE(extension); 110 ASSERT_TRUE(extension);
111 111
112 const std::string id = extension->id(); 112 const std::string id = extension->id();
113 113
114 scoped_refptr<Extension> empty_extension(
115 extension_function_test_utils::CreateEmptyExtension());
114 // Uninstall, then cancel via the confirm dialog. 116 // Uninstall, then cancel via the confirm dialog.
115 scoped_refptr<ManagementUninstallFunction> uninstall_function( 117 scoped_refptr<ManagementUninstallFunction> uninstall_function(
116 new ManagementUninstallFunction()); 118 new ManagementUninstallFunction());
119 uninstall_function->set_extension(empty_extension);
120 uninstall_function->set_user_gesture(true);
117 ManagementUninstallFunction::SetAutoConfirmForTest(false); 121 ManagementUninstallFunction::SetAutoConfirmForTest(false);
118 122
119 EXPECT_TRUE(MatchPattern( 123 EXPECT_TRUE(MatchPattern(
120 util::RunFunctionAndReturnError( 124 util::RunFunctionAndReturnError(
121 uninstall_function.get(), 125 uninstall_function.get(),
122 base::StringPrintf("[\"%s\", {\"showConfirmDialog\": true}]", 126 base::StringPrintf("[\"%s\", {\"showConfirmDialog\": true}]",
123 id.c_str()), 127 id.c_str()),
124 browser()), 128 browser()),
125 keys::kUninstallCanceledError)); 129 keys::kUninstallCanceledError));
126 130
127 // Make sure the extension wasn't uninstalled. 131 // Make sure the extension wasn't uninstalled.
128 EXPECT_TRUE(service->GetExtensionById(id, false) != NULL); 132 EXPECT_TRUE(service->GetExtensionById(id, false) != NULL);
129 133
130 // Uninstall, then accept via the confirm dialog. 134 // Uninstall, then accept via the confirm dialog.
131 uninstall_function = new ManagementUninstallFunction(); 135 uninstall_function = new ManagementUninstallFunction();
136 uninstall_function->set_extension(empty_extension);
132 ManagementUninstallFunction::SetAutoConfirmForTest(true); 137 ManagementUninstallFunction::SetAutoConfirmForTest(true);
133 138 uninstall_function->set_user_gesture(true);
134 util::RunFunctionAndReturnSingleResult( 139 util::RunFunctionAndReturnSingleResult(
135 uninstall_function.get(), 140 uninstall_function.get(),
136 base::StringPrintf("[\"%s\", {\"showConfirmDialog\": true}]", id.c_str()), 141 base::StringPrintf("[\"%s\", {\"showConfirmDialog\": true}]", id.c_str()),
137 browser()); 142 browser());
138 143
139 // Make sure the extension was uninstalled. 144 // Make sure the extension was uninstalled.
140 EXPECT_TRUE(service->GetExtensionById(id, false) == NULL); 145 EXPECT_TRUE(service->GetExtensionById(id, false) == NULL);
141 } 146 }
142 147
143 IN_PROC_BROWSER_TEST_F(ExtensionManagementApiBrowserTest, 148 IN_PROC_BROWSER_TEST_F(ExtensionManagementApiBrowserTest,
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 // extension should be reloaded and enabled. 281 // extension should be reloaded and enabled.
277 ASSERT_TRUE(CrashEnabledExtension(kId)); 282 ASSERT_TRUE(CrashEnabledExtension(kId));
278 SetEnabled(false, true, std::string()); 283 SetEnabled(false, true, std::string());
279 SetEnabled(true, true, std::string()); 284 SetEnabled(true, true, std::string());
280 const Extension* extension = ExtensionSystem::Get(browser()->profile()) 285 const Extension* extension = ExtensionSystem::Get(browser()->profile())
281 ->extension_service()->GetExtensionById(kId, false); 286 ->extension_service()->GetExtensionById(kId, false);
282 EXPECT_TRUE(extension); 287 EXPECT_TRUE(extension);
283 } 288 }
284 289
285 } // namespace extensions 290 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698