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