| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/profiles/profile.h" | 5 #include "chrome/browser/profiles/profile.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "chrome/browser/first_run/first_run.h" | 11 #include "chrome/browser/first_run/first_run.h" |
| 12 #include "chrome/browser/sync/profile_sync_service.h" | 12 #include "chrome/browser/sync/profile_sync_service.h" |
| 13 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 13 #include "chrome/browser/sync/sync_prefs.h" | 14 #include "chrome/browser/sync/sync_prefs.h" |
| 14 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
| 15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 16 #include "components/user_prefs/pref_registry_syncable.h" | 17 #include "components/user_prefs/pref_registry_syncable.h" |
| 17 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
| 18 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
| 19 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/browser/web_ui.h" | 21 #include "content/public/browser/web_ui.h" |
| 21 | 22 |
| 22 #if defined(OS_CHROMEOS) | 23 #if defined(OS_CHROMEOS) |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 bool Profile::IsNewProfile() { | 165 bool Profile::IsNewProfile() { |
| 165 // The profile has been shut down if the prefs were loaded from disk, unless | 166 // The profile has been shut down if the prefs were loaded from disk, unless |
| 166 // first-run autoimport wrote them and reloaded the pref service. | 167 // first-run autoimport wrote them and reloaded the pref service. |
| 167 // TODO(dconnelly): revisit this when crbug.com/22142 (unifying the profile | 168 // TODO(dconnelly): revisit this when crbug.com/22142 (unifying the profile |
| 168 // import code) is fixed. | 169 // import code) is fixed. |
| 169 return GetOriginalProfile()->GetPrefs()->GetInitializationStatus() == | 170 return GetOriginalProfile()->GetPrefs()->GetInitializationStatus() == |
| 170 PrefService::INITIALIZATION_STATUS_CREATED_NEW_PREF_STORE; | 171 PrefService::INITIALIZATION_STATUS_CREATED_NEW_PREF_STORE; |
| 171 } | 172 } |
| 172 | 173 |
| 173 bool Profile::IsSyncAccessible() { | 174 bool Profile::IsSyncAccessible() { |
| 175 if (ProfileSyncServiceFactory::HasProfileSyncService(this)) |
| 176 return !ProfileSyncServiceFactory::GetForProfile(this)->IsManaged(); |
| 177 |
| 178 // No ProfileSyncService created yet - we don't want to create one, so just |
| 179 // infer the accessible state by looking at prefs/command line flags. |
| 174 browser_sync::SyncPrefs prefs(GetPrefs()); | 180 browser_sync::SyncPrefs prefs(GetPrefs()); |
| 175 return ProfileSyncService::IsSyncEnabled() && !prefs.IsManaged(); | 181 return ProfileSyncService::IsSyncEnabled() && !prefs.IsManaged(); |
| 176 } | 182 } |
| 177 | 183 |
| 178 void Profile::MaybeSendDestroyedNotification() { | 184 void Profile::MaybeSendDestroyedNotification() { |
| 179 if (!sent_destroyed_notification_) { | 185 if (!sent_destroyed_notification_) { |
| 180 sent_destroyed_notification_ = true; | 186 sent_destroyed_notification_ = true; |
| 181 content::NotificationService::current()->Notify( | 187 content::NotificationService::current()->Notify( |
| 182 chrome::NOTIFICATION_PROFILE_DESTROYED, | 188 chrome::NOTIFICATION_PROFILE_DESTROYED, |
| 183 content::Source<Profile>(this), | 189 content::Source<Profile>(this), |
| 184 content::NotificationService::NoDetails()); | 190 content::NotificationService::NoDetails()); |
| 185 } | 191 } |
| 186 } | 192 } |
| OLD | NEW |