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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/sessions/session_backend.h" | 25 #include "chrome/browser/sessions/session_backend.h" |
26 #include "chrome/browser/sessions/session_service_factory.h" | 26 #include "chrome/browser/sessions/session_service_factory.h" |
27 #include "chrome/browser/translate/translate_tab_helper.h" | 27 #include "chrome/browser/translate/translate_tab_helper.h" |
28 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" | 28 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" |
29 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" | 29 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" |
30 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" | 30 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" |
31 #include "chrome/browser/ui/browser.h" | 31 #include "chrome/browser/ui/browser.h" |
32 #include "chrome/browser/ui/browser_command_controller.h" | 32 #include "chrome/browser/ui/browser_command_controller.h" |
33 #include "chrome/browser/ui/browser_commands.h" | 33 #include "chrome/browser/ui/browser_commands.h" |
34 #include "chrome/browser/ui/browser_finder.h" | 34 #include "chrome/browser/ui/browser_finder.h" |
| 35 #include "chrome/browser/ui/browser_iterator.h" |
35 #include "chrome/browser/ui/browser_list.h" | 36 #include "chrome/browser/ui/browser_list.h" |
36 #include "chrome/browser/ui/browser_navigator.h" | 37 #include "chrome/browser/ui/browser_navigator.h" |
37 #include "chrome/browser/ui/browser_tabstrip.h" | 38 #include "chrome/browser/ui/browser_tabstrip.h" |
38 #include "chrome/browser/ui/browser_ui_prefs.h" | 39 #include "chrome/browser/ui/browser_ui_prefs.h" |
39 #include "chrome/browser/ui/browser_window.h" | 40 #include "chrome/browser/ui/browser_window.h" |
40 #include "chrome/browser/ui/extensions/application_launch.h" | 41 #include "chrome/browser/ui/extensions/application_launch.h" |
41 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 42 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
42 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | 43 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
43 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" | 44 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" |
44 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 45 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 EXPECT_TRUE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops); | 795 EXPECT_TRUE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops); |
795 | 796 |
796 // Turn |app_tab| into a tab in an app panel. | 797 // Turn |app_tab| into a tab in an app panel. |
797 chrome::ConvertTabToAppWindow(browser(), app_tab); | 798 chrome::ConvertTabToAppWindow(browser(), app_tab); |
798 | 799 |
799 // The launch should have created a new browser. | 800 // The launch should have created a new browser. |
800 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); | 801 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); |
801 | 802 |
802 // Find the new browser. | 803 // Find the new browser. |
803 Browser* app_browser = NULL; | 804 Browser* app_browser = NULL; |
804 for (BrowserList::const_iterator i = BrowserList::begin(); | 805 for (chrome::BrowserIterator it; !it.done() && !app_browser; it.Next()) { |
805 i != BrowserList::end() && !app_browser; ++i) { | 806 if (*it != browser()) |
806 if (*i != browser()) | 807 app_browser = *it; |
807 app_browser = *i; | |
808 } | 808 } |
809 ASSERT_TRUE(app_browser); | 809 ASSERT_TRUE(app_browser); |
810 | 810 |
811 // Check that the tab contents is in the new browser, and not in the old. | 811 // Check that the tab contents is in the new browser, and not in the old. |
812 ASSERT_EQ(1, browser()->tab_strip_model()->count()); | 812 ASSERT_EQ(1, browser()->tab_strip_model()->count()); |
813 ASSERT_EQ(initial_tab, browser()->tab_strip_model()->GetWebContentsAt(0)); | 813 ASSERT_EQ(initial_tab, browser()->tab_strip_model()->GetWebContentsAt(0)); |
814 | 814 |
815 // Check that the appliaction browser has a single tab, and that tab contains | 815 // Check that the appliaction browser has a single tab, and that tab contains |
816 // the content that we app-ified. | 816 // the content that we app-ified. |
817 ASSERT_EQ(1, app_browser->tab_strip_model()->count()); | 817 ASSERT_EQ(1, app_browser->tab_strip_model()->count()); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; | 930 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; |
931 StartupBrowserCreatorImpl launch(base::FilePath(), command_line, first_run); | 931 StartupBrowserCreatorImpl launch(base::FilePath(), command_line, first_run); |
932 ASSERT_TRUE(launch.OpenApplicationWindow(browser()->profile(), NULL)); | 932 ASSERT_TRUE(launch.OpenApplicationWindow(browser()->profile(), NULL)); |
933 | 933 |
934 // Check that the new browser has an app name. | 934 // Check that the new browser has an app name. |
935 // The launch should have created a new browser. | 935 // The launch should have created a new browser. |
936 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); | 936 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); |
937 | 937 |
938 // Find the new browser. | 938 // Find the new browser. |
939 Browser* new_browser = NULL; | 939 Browser* new_browser = NULL; |
940 for (BrowserList::const_iterator i = BrowserList::begin(); | 940 for (chrome::BrowserIterator it; !it.done() && !new_browser; it.Next()) { |
941 i != BrowserList::end() && !new_browser; ++i) { | 941 if (*it != browser()) |
942 if (*i != browser()) | 942 new_browser = *it; |
943 new_browser = *i; | |
944 } | 943 } |
945 ASSERT_TRUE(new_browser); | 944 ASSERT_TRUE(new_browser); |
946 ASSERT_TRUE(new_browser != browser()); | 945 ASSERT_TRUE(new_browser != browser()); |
947 | 946 |
948 // The browser's app_name should include the app's ID. | 947 // The browser's app_name should include the app's ID. |
949 ASSERT_NE( | 948 ASSERT_NE( |
950 new_browser->app_name_.find(extension_app->id()), | 949 new_browser->app_name_.find(extension_app->id()), |
951 std::string::npos) << new_browser->app_name_; | 950 std::string::npos) << new_browser->app_name_; |
952 } | 951 } |
953 #endif | 952 #endif |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; | 1037 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; |
1039 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); | 1038 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); |
1040 launch.profile_ = browser()->profile(); | 1039 launch.profile_ = browser()->profile(); |
1041 launch.ProcessStartupURLs(std::vector<GURL>()); | 1040 launch.ProcessStartupURLs(std::vector<GURL>()); |
1042 | 1041 |
1043 // The launch should have created a new browser. | 1042 // The launch should have created a new browser. |
1044 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); | 1043 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); |
1045 | 1044 |
1046 // Find the new browser. | 1045 // Find the new browser. |
1047 Browser* new_browser = NULL; | 1046 Browser* new_browser = NULL; |
1048 for (BrowserList::const_iterator i = BrowserList::begin(); | 1047 for (chrome::BrowserIterator it; !it.done() && !new_browser; it.Next()) { |
1049 i != BrowserList::end() && !new_browser; ++i) { | 1048 if (*it != browser()) |
1050 if (*i != browser()) | 1049 new_browser = *it; |
1051 new_browser = *i; | |
1052 } | 1050 } |
1053 ASSERT_TRUE(new_browser); | 1051 ASSERT_TRUE(new_browser); |
1054 ASSERT_TRUE(new_browser != browser()); | 1052 ASSERT_TRUE(new_browser != browser()); |
1055 | 1053 |
1056 // We should get back an additional tab for the app, and another for the | 1054 // We should get back an additional tab for the app, and another for the |
1057 // default home page. | 1055 // default home page. |
1058 ASSERT_EQ(3, new_browser->tab_strip_model()->count()); | 1056 ASSERT_EQ(3, new_browser->tab_strip_model()->count()); |
1059 | 1057 |
1060 // Make sure the state matches. | 1058 // Make sure the state matches. |
1061 TabStripModel* new_model = new_browser->tab_strip_model(); | 1059 TabStripModel* new_model = new_browser->tab_strip_model(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 ASSERT_TRUE(extensions::TabHelper::FromWebContents(app_window)); | 1105 ASSERT_TRUE(extensions::TabHelper::FromWebContents(app_window)); |
1108 EXPECT_FALSE( | 1106 EXPECT_FALSE( |
1109 extensions::TabHelper::FromWebContents(app_window)->extension_app()); | 1107 extensions::TabHelper::FromWebContents(app_window)->extension_app()); |
1110 EXPECT_EQ(extension_app->GetFullLaunchURL(), app_window->GetURL()); | 1108 EXPECT_EQ(extension_app->GetFullLaunchURL(), app_window->GetURL()); |
1111 | 1109 |
1112 // The launch should have created a new browser. | 1110 // The launch should have created a new browser. |
1113 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); | 1111 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); |
1114 | 1112 |
1115 // Find the new browser. | 1113 // Find the new browser. |
1116 Browser* new_browser = NULL; | 1114 Browser* new_browser = NULL; |
1117 for (BrowserList::const_iterator i = BrowserList::begin(); | 1115 for (chrome::BrowserIterator it; !it.done() && !new_browser; it.Next()) { |
1118 i != BrowserList::end() && !new_browser; ++i) { | 1116 if (*it != browser()) |
1119 if (*i != browser()) | 1117 new_browser = *it; |
1120 new_browser = *i; | |
1121 } | 1118 } |
1122 ASSERT_TRUE(new_browser); | 1119 ASSERT_TRUE(new_browser); |
1123 ASSERT_TRUE(new_browser != browser()); | 1120 ASSERT_TRUE(new_browser != browser()); |
1124 | 1121 |
1125 EXPECT_TRUE(new_browser->is_app()); | 1122 EXPECT_TRUE(new_browser->is_app()); |
1126 | 1123 |
1127 // The browser's app name should include the extension's id. | 1124 // The browser's app name should include the extension's id. |
1128 std::string app_name = new_browser->app_name_; | 1125 std::string app_name = new_browser->app_name_; |
1129 EXPECT_NE(app_name.find(extension_app->id()), std::string::npos) | 1126 EXPECT_NE(app_name.find(extension_app->id()), std::string::npos) |
1130 << "Name " << app_name << " should contain id "<< extension_app->id(); | 1127 << "Name " << app_name << " should contain id "<< extension_app->id(); |
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2023 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2020 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
2024 } | 2021 } |
2025 | 2022 |
2026 // Shift-middle-clicks open in a foreground tab. | 2023 // Shift-middle-clicks open in a foreground tab. |
2027 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) { | 2024 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) { |
2028 int modifiers = WebKit::WebInputEvent::ShiftKey; | 2025 int modifiers = WebKit::WebInputEvent::ShiftKey; |
2029 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle; | 2026 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle; |
2030 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; | 2027 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; |
2031 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2028 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
2032 } | 2029 } |
OLD | NEW |