1 // Copyright (c) 2013 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_MERGE_SESSION_LOAD_PAGE_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MERGE_SESSION_LOAD_PAGE_H_ 7 8 #include <string> 9 10 #include "base/callback.h" 11 #include "base/compiler_specific.h" 12 #include "chrome/browser/chromeos/login/oauth2_login_manager.h" 13 #include "content/public/browser/interstitial_page_delegate.h" 14 #include "url/gurl.h" 15 16 namespace base { 17 class DictionaryValue; 18 } 19 20 namespace content { 21 class InterstitialPage; 22 class WebContents; 23 } 24 25 namespace extensions { 26 class Extension; 27 } 28 29 namespace chromeos { 30 31 // MergeSessionLoadPage class shows the interstitial page that is shown 32 // while we are trying to restore session containing tabs with Google properties 33 // during the process of exchanging OAuth2 refresh token for user cookies. 34 // It deletes itself when the interstitial page is closed. 35 class MergeSessionLoadPage 36 : public content::InterstitialPageDelegate, 37 public OAuth2LoginManager::Observer { 38 public: 39 // Passed a boolean indicating whether or not it is OK to proceed with the 40 // page load. 41 typedef base::Closure CompletionCallback; 42 43 // Create a merge session load delay page for the |web_contents|. 44 // The |callback| will be run on the IO thread. 45 MergeSessionLoadPage(content::WebContents* web_contents, 46 const GURL& url, 47 const CompletionCallback& callback); 48 49 void Show(); 50 51 protected: 52 virtual ~MergeSessionLoadPage(); 53 54 private: 55 friend class TestMergeSessionLoadPage; 56 57 // InterstitialPageDelegate implementation. 58 virtual std::string GetHTMLContents() OVERRIDE; 59 virtual void CommandReceived(const std::string& command) OVERRIDE; 60 virtual void OverrideRendererPrefs( 61 content::RendererPreferences* prefs) OVERRIDE; 62 virtual void OnProceed() OVERRIDE; 63 virtual void OnDontProceed() OVERRIDE; 64 65 // OAuth2LoginManager::Observer overrides. 66 virtual void OnSessionRestoreStateChanged( 67 Profile* user_profile, 68 OAuth2LoginManager::SessionRestoreState state) OVERRIDE; 69 70 void NotifyBlockingPageComplete(); 71 72 // Helper function to get OAuth2LoginManager out of |web_contents_|. 73 OAuth2LoginManager* GetOAuth2LoginManager(); 74 75 CompletionCallback callback_; 76 77 // True if the proceed is chosen. 78 bool proceeded_; 79 80 content::WebContents* web_contents_; 81 GURL url_; 82 content::InterstitialPage* interstitial_page_; // Owns us. 83 84 DISALLOW_COPY_AND_ASSIGN(MergeSessionLoadPage); 85 }; 86 87 } // namespace chromeos 88 89 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MERGE_SESSION_LOAD_PAGE_H_ 90