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 "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "chrome/browser/chrome_notification_types.h" | |
10 #include "chrome/browser/extensions/api/management/management_api.h" | 9 #include "chrome/browser/extensions/api/management/management_api.h" |
11 #include "chrome/browser/extensions/api/management/management_api_constants.h" | 10 #include "chrome/browser/extensions/api/management/management_api_constants.h" |
12 #include "chrome/browser/extensions/extension_browsertest.h" | 11 #include "chrome/browser/extensions/extension_browsertest.h" |
13 #include "chrome/browser/extensions/extension_function_test_utils.h" | 12 #include "chrome/browser/extensions/extension_function_test_utils.h" |
14 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
15 #include "chrome/browser/extensions/extension_test_message_listener.h" | 14 #include "chrome/browser/extensions/extension_test_message_listener.h" |
16 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
18 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
19 #include "content/public/common/url_constants.h" | 18 #include "content/public/common/url_constants.h" |
20 #include "content/public/test/browser_test_utils.h" | 19 #include "content/public/test/browser_test_utils.h" |
21 #include "content/public/test/test_utils.h" | 20 #include "content/public/test/test_utils.h" |
22 #include "extensions/browser/extension_host.h" | 21 #include "extensions/browser/extension_host.h" |
23 #include "extensions/browser/extension_prefs.h" | 22 #include "extensions/browser/extension_prefs.h" |
24 #include "extensions/browser/extension_system.h" | 23 #include "extensions/browser/extension_system.h" |
| 24 #include "extensions/browser/notification_types.h" |
25 | 25 |
26 namespace keys = extension_management_api_constants; | 26 namespace keys = extension_management_api_constants; |
27 namespace util = extension_function_test_utils; | 27 namespace util = extension_function_test_utils; |
28 | 28 |
29 namespace extensions { | 29 namespace extensions { |
30 | 30 |
31 class ExtensionManagementApiBrowserTest : public ExtensionBrowserTest { | 31 class ExtensionManagementApiBrowserTest : public ExtensionBrowserTest { |
32 protected: | 32 protected: |
33 bool CrashEnabledExtension(const std::string& extension_id) { | 33 bool CrashEnabledExtension(const std::string& extension_id) { |
34 ExtensionHost* background_host = | 34 ExtensionHost* background_host = |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 // Expect an error that user cancelled the dialog. | 290 // Expect an error that user cancelled the dialog. |
291 ExtensionInstallPrompt::g_auto_confirm_for_tests = | 291 ExtensionInstallPrompt::g_auto_confirm_for_tests = |
292 ExtensionInstallPrompt::CANCEL; | 292 ExtensionInstallPrompt::CANCEL; |
293 SetEnabled(true, true, keys::kUserDidNotReEnableError); | 293 SetEnabled(true, true, keys::kUserDidNotReEnableError); |
294 | 294 |
295 // This should succeed when user accepts dialog. We must wait for the process | 295 // This should succeed when user accepts dialog. We must wait for the process |
296 // to connect *and* for the channel to finish initializing before trying to | 296 // to connect *and* for the channel to finish initializing before trying to |
297 // crash it. (NOTIFICATION_RENDERER_PROCESS_CREATED does not wait for the | 297 // crash it. (NOTIFICATION_RENDERER_PROCESS_CREATED does not wait for the |
298 // latter and can cause KillProcess to fail on Windows.) | 298 // latter and can cause KillProcess to fail on Windows.) |
299 content::WindowedNotificationObserver observer( | 299 content::WindowedNotificationObserver observer( |
300 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, | 300 extensions::NOTIFICATION_EXTENSION_HOST_CREATED, |
301 content::NotificationService::AllSources()); | 301 content::NotificationService::AllSources()); |
302 ExtensionInstallPrompt::g_auto_confirm_for_tests = | 302 ExtensionInstallPrompt::g_auto_confirm_for_tests = |
303 ExtensionInstallPrompt::ACCEPT; | 303 ExtensionInstallPrompt::ACCEPT; |
304 SetEnabled(true, true, std::string()); | 304 SetEnabled(true, true, std::string()); |
305 observer.Wait(); | 305 observer.Wait(); |
306 | 306 |
307 // Crash the extension. Mock a reload by disabling and then enabling. The | 307 // Crash the extension. Mock a reload by disabling and then enabling. The |
308 // extension should be reloaded and enabled. | 308 // extension should be reloaded and enabled. |
309 ASSERT_TRUE(CrashEnabledExtension(kId)); | 309 ASSERT_TRUE(CrashEnabledExtension(kId)); |
310 SetEnabled(false, true, std::string()); | 310 SetEnabled(false, true, std::string()); |
311 SetEnabled(true, true, std::string()); | 311 SetEnabled(true, true, std::string()); |
312 const Extension* extension = ExtensionSystem::Get(browser()->profile()) | 312 const Extension* extension = ExtensionSystem::Get(browser()->profile()) |
313 ->extension_service()->GetExtensionById(kId, false); | 313 ->extension_service()->GetExtensionById(kId, false); |
314 EXPECT_TRUE(extension); | 314 EXPECT_TRUE(extension); |
315 } | 315 } |
316 | 316 |
317 } // namespace extensions | 317 } // namespace extensions |
OLD | NEW |