| OLD | NEW |
| 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 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 5 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/metrics/field_trial.h" |
| 10 #include "base/string_split.h" | 11 #include "base/string_split.h" |
| 11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" | 13 #include "chrome/browser/api/infobars/one_click_signin_infobar_delegate.h" |
| 13 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/defaults.h" |
| 14 #include "chrome/browser/infobars/infobar_tab_helper.h" | 16 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 15 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
| 16 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 18 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/profiles/profile_info_cache.h" | 20 #include "chrome/browser/profiles/profile_info_cache.h" |
| 19 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
| 20 #include "chrome/browser/signin/signin_manager.h" | 22 #include "chrome/browser/signin/signin_manager.h" |
| 21 #include "chrome/browser/signin/signin_manager_factory.h" | 23 #include "chrome/browser/signin/signin_manager_factory.h" |
| 22 #include "chrome/browser/sync/profile_sync_service.h" | 24 #include "chrome/browser/sync/profile_sync_service.h" |
| 23 #include "chrome/browser/tab_contents/tab_util.h" | 25 #include "chrome/browser/tab_contents/tab_util.h" |
| 24 #include "chrome/browser/ui/browser_finder.h" | 26 #include "chrome/browser/ui/browser_finder.h" |
| 25 #include "chrome/browser/ui/browser_window.h" | 27 #include "chrome/browser/ui/browser_window.h" |
| 26 #include "chrome/browser/ui/sync/one_click_signin_histogram.h" | 28 #include "chrome/browser/ui/sync/one_click_signin_histogram.h" |
| 27 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" | 29 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" |
| 28 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 30 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 31 #include "chrome/common/chrome_version_info.h" |
| 29 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| 30 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
| 31 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
| 32 #include "content/public/browser/page_navigator.h" | 35 #include "content/public/browser/page_navigator.h" |
| 33 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
| 34 #include "content/public/browser/web_contents_view.h" | 37 #include "content/public/browser/web_contents_view.h" |
| 35 #include "content/public/common/frame_navigate_params.h" | 38 #include "content/public/common/frame_navigate_params.h" |
| 36 #include "content/public/common/page_transition_types.h" | 39 #include "content/public/common/page_transition_types.h" |
| 37 #include "googleurl/src/gurl.h" | 40 #include "googleurl/src/gurl.h" |
| 38 #include "grit/chromium_strings.h" | 41 #include "grit/chromium_strings.h" |
| 39 #include "grit/generated_resources.h" | 42 #include "grit/generated_resources.h" |
| 40 #include "grit/theme_resources.h" | 43 #include "grit/theme_resources.h" |
| 41 #include "net/cookies/cookie_monster.h" | 44 #include "net/cookies/cookie_monster.h" |
| 42 #include "net/url_request/url_request.h" | 45 #include "net/url_request/url_request.h" |
| 43 #include "ui/base/l10n/l10n_util.h" | 46 #include "ui/base/l10n/l10n_util.h" |
| 44 #include "ui/base/resource/resource_bundle.h" | 47 #include "ui/base/resource/resource_bundle.h" |
| 45 #include "webkit/forms/password_form.h" | 48 #include "webkit/forms/password_form.h" |
| 46 #include "webkit/forms/password_form_dom_manager.h" | 49 #include "webkit/forms/password_form_dom_manager.h" |
| 47 | 50 |
| 51 namespace { |
| 52 |
| 53 // Set to true if this chrome instance is in the blue-button-on-white-bar |
| 54 // experimental group. |
| 55 bool use_blue_on_white = false; |
| 56 |
| 57 // Start syncing with the given user information. |
| 58 void StartSync(content::WebContents* web_contents, |
| 59 const std::string& session_index, |
| 60 const std::string& email, |
| 61 const std::string& password, |
| 62 OneClickSigninSyncStarter::StartSyncMode start_mode) { |
| 63 // The starter deletes itself once its done. |
| 64 Browser* browser = browser::FindBrowserWithWebContents(web_contents); |
| 65 new OneClickSigninSyncStarter(browser, session_index, email, password, |
| 66 start_mode); |
| 67 } |
| 68 |
| 69 } // namespace |
| 70 |
| 48 // The infobar asking the user if they want to use one-click sign in. | 71 // The infobar asking the user if they want to use one-click sign in. |
| 49 class OneClickLoginInfoBarDelegate : public ConfirmInfoBarDelegate { | 72 class OneClickInfoBarDelegateImpl : public OneClickSigninInfoBarDelegate { |
| 50 public: | 73 public: |
| 51 OneClickLoginInfoBarDelegate(InfoBarTabHelper* owner, | 74 OneClickInfoBarDelegateImpl(InfoBarTabHelper* owner, |
| 52 const std::string& session_index, | 75 const std::string& session_index, |
| 53 const std::string& email, | 76 const std::string& email, |
| 54 const std::string& password); | 77 const std::string& password); |
| 55 virtual ~OneClickLoginInfoBarDelegate(); | 78 virtual ~OneClickInfoBarDelegateImpl(); |
| 56 | 79 |
| 57 private: | 80 private: |
| 58 // ConfirmInfoBarDelegate overrides. | 81 // InfoBarDelegate overrides. |
| 82 virtual InfoBarAutomationType GetInfoBarAutomationType() const OVERRIDE; |
| 59 virtual void InfoBarDismissed() OVERRIDE; | 83 virtual void InfoBarDismissed() OVERRIDE; |
| 60 virtual gfx::Image* GetIcon() const OVERRIDE; | 84 virtual gfx::Image* GetIcon() const OVERRIDE; |
| 61 virtual Type GetInfoBarType() const OVERRIDE; | 85 virtual Type GetInfoBarType() const OVERRIDE; |
| 62 virtual string16 GetMessageText() const OVERRIDE; | 86 virtual string16 GetMessageText() const OVERRIDE; |
| 87 |
| 88 // ConfirmInfoBarDelegate overrides. |
| 63 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 89 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 64 virtual bool Accept() OVERRIDE; | 90 virtual bool Accept() OVERRIDE; |
| 65 virtual bool Cancel() OVERRIDE; | 91 virtual bool Cancel() OVERRIDE; |
| 66 virtual string16 GetLinkText() const OVERRIDE; | 92 virtual string16 GetLinkText() const OVERRIDE; |
| 67 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; | 93 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; |
| 68 | 94 |
| 69 virtual InfoBarAutomationType GetInfoBarAutomationType() const OVERRIDE; | 95 // OneClickSigninInfoBarDelegate overrides. |
| 96 virtual void GetAlternateColors(AlternateColors* alt_colors) OVERRIDE; |
| 70 | 97 |
| 71 // Set the profile preference to turn off one-click sign in so that it won't | 98 // Set the profile preference to turn off one-click sign in so that it won't |
| 72 // show again in this profile. | 99 // show again in this profile. |
| 73 void DisableOneClickSignIn(); | 100 void DisableOneClickSignIn(); |
| 74 | 101 |
| 75 // Add a specific email to the list of emails rejected for one-click | 102 // Add a specific email to the list of emails rejected for one-click |
| 76 // sign-in, for this profile. | 103 // sign-in, for this profile. |
| 77 void AddEmailToOneClickRejectedList(const std::string& email); | 104 void AddEmailToOneClickRejectedList(const std::string& email); |
| 78 | 105 |
| 79 // Record the specified action in the histogram for one-click sign in. | 106 // Record the specified action in the histogram for one-click sign in. |
| 80 void RecordHistogramAction(int action); | 107 void RecordHistogramAction(int action); |
| 81 | 108 |
| 82 // Information about the account that has just logged in. | 109 // Information about the account that has just logged in. |
| 83 std::string session_index_; | 110 std::string session_index_; |
| 84 std::string email_; | 111 std::string email_; |
| 85 std::string password_; | 112 std::string password_; |
| 86 | 113 |
| 87 // Whether any UI controls in the infobar were pressed or not. | 114 // Whether any UI controls in the infobar were pressed or not. |
| 88 bool button_pressed_; | 115 bool button_pressed_; |
| 89 | 116 |
| 90 DISALLOW_COPY_AND_ASSIGN(OneClickLoginInfoBarDelegate); | 117 DISALLOW_COPY_AND_ASSIGN(OneClickInfoBarDelegateImpl); |
| 91 }; | 118 }; |
| 92 | 119 |
| 93 OneClickLoginInfoBarDelegate::OneClickLoginInfoBarDelegate( | 120 OneClickInfoBarDelegateImpl::OneClickInfoBarDelegateImpl( |
| 94 InfoBarTabHelper* owner, | 121 InfoBarTabHelper* owner, |
| 95 const std::string& session_index, | 122 const std::string& session_index, |
| 96 const std::string& email, | 123 const std::string& email, |
| 97 const std::string& password) | 124 const std::string& password) |
| 98 : ConfirmInfoBarDelegate(owner), | 125 : OneClickSigninInfoBarDelegate(owner), |
| 99 session_index_(session_index), | 126 session_index_(session_index), |
| 100 email_(email), | 127 email_(email), |
| 101 password_(password), | 128 password_(password), |
| 102 button_pressed_(false) { | 129 button_pressed_(false) { |
| 103 RecordHistogramAction(one_click_signin::HISTOGRAM_SHOWN); | 130 RecordHistogramAction(one_click_signin::HISTOGRAM_SHOWN); |
| 104 } | 131 } |
| 105 | 132 |
| 106 OneClickLoginInfoBarDelegate::~OneClickLoginInfoBarDelegate() { | 133 OneClickInfoBarDelegateImpl::~OneClickInfoBarDelegateImpl() { |
| 107 if (!button_pressed_) | 134 if (!button_pressed_) |
| 108 RecordHistogramAction(one_click_signin::HISTOGRAM_IGNORED); | 135 RecordHistogramAction(one_click_signin::HISTOGRAM_IGNORED); |
| 109 } | 136 } |
| 110 | 137 |
| 111 void OneClickLoginInfoBarDelegate::InfoBarDismissed() { | 138 InfoBarDelegate::InfoBarAutomationType |
| 139 OneClickInfoBarDelegateImpl::GetInfoBarAutomationType() const { |
| 140 return ONE_CLICK_LOGIN_INFOBAR; |
| 141 } |
| 142 |
| 143 void OneClickInfoBarDelegateImpl::InfoBarDismissed() { |
| 112 RecordHistogramAction(one_click_signin::HISTOGRAM_DISMISSED); | 144 RecordHistogramAction(one_click_signin::HISTOGRAM_DISMISSED); |
| 113 button_pressed_ = true; | 145 button_pressed_ = true; |
| 114 } | 146 } |
| 115 | 147 |
| 116 gfx::Image* OneClickLoginInfoBarDelegate::GetIcon() const { | 148 gfx::Image* OneClickInfoBarDelegateImpl::GetIcon() const { |
| 117 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 149 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
| 118 IDR_INFOBAR_SYNC); | 150 IDR_INFOBAR_SYNC); |
| 119 } | 151 } |
| 120 | 152 |
| 121 InfoBarDelegate::Type OneClickLoginInfoBarDelegate::GetInfoBarType() const { | 153 InfoBarDelegate::Type OneClickInfoBarDelegateImpl::GetInfoBarType() const { |
| 122 return PAGE_ACTION_TYPE; | 154 return PAGE_ACTION_TYPE; |
| 123 } | 155 } |
| 124 | 156 |
| 125 string16 OneClickLoginInfoBarDelegate::GetMessageText() const { | 157 string16 OneClickInfoBarDelegateImpl::GetMessageText() const { |
| 126 return l10n_util::GetStringUTF16(IDS_ONE_CLICK_SIGNIN_INFOBAR_MESSAGE); | 158 return l10n_util::GetStringUTF16(IDS_ONE_CLICK_SIGNIN_INFOBAR_MESSAGE); |
| 127 } | 159 } |
| 128 | 160 |
| 129 string16 OneClickLoginInfoBarDelegate::GetButtonLabel( | 161 string16 OneClickInfoBarDelegateImpl::GetButtonLabel( |
| 130 InfoBarButton button) const { | 162 InfoBarButton button) const { |
| 131 return l10n_util::GetStringUTF16( | 163 return l10n_util::GetStringUTF16( |
| 132 (button == BUTTON_OK) ? IDS_ONE_CLICK_SIGNIN_INFOBAR_OK_BUTTON | 164 (button == BUTTON_OK) ? IDS_ONE_CLICK_SIGNIN_INFOBAR_OK_BUTTON |
| 133 : IDS_ONE_CLICK_SIGNIN_INFOBAR_CANCEL_BUTTON); | 165 : IDS_ONE_CLICK_SIGNIN_INFOBAR_CANCEL_BUTTON); |
| 134 } | 166 } |
| 135 | 167 |
| 136 namespace { | 168 bool OneClickInfoBarDelegateImpl::Accept() { |
| 137 | |
| 138 // Start syncing with the given user information. | |
| 139 void StartSync(content::WebContents* web_contents, | |
| 140 const std::string& session_index, | |
| 141 const std::string& email, | |
| 142 const std::string& password, | |
| 143 OneClickSigninSyncStarter::StartSyncMode start_mode) { | |
| 144 // The starter deletes itself once its done. | |
| 145 Browser* browser = browser::FindBrowserWithWebContents(web_contents); | |
| 146 new OneClickSigninSyncStarter(browser, session_index, email, password, | |
| 147 start_mode); | |
| 148 } | |
| 149 | |
| 150 } // namespace | |
| 151 | |
| 152 bool OneClickLoginInfoBarDelegate::Accept() { | |
| 153 // User has accepted one-click sign-in for this account. Never ask again for | 169 // User has accepted one-click sign-in for this account. Never ask again for |
| 154 // this profile. | 170 // this profile. |
| 155 DisableOneClickSignIn(); | 171 DisableOneClickSignIn(); |
| 156 content::WebContents* web_contents = owner()->GetWebContents(); | 172 content::WebContents* web_contents = owner()->GetWebContents(); |
| 157 RecordHistogramAction(one_click_signin::HISTOGRAM_ACCEPTED); | 173 RecordHistogramAction(one_click_signin::HISTOGRAM_ACCEPTED); |
| 158 browser::FindBrowserWithWebContents(web_contents)->window()-> | 174 browser::FindBrowserWithWebContents(web_contents)->window()-> |
| 159 ShowOneClickSigninBubble(base::Bind(&StartSync, web_contents, | 175 ShowOneClickSigninBubble(base::Bind(&StartSync, web_contents, |
| 160 session_index_, email_, password_)); | 176 session_index_, email_, password_)); |
| 161 button_pressed_ = true; | 177 button_pressed_ = true; |
| 162 return true; | 178 return true; |
| 163 } | 179 } |
| 164 | 180 |
| 165 bool OneClickLoginInfoBarDelegate::Cancel() { | 181 bool OneClickInfoBarDelegateImpl::Cancel() { |
| 166 AddEmailToOneClickRejectedList(email_); | 182 AddEmailToOneClickRejectedList(email_); |
| 167 RecordHistogramAction(one_click_signin::HISTOGRAM_REJECTED); | 183 RecordHistogramAction(one_click_signin::HISTOGRAM_REJECTED); |
| 168 button_pressed_ = true; | 184 button_pressed_ = true; |
| 169 return true; | 185 return true; |
| 170 } | 186 } |
| 171 | 187 |
| 172 string16 OneClickLoginInfoBarDelegate::GetLinkText() const { | 188 string16 OneClickInfoBarDelegateImpl::GetLinkText() const { |
| 173 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 189 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
| 174 } | 190 } |
| 175 | 191 |
| 176 bool OneClickLoginInfoBarDelegate::LinkClicked( | 192 bool OneClickInfoBarDelegateImpl::LinkClicked( |
| 177 WindowOpenDisposition disposition) { | 193 WindowOpenDisposition disposition) { |
| 178 RecordHistogramAction(one_click_signin::HISTOGRAM_LEARN_MORE); | 194 RecordHistogramAction(one_click_signin::HISTOGRAM_LEARN_MORE); |
| 179 content::OpenURLParams params( | 195 content::OpenURLParams params( |
| 180 GURL(chrome::kChromeSyncLearnMoreURL), content::Referrer(), disposition, | 196 GURL(chrome::kChromeSyncLearnMoreURL), content::Referrer(), disposition, |
| 181 content::PAGE_TRANSITION_LINK, false); | 197 content::PAGE_TRANSITION_LINK, false); |
| 182 owner()->GetWebContents()->OpenURL(params); | 198 owner()->GetWebContents()->OpenURL(params); |
| 183 return false; | 199 return false; |
| 184 } | 200 } |
| 185 | 201 |
| 202 void OneClickInfoBarDelegateImpl::GetAlternateColors( |
| 203 AlternateColors* alt_colors) { |
| 204 if (use_blue_on_white) { |
| 205 alt_colors->infobar_bottom_color = SK_ColorWHITE; |
| 206 alt_colors->infobar_top_color = SK_ColorWHITE; |
| 207 alt_colors->button_text_color = SK_ColorWHITE; |
| 208 alt_colors->button_background_color = SkColorSetRGB(71, 135, 237); |
| 209 alt_colors->button_border_color = SkColorSetRGB(48, 121, 237); |
| 210 return; |
| 211 } |
| 186 | 212 |
| 187 InfoBarDelegate::InfoBarAutomationType | 213 return OneClickSigninInfoBarDelegate::GetAlternateColors(alt_colors); |
| 188 OneClickLoginInfoBarDelegate::GetInfoBarAutomationType() const { | |
| 189 return ONE_CLICK_LOGIN_INFOBAR; | |
| 190 } | 214 } |
| 191 | 215 |
| 192 void OneClickLoginInfoBarDelegate::DisableOneClickSignIn() { | 216 void OneClickInfoBarDelegateImpl::DisableOneClickSignIn() { |
| 193 PrefService* pref_service = | 217 PrefService* pref_service = |
| 194 TabContents::FromWebContents(owner()->GetWebContents())-> | 218 TabContents::FromWebContents(owner()->GetWebContents())-> |
| 195 profile()->GetPrefs(); | 219 profile()->GetPrefs(); |
| 196 pref_service->SetBoolean(prefs::kReverseAutologinEnabled, false); | 220 pref_service->SetBoolean(prefs::kReverseAutologinEnabled, false); |
| 197 } | 221 } |
| 198 | 222 |
| 199 void OneClickLoginInfoBarDelegate::AddEmailToOneClickRejectedList( | 223 void OneClickInfoBarDelegateImpl::AddEmailToOneClickRejectedList( |
| 200 const std::string& email) { | 224 const std::string& email) { |
| 201 PrefService* pref_service = | 225 PrefService* pref_service = |
| 202 TabContents::FromWebContents(owner()->GetWebContents())-> | 226 TabContents::FromWebContents(owner()->GetWebContents())-> |
| 203 profile()->GetPrefs(); | 227 profile()->GetPrefs(); |
| 204 ListPrefUpdate updater(pref_service, | 228 ListPrefUpdate updater(pref_service, |
| 205 prefs::kReverseAutologinRejectedEmailList); | 229 prefs::kReverseAutologinRejectedEmailList); |
| 206 updater->AppendIfNotPresent(base::Value::CreateStringValue(email)); | 230 updater->AppendIfNotPresent(base::Value::CreateStringValue(email)); |
| 207 } | 231 } |
| 208 | 232 |
| 209 void OneClickLoginInfoBarDelegate::RecordHistogramAction(int action) { | 233 void OneClickInfoBarDelegateImpl::RecordHistogramAction(int action) { |
| 210 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", action, | 234 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", action, |
| 211 one_click_signin::HISTOGRAM_MAX); | 235 one_click_signin::HISTOGRAM_MAX); |
| 212 } | 236 } |
| 213 | 237 |
| 214 // static | 238 // static |
| 215 bool OneClickSigninHelper::CanOffer(content::WebContents* web_contents, | 239 bool OneClickSigninHelper::CanOffer(content::WebContents* web_contents, |
| 216 const std::string& email, | 240 const std::string& email, |
| 217 bool check_connected) { | 241 bool check_connected) { |
| 218 if (!web_contents) | 242 if (!web_contents) |
| 219 return false; | 243 return false; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 if (iter != rejected_emails->end()) | 298 if (iter != rejected_emails->end()) |
| 275 return false; | 299 return false; |
| 276 } | 300 } |
| 277 } | 301 } |
| 278 } | 302 } |
| 279 | 303 |
| 280 return true; | 304 return true; |
| 281 } | 305 } |
| 282 | 306 |
| 283 // static | 307 // static |
| 308 void OneClickSigninHelper::InitializeFieldTrial() { |
| 309 scoped_refptr<base::FieldTrial> trial( |
| 310 base::FieldTrialList::FactoryGetFieldTrial("OneClickSignIn", 100, |
| 311 "Standard", 2013, 9, 1, NULL)); |
| 312 |
| 313 // For dev and beta, we'll give half the people the new experience. For |
| 314 // stable, only 1%. These numbers are overridable on the server. |
| 315 const bool kIsStableChannel = |
| 316 chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_STABLE; |
| 317 const int kBlueOnWhiteGroup = trial->AppendGroup("BlueOnWhite", |
| 318 kIsStableChannel ? 1 : 50); |
| 319 use_blue_on_white = trial->group() == kBlueOnWhiteGroup; |
| 320 } |
| 321 |
| 322 // static |
| 284 void OneClickSigninHelper::ShowInfoBarIfPossible(net::URLRequest* request, | 323 void OneClickSigninHelper::ShowInfoBarIfPossible(net::URLRequest* request, |
| 285 int child_id, | 324 int child_id, |
| 286 int route_id) { | 325 int route_id) { |
| 287 // See if the response contains the Google-Accounts-SignIn header. | 326 // See if the response contains the Google-Accounts-SignIn header. |
| 288 std::string value; | 327 std::string value; |
| 289 request->GetResponseHeaderByName("Google-Accounts-SignIn", &value); | 328 request->GetResponseHeaderByName("Google-Accounts-SignIn", &value); |
| 290 if (value.empty()) | 329 if (value.empty()) |
| 291 return; | 330 return; |
| 292 | 331 |
| 293 std::vector<std::pair<std::string, std::string> > pairs; | 332 std::vector<std::pair<std::string, std::string> > pairs; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 } | 397 } |
| 359 | 398 |
| 360 void OneClickSigninHelper::DidStopLoading( | 399 void OneClickSigninHelper::DidStopLoading( |
| 361 content::RenderViewHost* render_view_host) { | 400 content::RenderViewHost* render_view_host) { |
| 362 if (email_.empty() || password_.empty()) | 401 if (email_.empty() || password_.empty()) |
| 363 return; | 402 return; |
| 364 | 403 |
| 365 TabContents* tab_contents = TabContents::FromWebContents(web_contents()); | 404 TabContents* tab_contents = TabContents::FromWebContents(web_contents()); |
| 366 | 405 |
| 367 tab_contents->infobar_tab_helper()->AddInfoBar( | 406 tab_contents->infobar_tab_helper()->AddInfoBar( |
| 368 new OneClickLoginInfoBarDelegate(tab_contents->infobar_tab_helper(), | 407 new OneClickInfoBarDelegateImpl(tab_contents->infobar_tab_helper(), |
| 369 session_index_, email_, password_)); | 408 session_index_, email_, password_)); |
| 370 | 409 |
| 371 email_.clear(); | 410 email_.clear(); |
| 372 password_.clear(); | 411 password_.clear(); |
| 373 } | 412 } |
| 374 | 413 |
| 375 void OneClickSigninHelper::SaveSessionIndexAndEmail( | 414 void OneClickSigninHelper::SaveSessionIndexAndEmail( |
| 376 const std::string& session_index, | 415 const std::string& session_index, |
| 377 const std::string& email) { | 416 const std::string& email) { |
| 378 session_index_ = session_index; | 417 session_index_ = session_index; |
| 379 email_ = email; | 418 email_ = email; |
| 380 } | 419 } |
| 381 | 420 |
| 382 void OneClickSigninHelper::SavePassword(const std::string& password) { | 421 void OneClickSigninHelper::SavePassword(const std::string& password) { |
| 383 // TODO(rogerta): in the case of a 2-factor or captcha or some other type of | 422 // TODO(rogerta): in the case of a 2-factor or captcha or some other type of |
| 384 // challenge, its possible for the user to never complete the signin. | 423 // challenge, its possible for the user to never complete the signin. |
| 385 // Should have a way to detect this and clear the password member. | 424 // Should have a way to detect this and clear the password member. |
| 386 password_ = password; | 425 password_ = password; |
| 387 } | 426 } |
| OLD | NEW |