OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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_SIGNIN_ONE_CLICK_SIGNIN_H_ |
| 6 #define CHROME_BROWSER_SIGNIN_ONE_CLICK_SIGNIN_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <vector> |
| 10 |
| 11 #include "content/public/browser/web_contents_observer.h" |
| 12 #include "webkit/forms/password_form.h" |
| 13 #include "webkit/forms/password_form_dom_manager.h" |
| 14 |
| 15 class PrefService; |
| 16 |
| 17 namespace content { |
| 18 class WebContents; |
| 19 } |
| 20 |
| 21 namespace net { |
| 22 class URLRequest; |
| 23 } |
| 24 |
| 25 // Per-tab one-click signin manager. When a user signs in to a Google service |
| 26 // and the profile is not yet connected to a Google account, will start the |
| 27 // process of helping the user connect his profile with one click. The process |
| 28 // begins with an infobar and is followed with a confirmation dialog explaining |
| 29 // more about what this means. |
| 30 class OneClickSigninManager : public content::WebContentsObserver { |
| 31 public: |
| 32 // Returns true if the one-click signin fearture can be offered at this time. |
| 33 // It can be offered if the contents is not in an incognito window. |
| 34 static bool OneClickSigninManager::CanOffer( |
| 35 content::WebContents* web_contents); |
| 36 |
| 37 // Looks for the X-Google-Accounts-SignIn response header, and if found, |
| 38 // tries to display an infobar in the tab contents identified by the |
| 39 // child/route id. |
| 40 static void ShowInfoBarIfPossible(net::URLRequest* request, |
| 41 int child_id, |
| 42 int route_id); |
| 43 |
| 44 explicit OneClickSigninManager(content::WebContents* web_contents); |
| 45 ~OneClickSigninManager(); |
| 46 |
| 47 private: |
| 48 // The portion of ShowInfoBarIfPossible() that needs to run on the UI thread. |
| 49 static void ShowInfoBarUIThread(const std::string& account, |
| 50 int child_id, |
| 51 int route_id); |
| 52 |
| 53 // content::WebContentsObserver overrides. |
| 54 virtual void DidNavigateAnyFrame( |
| 55 const content::LoadCommittedDetails& details, |
| 56 const content::FrameNavigateParams& params) OVERRIDE; |
| 57 virtual void DidStopLoading() OVERRIDE; |
| 58 |
| 59 // Save the email address that we can display the info bar correctly. |
| 60 void SaveEmail(const std::string& email); |
| 61 |
| 62 // Remember the user's password for later use. |
| 63 void SavePassword(const webkit::forms::PasswordForm& form); |
| 64 |
| 65 // Email address and password of the account that has just logged in. |
| 66 std::string email_; |
| 67 std::string password_; |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(OneClickSigninManager); |
| 70 }; |
| 71 |
| 72 #endif // CHROME_BROWSER_SIGNIN_ONE_CLICK_SIGNIN_H_ |
OLD | NEW |