Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(386)

Side by Side Diff: chrome/browser/ui/sync/one_click_signin_helper.h

Issue 10928242: Switch OneClickSigninHelper to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/sync/one_click_signin_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_ 5 #ifndef CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_
6 #define CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_ 6 #define CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "chrome/browser/tab_contents/web_contents_user_data.h"
10 #include "content/public/browser/web_contents_observer.h" 11 #include "content/public/browser/web_contents_observer.h"
11 12
12 namespace content { 13 namespace content {
13 class WebContents; 14 class WebContents;
14 } 15 }
15 16
16 namespace net { 17 namespace net {
17 class URLRequest; 18 class URLRequest;
18 } 19 }
19 20
20 // Per-tab one-click signin helper. When a user signs in to a Google service 21 // Per-tab one-click signin helper. When a user signs in to a Google service
21 // and the profile is not yet connected to a Google account, will start the 22 // and the profile is not yet connected to a Google account, will start the
22 // process of helping the user connect his profile with one click. The process 23 // process of helping the user connect his profile with one click. The process
23 // begins with an infobar and is followed with a confirmation dialog explaining 24 // begins with an infobar and is followed with a confirmation dialog explaining
24 // more about what this means. 25 // more about what this means.
25 class OneClickSigninHelper : public content::WebContentsObserver { 26 class OneClickSigninHelper : public content::WebContentsObserver,
27 public WebContentsUserData<OneClickSigninHelper> {
26 public: 28 public:
27 explicit OneClickSigninHelper(content::WebContents* web_contents);
28 virtual ~OneClickSigninHelper(); 29 virtual ~OneClickSigninHelper();
29 30
30 // Returns true if the one-click signin feature can be offered at this time. 31 // Returns true if the one-click signin feature can be offered at this time.
31 // It can be offered if the contents is not in an incognito window. If 32 // It can be offered if the contents is not in an incognito window. If
32 // |check_connected| is true, then the profile is checked to see if it's 33 // |check_connected| is true, then the profile is checked to see if it's
33 // already connected to a google account or if the user has already rejected 34 // already connected to a google account or if the user has already rejected
34 // one-click sign-in with this email, in which cases a one click signin 35 // one-click sign-in with this email, in which cases a one click signin
35 // should not be offered. 36 // should not be offered.
36 static bool CanOffer(content::WebContents* web_contents, 37 static bool CanOffer(content::WebContents* web_contents,
37 const std::string& email, 38 const std::string& email,
38 bool check_connected); 39 bool check_connected);
39 40
40 // Initialize a finch experiment for the infobar. 41 // Initialize a finch experiment for the infobar.
41 static void InitializeFieldTrial(); 42 static void InitializeFieldTrial();
42 43
43 // Looks for the Google-Accounts-SignIn response header, and if found, 44 // Looks for the Google-Accounts-SignIn response header, and if found,
44 // tries to display an infobar in the tab contents identified by the 45 // tries to display an infobar in the tab contents identified by the
45 // child/route id. 46 // child/route id.
46 static void ShowInfoBarIfPossible(net::URLRequest* request, 47 static void ShowInfoBarIfPossible(net::URLRequest* request,
47 int child_id, 48 int child_id,
48 int route_id); 49 int route_id);
49 50
50 private: 51 private:
52 explicit OneClickSigninHelper(content::WebContents* web_contents);
53 static int kUserDataKey;
54 friend class WebContentsUserData<OneClickSigninHelper>;
55
51 // The portion of ShowInfoBarIfPossible() that needs to run on the UI thread. 56 // The portion of ShowInfoBarIfPossible() that needs to run on the UI thread.
52 static void ShowInfoBarUIThread(const std::string& session_index, 57 static void ShowInfoBarUIThread(const std::string& session_index,
53 const std::string& email, 58 const std::string& email,
54 int child_id, 59 int child_id,
55 int route_id); 60 int route_id);
56 61
57 // content::WebContentsObserver overrides. 62 // content::WebContentsObserver overrides.
58 virtual void DidNavigateAnyFrame( 63 virtual void DidNavigateAnyFrame(
59 const content::LoadCommittedDetails& details, 64 const content::LoadCommittedDetails& details,
60 const content::FrameNavigateParams& params) OVERRIDE; 65 const content::FrameNavigateParams& params) OVERRIDE;
61 virtual void DidStopLoading( 66 virtual void DidStopLoading(
62 content::RenderViewHost* render_view_host) OVERRIDE; 67 content::RenderViewHost* render_view_host) OVERRIDE;
63 68
64 // Save the email address that we can display the info bar correctly. 69 // Save the email address that we can display the info bar correctly.
65 void SaveSessionIndexAndEmail(const std::string& session_index, 70 void SaveSessionIndexAndEmail(const std::string& session_index,
66 const std::string& email); 71 const std::string& email);
67 72
68 // Remember the user's password for later use. 73 // Remember the user's password for later use.
69 void SavePassword(const std::string& password); 74 void SavePassword(const std::string& password);
70 75
71 // Information about the account that has just logged in. 76 // Information about the account that has just logged in.
72 std::string session_index_; 77 std::string session_index_;
73 std::string email_; 78 std::string email_;
74 std::string password_; 79 std::string password_;
75 80
76 DISALLOW_COPY_AND_ASSIGN(OneClickSigninHelper); 81 DISALLOW_COPY_AND_ASSIGN(OneClickSigninHelper);
77 }; 82 };
78 83
79 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_ 84 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/sync/one_click_signin_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698