Home | History | Annotate | Download | only in login
      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
      3 // found in the LICENSE file.
      4 
      5 #include "chrome/browser/ui/login/login_interstitial_delegate.h"
      6 
      7 LoginInterstitialDelegate::LoginInterstitialDelegate(
      8     content::WebContents* web_contents,
      9     const GURL& request_url,
     10     base::Closure& callback)
     11     : callback_(callback) {
     12   // The interstitial page owns us.
     13   content::InterstitialPage* interstitial_page =
     14       content::InterstitialPage::Create(web_contents,
     15                                         true,
     16                                         request_url,
     17                                         this);
     18   interstitial_page->Show();
     19 }
     20 
     21 LoginInterstitialDelegate::~LoginInterstitialDelegate() {
     22 }
     23 
     24 void LoginInterstitialDelegate::CommandReceived(const std::string& command) {
     25   callback_.Run();
     26 }
     27 
     28 std::string LoginInterstitialDelegate::GetHTMLContents() {
     29   // 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
     31   // shown after the interstitial is displayed. This is done by sending a
     32   // command from the interstitial page as soon as it is loaded.
     33   return std::string(
     34       "<!DOCTYPE html>"
     35       "<html><body><script>"
     36       "window.domAutomationController.setAutomationId(1);"
     37       "window.domAutomationController.send('1');"
     38       "</script></body></html>");
     39 }
     40