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

Unified Diff: chrome/browser/sync/profile_sync_service.cc

Issue 7198025: Adds --enable-sync-oauth, enabling INFO logging of oauth_token cookies (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Declaring a struct instead of including a header that breaks a ChromeOS build. Created 9 years, 6 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/sync/profile_sync_service.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698