| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/lifetime/browser_close_manager.h" | 5 #include "chrome/browser/lifetime/browser_close_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "chrome/test/base/in_process_browser_test.h" | 38 #include "chrome/test/base/in_process_browser_test.h" |
| 39 #include "chrome/test/base/ui_test_utils.h" | 39 #include "chrome/test/base/ui_test_utils.h" |
| 40 #include "components/app_modal/javascript_app_modal_dialog.h" | 40 #include "components/app_modal/javascript_app_modal_dialog.h" |
| 41 #include "components/app_modal/native_app_modal_dialog.h" | 41 #include "components/app_modal/native_app_modal_dialog.h" |
| 42 #include "components/sessions/core/tab_restore_service.h" | 42 #include "components/sessions/core/tab_restore_service.h" |
| 43 #include "components/sessions/core/tab_restore_service_observer.h" | 43 #include "components/sessions/core/tab_restore_service_observer.h" |
| 44 #include "content/public/browser/browser_context.h" | 44 #include "content/public/browser/browser_context.h" |
| 45 #include "content/public/browser/download_item.h" | 45 #include "content/public/browser/download_item.h" |
| 46 #include "content/public/browser/download_manager.h" | 46 #include "content/public/browser/download_manager.h" |
| 47 #include "content/public/browser/notification_service.h" | 47 #include "content/public/browser/notification_service.h" |
| 48 #include "content/public/browser/render_frame_host.h" |
| 48 #include "content/public/browser/render_view_host.h" | 49 #include "content/public/browser/render_view_host.h" |
| 49 #include "content/public/browser/render_widget_host.h" | 50 #include "content/public/browser/render_widget_host.h" |
| 50 #include "content/public/browser/web_contents.h" | 51 #include "content/public/browser/web_contents.h" |
| 51 #include "content/public/test/browser_test_utils.h" | 52 #include "content/public/test/browser_test_utils.h" |
| 52 #include "content/public/test/download_test_observer.h" | 53 #include "content/public/test/download_test_observer.h" |
| 53 #include "content/public/test/test_navigation_observer.h" | 54 #include "content/public/test/test_navigation_observer.h" |
| 54 #include "net/test/embedded_test_server/embedded_test_server.h" | 55 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 55 #include "net/test/url_request/url_request_mock_http_job.h" | 56 #include "net/test/url_request/url_request_mock_http_job.h" |
| 56 #include "net/test/url_request/url_request_slow_download_job.h" | 57 #include "net/test/url_request/url_request_slow_download_job.h" |
| 57 | 58 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 ui_test_utils::NavigateToURLWithDisposition( | 285 ui_test_utils::NavigateToURLWithDisposition( |
| 285 browser, GURL(net::URLRequestSlowDownloadJob::kKnownSizeUrl), | 286 browser, GURL(net::URLRequestSlowDownloadJob::kKnownSizeUrl), |
| 286 WindowOpenDisposition::NEW_BACKGROUND_TAB, | 287 WindowOpenDisposition::NEW_BACKGROUND_TAB, |
| 287 ui_test_utils::BROWSER_TEST_NONE); | 288 ui_test_utils::BROWSER_TEST_NONE); |
| 288 observer.WaitForFinished(); | 289 observer.WaitForFinished(); |
| 289 EXPECT_EQ( | 290 EXPECT_EQ( |
| 290 1UL, | 291 1UL, |
| 291 observer.NumDownloadsSeenInState(content::DownloadItem::IN_PROGRESS)); | 292 observer.NumDownloadsSeenInState(content::DownloadItem::IN_PROGRESS)); |
| 292 } | 293 } |
| 293 | 294 |
| 294 // Makes sure that hang monitor will not trigger RendererUnresponsive | 295 // Makes sure that the beforeunload hang monitor will not trigger. That must |
| 295 // for that web content or browser. That must be called before close action | 296 // be called before close action when using |AcceptClose| or |CancelClose|, to |
| 296 // when using |AcceptClose| or |CancelClose|, to ensure the timeout does not | 297 // ensure the timeout does not prevent the dialog from appearing. |
| 297 // prevent the dialog from appearing. https://crbug.com/519646 | 298 // https://crbug.com/519646 |
| 298 void DisableHangMonitor(content::WebContents* web_contents) { | 299 void DisableHangMonitor(content::WebContents* web_contents) { |
| 299 web_contents->GetRenderViewHost() | 300 web_contents->GetMainFrame()->DisableBeforeUnloadHangMonitorForTesting(); |
| 300 ->GetWidget() | |
| 301 ->DisableHangMonitorForTesting(); | |
| 302 } | 301 } |
| 303 | 302 |
| 304 void DisableHangMonitor(Browser* browser) { | 303 void DisableHangMonitor(Browser* browser) { |
| 305 for (int i = 0; i < browser->tab_strip_model()->count(); i++) | 304 for (int i = 0; i < browser->tab_strip_model()->count(); i++) |
| 306 DisableHangMonitor(browser->tab_strip_model()->GetWebContentsAt(i)); | 305 DisableHangMonitor(browser->tab_strip_model()->GetWebContentsAt(i)); |
| 307 } | 306 } |
| 308 | 307 |
| 309 std::vector<Browser*> browsers_; | 308 std::vector<Browser*> browsers_; |
| 310 }; | 309 }; |
| 311 | 310 |
| (...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1293 | 1292 |
| 1294 chrome::CloseAllBrowsers(); | 1293 chrome::CloseAllBrowsers(); |
| 1295 EXPECT_FALSE(browser_shutdown::IsTryingToQuit()); | 1294 EXPECT_FALSE(browser_shutdown::IsTryingToQuit()); |
| 1296 EXPECT_TRUE(BrowserList::GetInstance()->empty()); | 1295 EXPECT_TRUE(BrowserList::GetInstance()->empty()); |
| 1297 EXPECT_TRUE(IsBackgroundModeSuspended()); | 1296 EXPECT_TRUE(IsBackgroundModeSuspended()); |
| 1298 } | 1297 } |
| 1299 | 1298 |
| 1300 INSTANTIATE_TEST_CASE_P(BrowserCloseManagerWithBackgroundModeBrowserTest, | 1299 INSTANTIATE_TEST_CASE_P(BrowserCloseManagerWithBackgroundModeBrowserTest, |
| 1301 BrowserCloseManagerWithBackgroundModeBrowserTest, | 1300 BrowserCloseManagerWithBackgroundModeBrowserTest, |
| 1302 testing::Bool()); | 1301 testing::Bool()); |
| OLD | NEW |