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

Unified Diff: chrome/browser/signin/chrome_signin_client.cc

Issue 421583002: Show GAIA/cookie accounts on the signin-internals page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: include for CrOS Created 6 years, 4 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
« no previous file with comments | « chrome/browser/signin/chrome_signin_client.h ('k') | chrome/browser/ui/webui/signin_internals_ui.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/signin/chrome_signin_client.cc
diff --git a/chrome/browser/signin/chrome_signin_client.cc b/chrome/browser/signin/chrome_signin_client.cc
index c533ab3f3558e7d25497f4ab2ba86965efe434e1..dd909b6b71a2a5334153a934e0fa000dcb7cd061 100644
--- a/chrome/browser/signin/chrome_signin_client.cc
+++ b/chrome/browser/signin/chrome_signin_client.cc
@@ -40,7 +40,11 @@ const char kGoogleAccountsUrl[] = "https://accounts.google.com";
} // namespace
ChromeSigninClient::ChromeSigninClient(Profile* profile)
- : profile_(profile), signin_host_id_(ChildProcessHost::kInvalidUniqueID) {}
+ : profile_(profile), signin_host_id_(ChildProcessHost::kInvalidUniqueID) {
+ callbacks_.set_removal_callback(
+ base::Bind(&ChromeSigninClient::UnregisterForCookieChangedNotification,
+ base::Unretained(this)));
+}
ChromeSigninClient::~ChromeSigninClient() {
UnregisterForCookieChangedNotification();
@@ -172,18 +176,13 @@ std::string ChromeSigninClient::GetProductVersion() {
return chrome_version.CreateVersionString();
}
-void ChromeSigninClient::SetCookieChangedCallback(
+scoped_ptr<SigninClient::CookieChangedCallbackList::Subscription>
+ChromeSigninClient::AddCookieChangedCallback(
const CookieChangedCallback& callback) {
- if (callback_.Equals(callback))
- return;
-
- // There should be only one callback active at a time.
- DCHECK(callback.is_null() || callback_.is_null());
- callback_ = callback;
- if (!callback_.is_null())
- RegisterForCookieChangedNotification();
- else
- UnregisterForCookieChangedNotification();
+ scoped_ptr<SigninClient::CookieChangedCallbackList::Subscription>
+ subscription = callbacks_.Add(callback);
+ RegisterForCookieChangedNotification();
+ return subscription.Pass();
}
void ChromeSigninClient::GoogleSigninSucceeded(const std::string& username,
@@ -200,10 +199,10 @@ void ChromeSigninClient::Observe(int type,
const content::NotificationDetails& details) {
switch (type) {
case chrome::NOTIFICATION_COOKIE_CHANGED: {
- DCHECK(!callback_.is_null());
+ DCHECK(!callbacks_.empty());
const net::CanonicalCookie* cookie =
content::Details<ChromeCookieDetails>(details).ptr()->cookie;
- callback_.Run(cookie);
+ callbacks_.Notify(cookie);
break;
}
default:
@@ -213,13 +212,17 @@ void ChromeSigninClient::Observe(int type,
}
void ChromeSigninClient::RegisterForCookieChangedNotification() {
+ if (callbacks_.empty())
+ return;
content::Source<Profile> source(profile_);
- DCHECK(!registrar_.IsRegistered(
- this, chrome::NOTIFICATION_COOKIE_CHANGED, source));
+ if (!registrar_.IsRegistered(
+ this, chrome::NOTIFICATION_COOKIE_CHANGED, source))
registrar_.Add(this, chrome::NOTIFICATION_COOKIE_CHANGED, source);
}
void ChromeSigninClient::UnregisterForCookieChangedNotification() {
+ if (!callbacks_.empty())
+ return;
// Note that it's allowed to call this method multiple times without an
// intervening call to |RegisterForCookieChangedNotification()|.
content::Source<Profile> source(profile_);
« no previous file with comments | « chrome/browser/signin/chrome_signin_client.h ('k') | chrome/browser/ui/webui/signin_internals_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698