summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorstevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-14 17:59:48 +0000
committerstevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-14 17:59:48 +0000
commitb780ce945a519a9c4c77f19516a95f5e2254b8fc (patch)
tree00de0bb0266cfd67e8d7cc2a599fee466acf7e3e /chrome
parentbb5d5a10554732081cf484c0e624327fe46d8780 (diff)
downloadchromium_src-b780ce945a519a9c4c77f19516a95f5e2254b8fc.zip
chromium_src-b780ce945a519a9c4c77f19516a95f5e2254b8fc.tar.gz
chromium_src-b780ce945a519a9c4c77f19516a95f5e2254b8fc.tar.bz2
Fix chromium-os:10777 and other sync related crashes.
Return NULL when GetProfileSyncService() is called without a cros_user argument (if not already initialized) and protect the settings code when sync service is NULL. A side effect of this is that sync will be disabled if chrome is not started from the login screen in ChromeOS (e.g. when debugging), instead of being initialized without a valid backend, so e.g. settings will not have a sync section, and about:sync will show 'sync disabled'. BUG=chromium-os:10777,chromium-os:10893 TEST=Test proxy settings from login screen, sync settings page, and about:sync. Review URL: http://codereview.chromium.org/6260002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71457 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/dom_ui/options/personal_options_handler.cc2
-rw-r--r--chrome/browser/dom_ui/options/sync_options_handler.cc7
-rw-r--r--chrome/browser/profiles/profile_impl.cc13
3 files changed, 12 insertions, 10 deletions
diff --git a/chrome/browser/dom_ui/options/personal_options_handler.cc b/chrome/browser/dom_ui/options/personal_options_handler.cc
index bc14c1f..7102a7a 100644
--- a/chrome/browser/dom_ui/options/personal_options_handler.cc
+++ b/chrome/browser/dom_ui/options/personal_options_handler.cc
@@ -154,6 +154,7 @@ void PersonalOptionsHandler::OnStateChanged() {
string16 status_label;
string16 link_label;
ProfileSyncService* service = dom_ui_->GetProfile()->GetProfileSyncService();
+ DCHECK(service);
bool managed = service->IsManaged();
bool sync_setup_completed = service->HasSyncSetupCompleted();
bool status_has_error = sync_ui_util::GetStatusLabels(service,
@@ -275,6 +276,7 @@ void PersonalOptionsHandler::ShowSyncLoginDialog(const ListValue* args) {
dom_ui_->tab_contents(), UTF8ToUTF16(email), message, this);
#else
ProfileSyncService* service = dom_ui_->GetProfile()->GetProfileSyncService();
+ DCHECK(service);
service->ShowLoginDialog(NULL);
ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_OPTIONS);
#endif
diff --git a/chrome/browser/dom_ui/options/sync_options_handler.cc b/chrome/browser/dom_ui/options/sync_options_handler.cc
index e67050c..da9b080 100644
--- a/chrome/browser/dom_ui/options/sync_options_handler.cc
+++ b/chrome/browser/dom_ui/options/sync_options_handler.cc
@@ -59,10 +59,9 @@ void SyncOptionsHandler::GetLocalizedValues(
void SyncOptionsHandler::Initialize() {
ProfileSyncService* service =
- dom_ui_->GetProfile()->GetOriginalProfile()->GetProfileSyncService();
- // If service is unavailable for some good reason, 'IsEnabled()' method
- // should return false. Otherwise something is broken.
- DCHECK(service);
+ dom_ui_->GetProfile()->GetProfileSyncService();
+ if (!service)
+ return; // Can happen in ChromeOS if called before login.
DictionaryValue args;
SyncSetupFlow::GetArgsForConfigure(service, &args);
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 4a60cd1..8323989 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -1248,12 +1248,13 @@ TokenService* ProfileImpl::GetTokenService() {
ProfileSyncService* ProfileImpl::GetProfileSyncService() {
#if defined(OS_CHROMEOS)
- // If kLoginManager is specified, we shouldn't call this unless login has
- // completed and specified cros_user. Guard with if (HasProfileSyncService())
- // where this might legitimately get called before login has completed.
- if (!sync_service_.get() &&
- CommandLine::ForCurrentProcess()->HasSwitch(switches::kLoginManager)) {
- LOG(FATAL) << "GetProfileSyncService() called before login complete.";
+ if (!sync_service_.get()) {
+ // In ChromeOS, sync only gets initialized properly from login, when
+ // kLoginManager is specified. If this gets called before login, or
+ // during a debugging session without kLoginManager, this will return
+ // NULL, so ensure that calls either handle a NULL result, or use
+ // HasProfileSyncService() to guard against the call.
+ return NULL;
}
#endif
return GetProfileSyncService("");