OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/login/login_interstitial_delegate.h" | 5 #include "chrome/browser/ui/login/login_interstitial_delegate.h" |
6 | 6 |
| 7 content::InterstitialPageDelegate::TypeID |
| 8 LoginInterstitialDelegate::kTypeForTesting = |
| 9 &LoginInterstitialDelegate::kTypeForTesting; |
| 10 |
7 LoginInterstitialDelegate::LoginInterstitialDelegate( | 11 LoginInterstitialDelegate::LoginInterstitialDelegate( |
8 content::WebContents* web_contents, | 12 content::WebContents* web_contents, |
9 const GURL& request_url, | 13 const GURL& request_url, |
10 base::Closure& callback) | 14 base::Closure& callback) |
11 : callback_(callback) { | 15 : callback_(callback) { |
12 // The interstitial page owns us. | 16 // The interstitial page owns us. |
13 content::InterstitialPage* interstitial_page = | 17 content::InterstitialPage* interstitial_page = |
14 content::InterstitialPage::Create(web_contents, | 18 content::InterstitialPage::Create(web_contents, |
15 true, | 19 true, |
16 request_url, | 20 request_url, |
17 this); | 21 this); |
18 interstitial_page->Show(); | 22 interstitial_page->Show(); |
19 } | 23 } |
20 | 24 |
21 LoginInterstitialDelegate::~LoginInterstitialDelegate() { | 25 LoginInterstitialDelegate::~LoginInterstitialDelegate() { |
22 } | 26 } |
23 | 27 |
24 void LoginInterstitialDelegate::CommandReceived(const std::string& command) { | 28 void LoginInterstitialDelegate::CommandReceived(const std::string& command) { |
25 callback_.Run(); | 29 callback_.Run(); |
26 } | 30 } |
27 | 31 |
| 32 content::InterstitialPageDelegate::TypeID |
| 33 LoginInterstitialDelegate::GetTypeForTesting() const { |
| 34 return LoginInterstitialDelegate::kTypeForTesting; |
| 35 } |
| 36 |
28 std::string LoginInterstitialDelegate::GetHTMLContents() { | 37 std::string LoginInterstitialDelegate::GetHTMLContents() { |
29 // Showing an interstitial results in a new navigation, and a new navigation | 38 // Showing an interstitial results in a new navigation, and a new navigation |
30 // closes all modal dialogs on the page. Therefore the login prompt must be | 39 // closes all modal dialogs on the page. Therefore the login prompt must be |
31 // shown after the interstitial is displayed. This is done by sending a | 40 // shown after the interstitial is displayed. This is done by sending a |
32 // command from the interstitial page as soon as it is loaded. | 41 // command from the interstitial page as soon as it is loaded. |
33 return std::string( | 42 return std::string( |
34 "<!DOCTYPE html>" | 43 "<!DOCTYPE html>" |
35 "<html><body><script>" | 44 "<html><body><script>" |
36 "window.domAutomationController.setAutomationId(1);" | 45 "window.domAutomationController.setAutomationId(1);" |
37 "window.domAutomationController.send('1');" | 46 "window.domAutomationController.send('1');" |
38 "</script></body></html>"); | 47 "</script></body></html>"); |
39 } | 48 } |
OLD | NEW |