| 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/notification_observer.h" |
| 12 #include "content/public/browser/notification_registrar.h" |
| 13 #include "content/public/browser/web_contents_observer.h" |
| 14 #include "webkit/forms/password_form.h" |
| 15 #include "webkit/forms/password_form_dom_manager.h" |
| 16 |
| 17 class PrefService; |
| 18 class Profile; |
| 19 |
| 20 namespace content { |
| 21 class WebContents; |
| 22 } |
| 23 |
| 24 namespace net { |
| 25 class URLRequest; |
| 26 } |
| 27 |
| 28 // Per-tab one-click signin manager. When a user signs in to a Google service |
| 29 // and the profile is not yet connected to a Google account, will start the |
| 30 // process of helping the user connect his profile with one click. The process |
| 31 // begins with an infobar and is followed with a confirmation dialog explaining |
| 32 // more about what this means. |
| 33 class OneClickSigninManager : public content::WebContentsObserver { |
| 34 public: |
| 35 // Returns true if the one-click signin fearture can be offered at this time. |
| 36 // It can be offered if the contents is not in an incognito window. |
| 37 static bool OneClickSigninManager::CanOffer( |
| 38 content::WebContents* web_contents); |
| 39 |
| 40 // Looks for the X-Google-Accounts-SignIn response header, and if found, |
| 41 // tries to display an infobar in the tab contents identified by the |
| 42 // child/route id. |
| 43 static void ShowInfoBarIfPossible(net::URLRequest* request, |
| 44 int child_id, |
| 45 int route_id); |
| 46 |
| 47 explicit OneClickSigninManager(content::WebContents* web_contents); |
| 48 ~OneClickSigninManager(); |
| 49 |
| 50 private: |
| 51 // The portion of ShowInfoBarIfPossible() that needs to run on the UI thread. |
| 52 static void ShowInfoBarUIThread(const std::string& account, |
| 53 int child_id, |
| 54 int route_id); |
| 55 |
| 56 // content::WebContentsObserver overrides. |
| 57 virtual void DidNavigateAnyFrame( |
| 58 const content::LoadCommittedDetails& details, |
| 59 const content::FrameNavigateParams& params) OVERRIDE; |
| 60 virtual void DidStopLoading() OVERRIDE; |
| 61 |
| 62 // Save the email address that we can display the info bar correctly. |
| 63 void SaveEmail(const std::string& email); |
| 64 |
| 65 // Remember the user's password for later use. |
| 66 void SavePassword(const webkit::forms::PasswordForm& form); |
| 67 |
| 68 // Email address and password of the account that has just logged in. |
| 69 std::string email_; |
| 70 std::string password_; |
| 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(OneClickSigninManager); |
| 73 }; |
| 74 |
| 75 // Waits for successful singin notification from the signin manager and then |
| 76 // starts the sync machine. Instances of this class delete themselves once |
| 77 // the job is done. |
| 78 class OneClickSigninSyncStarter : public content::NotificationObserver { |
| 79 public: |
| 80 OneClickSigninSyncStarter(const std::string& email, |
| 81 const std::string& password, |
| 82 Profile* profile, |
| 83 bool use_default_settings); |
| 84 |
| 85 private: |
| 86 ~OneClickSigninSyncStarter(); |
| 87 |
| 88 // content::NotificationObserver override. |
| 89 virtual void Observe(int type, |
| 90 const content::NotificationSource& source, |
| 91 const content::NotificationDetails& details) OVERRIDE; |
| 92 |
| 93 content::NotificationRegistrar registrar_; |
| 94 Profile* profile_; |
| 95 bool use_default_settings_; |
| 96 |
| 97 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncStarter); |
| 98 }; |
| 99 |
| 100 |
| 101 #endif // CHROME_BROWSER_SIGNIN_ONE_CLICK_SIGNIN_H_ |
| OLD | NEW |