summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-10 09:27:53 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-10 09:27:53 +0000
commitddbb0b1bb8d761ec15ae84efedd1ead5384a3cf1 (patch)
tree4e27597f166aa3a63a7565fe96c5c9b8434d13a0
parent9e09bae277aa6cd98c3a5e340d7fdc82e8e07f96 (diff)
downloadchromium_src-ddbb0b1bb8d761ec15ae84efedd1ead5384a3cf1.zip
chromium_src-ddbb0b1bb8d761ec15ae84efedd1ead5384a3cf1.tar.gz
chromium_src-ddbb0b1bb8d761ec15ae84efedd1ead5384a3cf1.tar.bz2
[uber settings] more elegant fix for sync crash
in my haste to fix the crash I took the easy way out. This is slightly nicer in that it makes the no-sync-system case not jiggly as well, and we can remove one more js function. BUG=none TEST=launching settings, signing into and out of sync, launching settings in incognito Review URL: http://codereview.chromium.org/9370048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121417 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/options2/browser_options.js14
-rw-r--r--chrome/browser/ui/webui/options2/browser_options_handler2.cc16
2 files changed, 13 insertions, 17 deletions
diff --git a/chrome/browser/resources/options2/browser_options.js b/chrome/browser/resources/options2/browser_options.js
index 1545ad2..af6ec2c 100644
--- a/chrome/browser/resources/options2/browser_options.js
+++ b/chrome/browser/resources/options2/browser_options.js
@@ -46,8 +46,7 @@ cr.define('options', function() {
OptionsPage.prototype.initializePage.call(this);
// Sync (Sign in) section.
- if (templateData.syncData)
- this.updateSyncState_(templateData.syncData);
+ this.updateSyncState_(templateData.syncData);
$('sync-action-link').onclick = function(event) {
SyncSetupOverlay.showErrorUI();
@@ -254,6 +253,12 @@ cr.define('options', function() {
* @private
*/
updateSyncState_: function(syncData) {
+ if (!syncData.syncSystemEnabled) {
+ $('sync-section').hidden = true;
+ return;
+ }
+
+ $('sync-section').hidden = false;
this.syncSetupCompleted = syncData.setupCompleted;
$('customize-sync').hidden = !syncData.setupCompleted;
@@ -299,10 +304,6 @@ cr.define('options', function() {
$('profiles-section').hidden = !visible;
},
- hideSyncSection_: function() {
- $('sync-section').hidden = true;
- },
-
/**
* Get the start/stop sync button DOM element. Used for testing.
* @return {DOMElement} The start/stop sync button.
@@ -587,7 +588,6 @@ cr.define('options', function() {
//Forward public APIs to private implementations.
[
'getStartStopSyncButton',
- 'hideSyncSection',
'setGtkThemeButtonEnabled',
'setInstantFieldTrialStatus',
'setProfilesInfo',
diff --git a/chrome/browser/ui/webui/options2/browser_options_handler2.cc b/chrome/browser/ui/webui/options2/browser_options_handler2.cc
index 354fe46..5d98a7d 100644
--- a/chrome/browser/ui/webui/options2/browser_options_handler2.cc
+++ b/chrome/browser/ui/webui/options2/browser_options_handler2.cc
@@ -232,9 +232,7 @@ void BrowserOptionsHandler::GetLocalizedValues(
#endif
// Pass along sync status early so it will be available during page init.
- DictionaryValue* syncData = GetSyncStateDictionary();
- if (syncData)
- localized_strings->Set("syncData", syncData);
+ localized_strings->Set("syncData", GetSyncStateDictionary());
}
void BrowserOptionsHandler::RegisterMessages() {
@@ -300,12 +298,9 @@ void BrowserOptionsHandler::Initialize() {
ProfileSyncService* sync_service(ProfileSyncServiceFactory::
GetInstance()->GetForProfile(Profile::FromWebUI(web_ui())));
- if (sync_service) {
+ if (sync_service)
sync_service->AddObserver(this);
- OnStateChanged();
- } else {
- web_ui()->CallJavascriptFunction("options.BrowserOptions.hideSyncSection");
- }
+ OnStateChanged();
// Create our favicon data source.
profile->GetChromeURLDataManager()->AddDataSource(
@@ -744,12 +739,13 @@ void BrowserOptionsHandler::IncreaseScreenBrightnessCallback(
#endif
DictionaryValue* BrowserOptionsHandler::GetSyncStateDictionary() {
+ DictionaryValue* sync_status = new DictionaryValue;
ProfileSyncService* service(ProfileSyncServiceFactory::
GetInstance()->GetForProfile(Profile::FromWebUI(web_ui())));
+ sync_status->SetBoolean("syncSystemEnabled", !!service);
if (!service)
- return NULL;
+ return sync_status;
- DictionaryValue* sync_status = new DictionaryValue;
sync_status->SetBoolean("setupCompleted",
service->HasSyncSetupCompleted());
sync_status->SetBoolean("setupInProgress", service->SetupInProgress());