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 "chrome/browser/ui/tabs/tab_strip_model.h" | 5 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_split.h" | 15 #include "base/strings/string_split.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "chrome/browser/defaults.h" | 18 #include "chrome/browser/defaults.h" |
19 #include "chrome/browser/extensions/tab_helper.h" | 19 #include "chrome/browser/extensions/tab_helper.h" |
20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
22 #include "chrome/browser/ui/browser_tabstrip.h" | 22 #include "chrome/browser/ui/browser_tabstrip.h" |
23 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" | 23 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" |
24 #include "chrome/browser/ui/tabs/tab_strip_model_order_controller.h" | 24 #include "chrome/browser/ui/tabs/tab_strip_model_order_controller.h" |
25 #include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h" | 25 #include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h" |
26 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 26 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
27 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
28 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 28 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
29 #include "chrome/test/base/testing_profile.h" | 29 #include "chrome/test/base/testing_profile.h" |
| 30 #include "components/web_modal/popup_manager.h" |
30 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 31 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
31 #include "content/public/browser/navigation_controller.h" | 32 #include "content/public/browser/navigation_controller.h" |
32 #include "content/public/browser/navigation_entry.h" | 33 #include "content/public/browser/navigation_entry.h" |
33 #include "content/public/browser/render_process_host.h" | 34 #include "content/public/browser/render_process_host.h" |
34 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
35 #include "content/public/browser/web_contents_observer.h" | 36 #include "content/public/browser/web_contents_observer.h" |
36 #include "extensions/common/extension.h" | 37 #include "extensions/common/extension.h" |
37 #include "testing/gtest/include/gtest/gtest.h" | 38 #include "testing/gtest/include/gtest/gtest.h" |
38 | 39 |
39 using content::SiteInstance; | 40 using content::SiteInstance; |
(...skipping 2516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2556 web_modal::WebContentsModalDialogManager::CreateForWebContents(contents2); | 2557 web_modal::WebContentsModalDialogManager::CreateForWebContents(contents2); |
2557 strip_src.AppendWebContents(contents2, false); | 2558 strip_src.AppendWebContents(contents2, false); |
2558 | 2559 |
2559 // Create a destination tab strip. | 2560 // Create a destination tab strip. |
2560 TabStripModel strip_dst(&dummy_tab_strip_delegate, profile()); | 2561 TabStripModel strip_dst(&dummy_tab_strip_delegate, profile()); |
2561 TabBlockedStateTestBrowser browser_dst(&strip_dst); | 2562 TabBlockedStateTestBrowser browser_dst(&strip_dst); |
2562 | 2563 |
2563 // Setup a SingleWebContentsDialogManager for tab |contents2|. | 2564 // Setup a SingleWebContentsDialogManager for tab |contents2|. |
2564 web_modal::WebContentsModalDialogManager* modal_dialog_manager = | 2565 web_modal::WebContentsModalDialogManager* modal_dialog_manager = |
2565 web_modal::WebContentsModalDialogManager::FromWebContents(contents2); | 2566 web_modal::WebContentsModalDialogManager::FromWebContents(contents2); |
2566 web_modal::WebContentsModalDialogManager::TestApi test_api( | 2567 web_modal::PopupManager popup_manager(NULL); |
2567 modal_dialog_manager); | 2568 popup_manager.RegisterWith(contents2); |
2568 | 2569 |
2569 // Show a dialog that blocks tab |contents2|. | 2570 // Show a dialog that blocks tab |contents2|. |
2570 // DummySingleWebContentsDialogManager doesn't care about the | 2571 // DummySingleWebContentsDialogManager doesn't care about the |
2571 // NativeWebContentsModalDialog value, so any dummy value works. | 2572 // NativeWebContentsModalDialog value, so any dummy value works. |
2572 DummySingleWebContentsDialogManager* native_manager = | 2573 DummySingleWebContentsDialogManager* native_manager = |
2573 new DummySingleWebContentsDialogManager( | 2574 new DummySingleWebContentsDialogManager( |
2574 reinterpret_cast<NativeWebContentsModalDialog>(0), | 2575 reinterpret_cast<NativeWebContentsModalDialog>(0), |
2575 modal_dialog_manager); | 2576 modal_dialog_manager); |
2576 modal_dialog_manager->ShowDialogWithManager( | 2577 modal_dialog_manager->ShowDialogWithManager( |
2577 reinterpret_cast<NativeWebContentsModalDialog>(0), | 2578 reinterpret_cast<NativeWebContentsModalDialog>(0), |
2578 scoped_ptr<web_modal::SingleWebContentsDialogManager>( | 2579 scoped_ptr<web_modal::SingleWebContentsDialogManager>( |
2579 native_manager).Pass()); | 2580 native_manager).Pass()); |
2580 EXPECT_TRUE(strip_src.IsTabBlocked(1)); | 2581 EXPECT_TRUE(strip_src.IsTabBlocked(1)); |
2581 | 2582 |
2582 // Detach the tab. | 2583 // Detach the tab. |
2583 WebContents* moved_contents = strip_src.DetachWebContentsAt(1); | 2584 WebContents* moved_contents = strip_src.DetachWebContentsAt(1); |
2584 EXPECT_EQ(contents2, moved_contents); | 2585 EXPECT_EQ(contents2, moved_contents); |
2585 | 2586 |
2586 // Attach the tab to the destination tab strip. | 2587 // Attach the tab to the destination tab strip. |
2587 strip_dst.AppendWebContents(moved_contents, true); | 2588 strip_dst.AppendWebContents(moved_contents, true); |
2588 EXPECT_TRUE(strip_dst.IsTabBlocked(0)); | 2589 EXPECT_TRUE(strip_dst.IsTabBlocked(0)); |
2589 | 2590 |
2590 strip_dst.CloseAllTabs(); | 2591 strip_dst.CloseAllTabs(); |
2591 strip_src.CloseAllTabs(); | 2592 strip_src.CloseAllTabs(); |
2592 } | 2593 } |
OLD | NEW |