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