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