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

Unified Diff: chrome/browser/invalidation/invalidation_service_factory.cc

Issue 218903005: Make push messaging not create InvalidationService for login and guest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make code resilient against tests that do not create the Default profile first. Created 6 years, 9 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/invalidation/invalidation_service_factory.cc
diff --git a/chrome/browser/invalidation/invalidation_service_factory.cc b/chrome/browser/invalidation/invalidation_service_factory.cc
index 138b526f1b9e41694bb09f93021fd66afc391b8c..ef34d2ecf1087f70f7c7aa701a73cb1ce620e16a 100644
--- a/chrome/browser/invalidation/invalidation_service_factory.cc
+++ b/chrome/browser/invalidation/invalidation_service_factory.cc
@@ -28,8 +28,10 @@
#endif // defined(OS_ANDROID)
#if defined(OS_CHROMEOS)
+#include "base/files/file_path.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h"
#include "chrome/browser/invalidation/device_invalidation_auth_provider_chromeos.h"
#endif
@@ -39,6 +41,19 @@ namespace invalidation {
// static
InvalidationService* InvalidationServiceFactory::GetForProfile(
Profile* profile) {
+#if defined(OS_CHROMEOS)
+ // Using ProfileHelper::GetSigninProfile() here would lead to an infinite loop
+ // when this method is called during the creation of the sign-in profile
+ // itself. Using ProfileHelper::GetSigninProfileDir() is safe because it does
+ // not try to access the sign-in profile.
+ if (profile->GetPath() == chromeos::ProfileHelper::GetSigninProfileDir()||
+ (chromeos::UserManager::IsInitialized() &&
+ chromeos::UserManager::Get()->IsLoggedInAsGuest())) {
+ // The Chrome OS login and Chrome OS guest profiles do not have GAIA
+ // credentials and do not support invalidation.
+ return NULL;
+ }
+#endif
return static_cast<InvalidationService*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
« no previous file with comments | « chrome/browser/invalidation/invalidation_service_factory.h ('k') | chrome/browser/sync/glue/sync_backend_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698