| 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/strings/stringprintf.h" | 5 #include "base/strings/stringprintf.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "chrome/browser/background/background_contents_service.h" | 7 #include "chrome/browser/background/background_contents_service.h" |
| 8 #include "chrome/browser/background/background_contents_service_factory.h" | 8 #include "chrome/browser/background/background_contents_service_factory.h" |
| 9 #include "chrome/browser/background/background_mode_manager.h" | 9 #include "chrome/browser/background/background_mode_manager.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 return true; | 62 return true; |
| 63 #else | 63 #else |
| 64 BackgroundModeManager* manager = | 64 BackgroundModeManager* manager = |
| 65 g_browser_process->background_mode_manager(); | 65 g_browser_process->background_mode_manager(); |
| 66 // If background mode is disabled on this platform (e.g. cros), then skip | 66 // If background mode is disabled on this platform (e.g. cros), then skip |
| 67 // this check. | 67 // this check. |
| 68 if (!manager || !manager->IsBackgroundModePrefEnabled()) { | 68 if (!manager || !manager->IsBackgroundModePrefEnabled()) { |
| 69 DLOG(WARNING) << "Skipping check - background mode disabled"; | 69 DLOG(WARNING) << "Skipping check - background mode disabled"; |
| 70 return true; | 70 return true; |
| 71 } | 71 } |
| 72 if (manager->IsBackgroundModeActiveForTest() == expected_background_mode) | 72 if (manager->IsBackgroundModeActive() == expected_background_mode) |
| 73 return true; | 73 return true; |
| 74 | 74 |
| 75 // We are not currently in the expected state - wait for the state to | 75 // We are not currently in the expected state - wait for the state to |
| 76 // change. | 76 // change. |
| 77 content::WindowedNotificationObserver watcher( | 77 content::WindowedNotificationObserver watcher( |
| 78 chrome::NOTIFICATION_BACKGROUND_MODE_CHANGED, | 78 chrome::NOTIFICATION_BACKGROUND_MODE_CHANGED, |
| 79 content::NotificationService::AllSources()); | 79 content::NotificationService::AllSources()); |
| 80 watcher.Wait(); | 80 watcher.Wait(); |
| 81 return manager->IsBackgroundModeActiveForTest() == expected_background_mode; | 81 return manager->IsBackgroundModeActive() == expected_background_mode; |
| 82 #endif | 82 #endif |
| 83 } | 83 } |
| 84 | 84 |
| 85 void CloseBrowser(Browser* browser) { | 85 void CloseBrowser(Browser* browser) { |
| 86 content::WindowedNotificationObserver observer( | 86 content::WindowedNotificationObserver observer( |
| 87 chrome::NOTIFICATION_BROWSER_CLOSED, | 87 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 88 content::NotificationService::AllSources()); | 88 content::NotificationService::AllSources()); |
| 89 browser->window()->Close(); | 89 browser->window()->Close(); |
| 90 #if defined(OS_MACOSX) | 90 #if defined(OS_MACOSX) |
| 91 // BrowserWindowController depends on the auto release pool being recycled | 91 // BrowserWindowController depends on the auto release pool being recycled |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 // Close all browsers - app should continue running. | 488 // Close all browsers - app should continue running. |
| 489 set_exit_when_last_browser_closes(false); | 489 set_exit_when_last_browser_closes(false); |
| 490 CloseBrowser(browser()); | 490 CloseBrowser(browser()); |
| 491 | 491 |
| 492 // Post a task to unload the extension - this should cause Chrome to exit | 492 // Post a task to unload the extension - this should cause Chrome to exit |
| 493 // cleanly (not crash). | 493 // cleanly (not crash). |
| 494 UnloadExtensionViaTask(extension->id()); | 494 UnloadExtensionViaTask(extension->id()); |
| 495 content::RunAllPendingInMessageLoop(); | 495 content::RunAllPendingInMessageLoop(); |
| 496 ASSERT_TRUE(WaitForBackgroundMode(false)); | 496 ASSERT_TRUE(WaitForBackgroundMode(false)); |
| 497 } | 497 } |
| OLD | NEW |