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

Unified Diff: chrome/browser/ui/sync/one_click_signin_helper.cc

Issue 10555005: Address bug where the one-click sign-in bar would never show again once (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Merge Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/sync/one_click_signin_helper.cc
===================================================================
--- chrome/browser/ui/sync/one_click_signin_helper.cc (revision 148749)
+++ chrome/browser/ui/sync/one_click_signin_helper.cc (working copy)
@@ -12,13 +12,13 @@
#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"
#include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
-#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/browser/ui/browser_finder.h"
@@ -72,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 +150,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 +163,7 @@
}
bool OneClickLoginInfoBarDelegate::Cancel() {
- DisableOneClickSignIn();
+ AddEmailToOneClickRejectedList(email_);
RecordHistogramAction(one_click_signin::HISTOGRAM_REJECTED);
button_pressed_ = true;
return true;
@@ -190,6 +196,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 +213,7 @@
// static
bool OneClickSigninHelper::CanOffer(content::WebContents* web_contents,
+ const std::string& email,
bool check_connected) {
if (!web_contents)
return false;
@@ -227,20 +244,37 @@
if (!manager->GetAuthenticatedUsername().empty())
return false;
- // If we're about to show a one-click infobar but the user has started
- // a concurrent signin flow (perhaps via the promo), we may not have yet
- // established an authenticated username but we still shouldn't move
- // forward with two simultaneous signin processes. This is a bit
- // contentious as the one-click flow is a much smoother flow from the user
- // perspective, but it's much more difficult to hijack the other flow from
- // here as it is to bail.
- ProfileSyncService* service =
- ProfileSyncServiceFactory::GetForProfile(profile);
- if (!service)
+ // Make sure this username is not prohibited by policy.
+ if (!manager->IsAllowedUsername(email))
return false;
- if (service->FirstSetupInProgress())
- return false;
+ // If some profile, not just the current one, is already connected to this
+ // account, don't show the infobar.
+ if (g_browser_process) {
+ ProfileManager* manager = g_browser_process->profile_manager();
+ if (manager) {
+ string16 email16 = UTF8ToUTF16(email);
+ ProfileInfoCache& cache = manager->GetProfileInfoCache();
+
+ for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) {
+ if (email16 == cache.GetUserNameOfProfileAtIndex(i))
+ 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;
@@ -298,29 +332,10 @@
content::WebContents* web_contents = tab_util::GetWebContentsByID(child_id,
route_id);
- if (!web_contents || !CanOffer(web_contents, true))
- return;
- // If some profile, not just the current one, is already connected to this
- // account, don't show the infobar.
- if (g_browser_process) {
- ProfileManager* manager = g_browser_process->profile_manager();
- if (manager) {
- string16 email16 = UTF8ToUTF16(email);
- ProfileInfoCache& cache = manager->GetProfileInfoCache();
-
- for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) {
- if (email16 == cache.GetUserNameOfProfileAtIndex(i))
- return;
- }
- }
- }
-
- // Make sure this username is not prohibited by policy.
- Profile* profile =
- Profile::FromBrowserContext(web_contents->GetBrowserContext());
- SigninManager* signin = SigninManagerFactory::GetForProfile(profile);
- if (!signin->IsAllowedUsername(email))
+ // TODO(mathp): The appearance of this infobar should be tested using a
+ // browser_test.
+ if (!web_contents || !CanOffer(web_contents, email, true))
return;
TabContents* tab_contents = TabContents::FromWebContents(web_contents);
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.h ('k') | chrome/browser/ui/sync/one_click_signin_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698