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