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 <algorithm> | 5 #include <algorithm> |
6 #include <list> | 6 #include <list> |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/prerender/prerender_manager.h" | 12 #include "chrome/browser/prerender/prerender_manager.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_commands.h" | 14 #include "chrome/browser/ui/browser_commands.h" |
| 15 #include "chrome/browser/ui/login/login_interstitial_delegate.h" |
15 #include "chrome/browser/ui/login/login_prompt.h" | 16 #include "chrome/browser/ui/login/login_prompt.h" |
16 #include "chrome/browser/ui/login/login_prompt_test_utils.h" | 17 #include "chrome/browser/ui/login/login_prompt_test_utils.h" |
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
18 #include "chrome/test/base/in_process_browser_test.h" | 19 #include "chrome/test/base/in_process_browser_test.h" |
19 #include "chrome/test/base/ui_test_utils.h" | 20 #include "chrome/test/base/ui_test_utils.h" |
20 #include "content/public/browser/interstitial_page.h" | 21 #include "content/public/browser/interstitial_page.h" |
21 #include "content/public/browser/notification_details.h" | 22 #include "content/public/browser/notification_details.h" |
22 #include "content/public/browser/notification_source.h" | 23 #include "content/public/browser/notification_source.h" |
23 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
24 #include "content/public/test/browser_test_utils.h" | 25 #include "content/public/test/browser_test_utils.h" |
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 false)); | 1164 false)); |
1164 ASSERT_EQ(visit_url.host(), contents->GetVisibleURL().host()); | 1165 ASSERT_EQ(visit_url.host(), contents->GetVisibleURL().host()); |
1165 auth_needed_waiter.Wait(); | 1166 auth_needed_waiter.Wait(); |
1166 ASSERT_EQ(1u, observer.handlers().size()); | 1167 ASSERT_EQ(1u, observer.handlers().size()); |
1167 content::WaitForInterstitialAttach(contents); | 1168 content::WaitForInterstitialAttach(contents); |
1168 | 1169 |
1169 // The omnibox should show the correct origin for the new page when the | 1170 // The omnibox should show the correct origin for the new page when the |
1170 // login prompt is shown. | 1171 // login prompt is shown. |
1171 EXPECT_EQ(auth_host, contents->GetVisibleURL().host()); | 1172 EXPECT_EQ(auth_host, contents->GetVisibleURL().host()); |
1172 EXPECT_TRUE(contents->ShowingInterstitialPage()); | 1173 EXPECT_TRUE(contents->ShowingInterstitialPage()); |
| 1174 EXPECT_EQ(LoginInterstitialDelegate::kTypeForTesting, |
| 1175 contents->GetInterstitialPage() |
| 1176 ->GetDelegateForTesting() |
| 1177 ->GetTypeForTesting()); |
1173 | 1178 |
1174 // Cancel and wait for the interstitial to detach. | 1179 // Cancel and wait for the interstitial to detach. |
1175 LoginHandler* handler = *observer.handlers().begin(); | 1180 LoginHandler* handler = *observer.handlers().begin(); |
1176 content::RunTaskAndWaitForInterstitialDetach( | 1181 content::RunTaskAndWaitForInterstitialDetach( |
1177 contents, base::Bind(&LoginHandler::CancelAuth, handler)); | 1182 contents, base::Bind(&LoginHandler::CancelAuth, handler)); |
1178 | 1183 |
1179 EXPECT_EQ(auth_host, contents->GetVisibleURL().host()); | 1184 EXPECT_EQ(auth_host, contents->GetVisibleURL().host()); |
1180 EXPECT_FALSE(contents->ShowingInterstitialPage()); | 1185 EXPECT_FALSE(contents->ShowingInterstitialPage()); |
1181 } | 1186 } |
1182 } | 1187 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 // the interstitial to see the login prompt. | 1246 // the interstitial to see the login prompt. |
1242 contents->GetInterstitialPage()->Proceed(); | 1247 contents->GetInterstitialPage()->Proceed(); |
1243 auth_needed_waiter.Wait(); | 1248 auth_needed_waiter.Wait(); |
1244 ASSERT_EQ(1u, observer.handlers().size()); | 1249 ASSERT_EQ(1u, observer.handlers().size()); |
1245 content::WaitForInterstitialAttach(contents); | 1250 content::WaitForInterstitialAttach(contents); |
1246 | 1251 |
1247 // The omnibox should show the correct origin while the login prompt is | 1252 // The omnibox should show the correct origin while the login prompt is |
1248 // being displayed. | 1253 // being displayed. |
1249 EXPECT_EQ("127.0.0.1", contents->GetVisibleURL().host()); | 1254 EXPECT_EQ("127.0.0.1", contents->GetVisibleURL().host()); |
1250 EXPECT_TRUE(contents->ShowingInterstitialPage()); | 1255 EXPECT_TRUE(contents->ShowingInterstitialPage()); |
| 1256 EXPECT_EQ(LoginInterstitialDelegate::kTypeForTesting, |
| 1257 contents->GetInterstitialPage() |
| 1258 ->GetDelegateForTesting() |
| 1259 ->GetTypeForTesting()); |
1251 | 1260 |
1252 // Cancelling the login prompt should detach the interstitial while keeping | 1261 // Cancelling the login prompt should detach the interstitial while keeping |
1253 // the correct origin. | 1262 // the correct origin. |
1254 LoginHandler* handler = *observer.handlers().begin(); | 1263 LoginHandler* handler = *observer.handlers().begin(); |
1255 content::RunTaskAndWaitForInterstitialDetach( | 1264 content::RunTaskAndWaitForInterstitialDetach( |
1256 contents, base::Bind(&LoginHandler::CancelAuth, handler)); | 1265 contents, base::Bind(&LoginHandler::CancelAuth, handler)); |
1257 | 1266 |
1258 EXPECT_EQ("127.0.0.1", contents->GetVisibleURL().host()); | 1267 EXPECT_EQ("127.0.0.1", contents->GetVisibleURL().host()); |
1259 EXPECT_FALSE(contents->ShowingInterstitialPage()); | 1268 EXPECT_FALSE(contents->ShowingInterstitialPage()); |
1260 } | 1269 } |
1261 } | 1270 } |
1262 | 1271 |
1263 } // namespace | 1272 } // namespace |
OLD | NEW |