Chromium Code Reviews| 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 6a9de6c4e9b71097f53771e24e1d20602bd7a6d3..7d61ee1392644ebc4219a757186968f7a05c6acc 100644 |
| --- a/chrome/browser/signin/chrome_signin_client.cc |
| +++ b/chrome/browser/signin/chrome_signin_client.cc |
| @@ -14,6 +14,7 @@ |
| #include "chrome/browser/profiles/profile_info_cache.h" |
| #include "chrome/browser/profiles/profile_manager.h" |
| #include "chrome/browser/signin/local_auth.h" |
| +#include "chrome/browser/signin/signin_cookie_changed_subscription.h" |
| #include "chrome/browser/webdata/web_data_service_factory.h" |
| #include "chrome/common/chrome_version_info.h" |
| #include "components/metrics/metrics_service.h" |
| @@ -24,6 +25,7 @@ |
| #include "content/public/browser/notification_source.h" |
|
droger
2014/11/04 10:31:36
Do we need these includes?
msarda
2014/11/04 12:06:06
Done.
|
| #include "content/public/browser/render_process_host.h" |
| #include "content/public/common/child_process_host.h" |
| +#include "net/url_request/url_request_context_getter.h" |
| #include "url/gurl.h" |
| #if defined(ENABLE_MANAGED_USERS) |
| @@ -49,14 +51,9 @@ const char kGoogleAccountsUrl[] = "https://accounts.google.com"; |
| ChromeSigninClient::ChromeSigninClient(Profile* profile) |
| : profile_(profile), signin_host_id_(ChildProcessHost::kInvalidUniqueID) { |
| - callbacks_.set_removal_callback( |
| - base::Bind(&ChromeSigninClient::UnregisterForCookieChangedNotification, |
| - base::Unretained(this))); |
| } |
| ChromeSigninClient::~ChromeSigninClient() { |
| - UnregisterForCookieChangedNotification(); |
| - |
| std::set<RenderProcessHost*>::iterator i; |
| for (i = signin_hosts_observed_.begin(); i != signin_hosts_observed_.end(); |
| ++i) { |
| @@ -199,13 +196,19 @@ base::Time ChromeSigninClient::GetInstallDate() { |
| g_browser_process->metrics_service()->GetInstallDate()); |
| } |
| -scoped_ptr<SigninClient::CookieChangedCallbackList::Subscription> |
| +scoped_ptr<SigninClient::CookieChangedSubscription> |
| ChromeSigninClient::AddCookieChangedCallback( |
| - const CookieChangedCallback& callback) { |
| - scoped_ptr<SigninClient::CookieChangedCallbackList::Subscription> |
| - subscription = callbacks_.Add(callback); |
| - RegisterForCookieChangedNotification(); |
| - return subscription.Pass(); |
| + const GURL& url, |
| + const std::string& name, |
| + const net::CookieStore::CookieChangedCallback& callback) { |
| + scoped_refptr<net::URLRequestContextGetter> context_getter = |
| + profile_->GetRequestContext(); |
| + DCHECK(context_getter.get()); |
| + scoped_ptr<SigninCookieChangedSubscription> subscription( |
| + new SigninCookieChangedSubscription(callback)); |
| + subscription->RegisterForCookieChangedNotifications( |
| + context_getter, url, name); |
| + return scoped_ptr<CookieChangedSubscription>(subscription.release()); |
| } |
| void ChromeSigninClient::GoogleSigninSucceeded(const std::string& account_id, |
| @@ -217,41 +220,3 @@ void ChromeSigninClient::GoogleSigninSucceeded(const std::string& account_id, |
| chrome::SetLocalAuthCredentials(profile_, password); |
| #endif |
| } |
| - |
| -void ChromeSigninClient::Observe(int type, |
| - const content::NotificationSource& source, |
| - const content::NotificationDetails& details) { |
| - switch (type) { |
| - case chrome::NOTIFICATION_COOKIE_CHANGED: { |
| - DCHECK(!callbacks_.empty()); |
| - const net::CanonicalCookie* cookie = |
| - content::Details<ChromeCookieDetails>(details).ptr()->cookie; |
| - callbacks_.Notify(cookie); |
| - break; |
| - } |
| - default: |
| - NOTREACHED(); |
| - break; |
| - } |
| -} |
| - |
| -void ChromeSigninClient::RegisterForCookieChangedNotification() { |
| - if (callbacks_.empty()) |
| - return; |
| - content::Source<Profile> source(profile_); |
| - 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_); |
| - if (!registrar_.IsRegistered( |
| - this, chrome::NOTIFICATION_COOKIE_CHANGED, source)) |
| - return; |
| - registrar_.Remove(this, chrome::NOTIFICATION_COOKIE_CHANGED, source); |
| -} |