Index: chrome/browser/sync/profile_sync_service.cc |
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc |
index 3e058f3e83c53195278164073f38f018843cf021..2bcdc984648b5a0c718aa21104b7231ff67026ba 100644 |
--- a/chrome/browser/sync/profile_sync_service.cc |
+++ b/chrome/browser/sync/profile_sync_service.cc |
@@ -21,6 +21,7 @@ |
#include "base/stringprintf.h" |
#include "base/task.h" |
#include "base/threading/thread_restrictions.h" |
+#include "chrome/browser/net/chrome_cookie_notification_details.h" |
#include "chrome/browser/net/gaia/token_service.h" |
#include "chrome/browser/prefs/pref_service.h" |
#include "chrome/browser/profiles/profile.h" |
@@ -47,6 +48,7 @@ |
#include "content/common/notification_source.h" |
#include "content/common/notification_type.h" |
#include "grit/generated_resources.h" |
+#include "net/base/cookie_monster.h" |
#include "ui/base/l10n/l10n_util.h" |
using browser_sync::ChangeProcessor; |
@@ -173,6 +175,11 @@ void ProfileSyncService::RegisterAuthNotifications() { |
registrar_.Add(this, |
NotificationType::GOOGLE_SIGNIN_FAILED, |
Source<Profile>(profile_)); |
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableSyncOAuth)) { |
+ registrar_.Add(this, |
+ NotificationType::COOKIE_CHANGED, |
+ Source<Profile>(profile_)); |
+ } |
} |
void ProfileSyncService::RegisterDataTypeController( |
@@ -559,6 +566,59 @@ void ProfileSyncService::OnBackendInitialized() { |
} |
} |
+namespace { |
+const char* CauseName(net::CookieMonster::Delegate::ChangeCause cause) { |
+ switch (cause) { |
+ case net::CookieMonster::Delegate::CHANGE_COOKIE_EXPLICIT: |
+ return "CHANGE_COOKIE_EXPLICIT"; |
+ case net::CookieMonster::Delegate::CHANGE_COOKIE_OVERWRITE: |
+ return "CHANGE_COOKIE_OVERWRITE"; |
+ case net::CookieMonster::Delegate::CHANGE_COOKIE_EXPIRED: |
+ return "CHANGE_COOKIE_EXPIRED"; |
+ case net::CookieMonster::Delegate::CHANGE_COOKIE_EVICTED: |
+ return "CHANGE_COOKIE_EVICTED"; |
+ case net::CookieMonster::Delegate::CHANGE_COOKIE_EXPIRED_OVERWRITE: |
+ return "CHANGE_COOKIE_EXPIRED_OVERWRITE"; |
+ default: |
+ return "<unknown>"; |
+ } |
+} |
+} |
+ |
+void ProfileSyncService::OnCookieChanged(Profile* profile, |
+ ChromeCookieDetails* cookie_details) { |
+ const net::CookieMonster::CanonicalCookie* canonical_cookie = |
+ cookie_details->cookie; |
+ if (canonical_cookie->Name() == "oauth_token") { |
+ net::CookieMonster::Delegate::ChangeCause cause = cookie_details->cause; |
+ LOG(INFO) << "COOKIE_CHANGED: removed=" |
+ << (cookie_details->removed ? "true" : "false") |
+ << ", cause=" << CauseName(cause) |
+ << ", Source=" << canonical_cookie->Source() |
+ << ", Name=" << canonical_cookie->Name() |
+ << ", Value=" << canonical_cookie->Value() |
+ << ", Domain=" << canonical_cookie->Domain() |
+ << ", Path=" << canonical_cookie->Path() |
+ << ", DoesExpire=" |
+ << (canonical_cookie->DoesExpire() ? "true" : "false") |
+ << ", IsPersistent=" |
+ << (canonical_cookie->IsPersistent() ? "true" : "false") |
+ << ", IsSecure=" |
+ << (canonical_cookie->IsSecure() ? "true" : "false") |
+ << ", IsHttpOnly=" |
+ << (canonical_cookie->IsHttpOnly() ? "true" : "false") |
+ << ", IsDomainCookie=" |
+ << (canonical_cookie->IsDomainCookie() ? "true" : "false") |
+ << ", IsHostCookie=" |
+ << (canonical_cookie->IsHostCookie() ? "true" : "false") |
+ << ", IsExpired=" |
+ << (const_cast<net::CookieMonster::CanonicalCookie*>( |
+ canonical_cookie)->IsExpired( |
+ base::Time::NowFromSystemTime()) |
+ ? "true" : "false"); |
+ } |
+} |
+ |
void ProfileSyncService::OnSyncCycleCompleted() { |
UpdateLastSyncedTime(); |
VLOG(2) << "Notifying observers sync cycle completed"; |
@@ -1307,6 +1367,11 @@ void ProfileSyncService::Observe(NotificationType type, |
} |
break; |
} |
+ case NotificationType::COOKIE_CHANGED: { |
+ OnCookieChanged(Source<Profile>(source).ptr(), |
+ Details<ChromeCookieDetails>(details).ptr()); |
+ break; |
+ } |
default: { |
NOTREACHED(); |
} |