| 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 #include "content/public/browser/navigation_entry.h" |
| 8 #include "content/public/common/ssl_status.h" |
| 9 |
| 7 LoginInterstitialDelegate::LoginInterstitialDelegate( | 10 LoginInterstitialDelegate::LoginInterstitialDelegate( |
| 8 content::WebContents* web_contents, | 11 content::WebContents* web_contents, |
| 9 const GURL& request_url, | 12 const GURL& request_url, |
| 13 const content::SSLStatus& ssl_status, |
| 10 base::Closure& callback) | 14 base::Closure& callback) |
| 11 : callback_(callback) { | 15 : web_contents_(web_contents), |
| 16 ssl_status_(ssl_status), |
| 17 callback_(callback) { |
| 12 // The interstitial page owns us. | 18 // The interstitial page owns us. |
| 13 content::InterstitialPage* interstitial_page = | 19 content::InterstitialPage* interstitial_page = |
| 14 content::InterstitialPage::Create(web_contents, | 20 content::InterstitialPage::Create(web_contents, |
| 15 true, | 21 true, |
| 16 request_url, | 22 request_url, |
| 17 this); | 23 this); |
| 18 interstitial_page->Show(); | 24 interstitial_page->Show(); |
| 19 } | 25 } |
| 20 | 26 |
| 21 LoginInterstitialDelegate::~LoginInterstitialDelegate() { | 27 LoginInterstitialDelegate::~LoginInterstitialDelegate() { |
| 22 } | 28 } |
| 23 | 29 |
| 24 void LoginInterstitialDelegate::CommandReceived(const std::string& command) { | 30 void LoginInterstitialDelegate::CommandReceived(const std::string& command) { |
| 25 callback_.Run(); | 31 callback_.Run(); |
| 26 } | 32 } |
| 27 | 33 |
| 28 std::string LoginInterstitialDelegate::GetHTMLContents() { | 34 std::string LoginInterstitialDelegate::GetHTMLContents() { |
| 29 // Showing an interstitial results in a new navigation, and a new navigation | 35 // 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 | 36 // 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 | 37 // shown after the interstitial is displayed. This is done by sending a |
| 32 // command from the interstitial page as soon as it is loaded. | 38 // command from the interstitial page as soon as it is loaded. |
| 33 return std::string( | 39 return std::string( |
| 34 "<!DOCTYPE html>" | 40 "<!DOCTYPE html>" |
| 35 "<html><body><script>" | 41 "<html><body><script>" |
| 36 "window.domAutomationController.setAutomationId(1);" | 42 "window.domAutomationController.setAutomationId(1);" |
| 37 "window.domAutomationController.send('1');" | 43 "window.domAutomationController.send('1');" |
| 38 "</script></body></html>"); | 44 "</script></body></html>"); |
| 39 } | 45 } |
| 46 |
| 47 void LoginInterstitialDelegate::OverrideEntry(content::NavigationEntry* entry) { |
| 48 entry->GetSSL().security_style = ssl_status_.security_style; |
| 49 entry->GetSSL().cert_id = ssl_status_.cert_id; |
| 50 entry->GetSSL().cert_status = ssl_status_.cert_status; |
| 51 entry->GetSSL().security_bits = ssl_status_.security_bits; |
| 52 entry->GetSSL().connection_status = ssl_status_.connection_status; |
| 53 entry->GetSSL().content_status = ssl_status_.content_status; |
| 54 entry->GetSSL().signed_certificate_timestamp_ids = |
| 55 ssl_status_.signed_certificate_timestamp_ids; |
| 56 } |
| OLD | NEW |