| Index: chrome/browser/ui/sync/one_click_signin_helper.cc
|
| ===================================================================
|
| --- chrome/browser/ui/sync/one_click_signin_helper.cc (revision 142948)
|
| +++ chrome/browser/ui/sync/one_click_signin_helper.cc (working copy)
|
| @@ -12,6 +12,7 @@
|
| #include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/infobars/infobar_tab_helper.h"
|
| #include "chrome/browser/prefs/pref_service.h"
|
| +#include "chrome/browser/prefs/scoped_user_pref_update.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/profiles/profile_info_cache.h"
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| @@ -71,6 +72,10 @@
|
| // show again in this profile.
|
| void DisableOneClickSignIn();
|
|
|
| + // Add a specific email to the list of emails rejected for one-click
|
| + // sign-in, for this profile.
|
| + void AddEmailToOneClickRejectedList(const std::string& email);
|
| +
|
| // Record the specified action in the histogram for one-click sign in.
|
| void RecordHistogramAction(int action);
|
|
|
| @@ -146,6 +151,8 @@
|
| } // namespace
|
|
|
| bool OneClickLoginInfoBarDelegate::Accept() {
|
| + // User has accepted one-click sign-in for this account. Never ask again for
|
| + // this profile.
|
| DisableOneClickSignIn();
|
| content::WebContents* web_contents = owner()->web_contents();
|
| RecordHistogramAction(one_click_signin::HISTOGRAM_ACCEPTED);
|
| @@ -157,7 +164,7 @@
|
| }
|
|
|
| bool OneClickLoginInfoBarDelegate::Cancel() {
|
| - DisableOneClickSignIn();
|
| + AddEmailToOneClickRejectedList(email_);
|
| RecordHistogramAction(one_click_signin::HISTOGRAM_REJECTED);
|
| button_pressed_ = true;
|
| return true;
|
| @@ -190,6 +197,16 @@
|
| pref_service->SetBoolean(prefs::kReverseAutologinEnabled, false);
|
| }
|
|
|
| +void OneClickLoginInfoBarDelegate::AddEmailToOneClickRejectedList(
|
| + const std::string& email) {
|
| + PrefService* pref_service =
|
| + TabContents::FromWebContents(owner()->web_contents())->
|
| + profile()->GetPrefs();
|
| + ListPrefUpdate updater(pref_service,
|
| + prefs::kReverseAutologinRejectedEmailList);
|
| + updater->AppendIfNotPresent(base::Value::CreateStringValue(email));
|
| +}
|
| +
|
| void OneClickLoginInfoBarDelegate::RecordHistogramAction(int action) {
|
| UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", action,
|
| one_click_signin::HISTOGRAM_MAX);
|
| @@ -197,6 +214,7 @@
|
|
|
| // static
|
| bool OneClickSigninHelper::CanOffer(content::WebContents* web_contents,
|
| + const std::string& email,
|
| bool check_connected) {
|
| if (!web_contents)
|
| return false;
|
| @@ -226,6 +244,19 @@
|
|
|
| if (!manager->GetAuthenticatedUsername().empty())
|
| return false;
|
| +
|
| + // If email was already rejected by this profile for one-click sign-in.
|
| + if (!email.empty()) {
|
| + const ListValue* rejected_emails = profile->GetPrefs()->GetList(
|
| + prefs::kReverseAutologinRejectedEmailList);
|
| + if (!rejected_emails->empty()) {
|
| + const Value* email_value = Value::CreateStringValue(email);
|
| + ListValue::const_iterator iter = rejected_emails->Find(
|
| + *email_value);
|
| + if (iter != rejected_emails->end())
|
| + return false;
|
| + }
|
| + }
|
| }
|
|
|
| return true;
|
| @@ -283,7 +314,7 @@
|
|
|
| content::WebContents* web_contents = tab_util::GetWebContentsByID(child_id,
|
| route_id);
|
| - if (!web_contents || !CanOffer(web_contents, true))
|
| + if (!web_contents || !CanOffer(web_contents, email, true))
|
| return;
|
|
|
| // If some profile, not just the current one, is already connected to this
|
|
|