diff options
author | dantasse@chromium.org <dantasse@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-02 21:14:53 +0000 |
---|---|---|
committer | dantasse@chromium.org <dantasse@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-02 21:14:53 +0000 |
commit | 71db65535acb49f0cee246cd1a4cd4e0225107b7 (patch) | |
tree | 7d4dfd979480acd069cb8ae7d652866235921ddb /chrome/browser/sync | |
parent | 32da2a0bb25a12aa9eb425fdfb03ca82b1d6fd32 (diff) | |
download | chromium_src-71db65535acb49f0cee246cd1a4cd4e0225107b7.zip chromium_src-71db65535acb49f0cee246cd1a4cd4e0225107b7.tar.gz chromium_src-71db65535acb49f0cee246cd1a4cd4e0225107b7.tar.bz2 |
Disallow syncing 0 datatypes.
If you try to set up or customize sync, then click "choose data types to sync" and uncheck all of them, then click OK, this will give you an error message ("you must select at least one data type to sync.") and will not start syncing. This is what we wanted to do with the old dialog box; the only reason we couldn't is that we didn't have time to get a translated string in.
Note that there's enough room on the error message for two lines' worth of text if necessary.
Screenshot in the corresponding bug (47995).
BUG=47995
TEST=try to start syncing, click "choose data types to sync", and uncheck all of them, and click OK. It should give you an error as described above.
Review URL: http://codereview.chromium.org/2827040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51566 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync')
-rw-r--r-- | chrome/browser/sync/resources/choose_datatypes.html | 54 | ||||
-rw-r--r-- | chrome/browser/sync/sync_setup_wizard.cc | 2 |
2 files changed, 42 insertions, 14 deletions
diff --git a/chrome/browser/sync/resources/choose_datatypes.html b/chrome/browser/sync/resources/choose_datatypes.html index ed60867..6b40492 100644 --- a/chrome/browser/sync/resources/choose_datatypes.html +++ b/chrome/browser/sync/resources/choose_datatypes.html @@ -120,13 +120,10 @@ input[type='submit'] { } function setDataTypeCheckboxesEnabled(enabled) { - document.getElementById("bookmarksCheckbox").disabled = !enabled; - document.getElementById("preferencesCheckbox").disabled = !enabled; - document.getElementById("themesCheckbox").disabled = !enabled; - document.getElementById("passwordsCheckbox").disabled = !enabled; - document.getElementById("autofillCheckbox").disabled = !enabled; - document.getElementById("extensionsCheckbox").disabled = !enabled; - document.getElementById("typedUrlsCheckbox").disabled = !enabled; + var checkboxes = document.getElementsByName("dataTypeCheckbox"); + for (var i = 0; i < checkboxes.length; i++) { + checkboxes[i].disabled = !enabled; + } } function advanceThrobber() { @@ -145,7 +142,31 @@ input[type='submit'] { templateData['ok']; } + // Returns true if at least one data type is enabled and no data types are + // checked. (If all data type checkboxes are disabled, it's because "keep + // everything synced" is checked.) + function noDataTypesChecked() { + var checkboxes = document.getElementsByName("dataTypeCheckbox"); + var atLeastOneChecked = false; + var atLeastOneEnabled = false; + for (var i = 0; i < checkboxes.length; i++) { + if (!checkboxes[i].disabled && checkboxes[i].style.display != 'none') { + atLeastOneEnabled = true; + if (checkboxes[i].checked) { + atLeastOneChecked = true; + } + } + } + return atLeastOneEnabled && !atLeastOneChecked; + } + function sendChooseDataTypesAndClose() { + + if (noDataTypesChecked()) { + document.getElementById("error_text").style.visibility = "visible"; + return; + } + setStateThrobbing(true); var f = document.getElementById("chooseDataTypesForm"); @@ -192,37 +213,37 @@ input[type='submit'] { <table class="data_type_checkboxes_table" border="0" cellspacing="0" cellpadding="0" width="80%"> <tr> <td> - <input id="bookmarksCheckbox" type="checkbox"/> + <input id="bookmarksCheckbox" name="dataTypeCheckbox" type="checkbox"/> <label id="bookmarksCheckboxLabel" for="bookmarksCheckbox" i18n-content="bookmarks"></label> </td> <td> - <input id="autofillCheckbox" type="checkbox"/> + <input id="autofillCheckbox" name="dataTypeCheckbox" type="checkbox"/> <label id="autofillCheckboxLabel" for="autofillCheckbox" i18n-content="autofill"></label> </td> </tr> <tr> <td> - <input id="preferencesCheckbox" type="checkbox"/> + <input id="preferencesCheckbox" name="dataTypeCheckbox" type="checkbox"/> <label id="preferencesCheckboxLabel" for="preferencesCheckbox" i18n-content="preferences"></label> </td> <td> - <input id="extensionsCheckbox" type="checkbox"/> + <input id="extensionsCheckbox" name="dataTypeCheckbox" type="checkbox"/> <label id="extensionsCheckboxLabel" for="extensionsCheckbox" i18n-content="extensions"></label> </td> </tr> <tr> <td> - <input id="themesCheckbox" type="checkbox"/> + <input id="themesCheckbox" name="dataTypeCheckbox" type="checkbox"/> <label id="themesCheckboxLabel" for="themesCheckbox" i18n-content="themes"></label> </td> <td> - <input id="typedUrlsCheckbox" type="checkbox"/> + <input id="typedUrlsCheckbox" name="dataTypeCheckbox" type="checkbox"/> <label id="typedUrlsCheckboxLabel" for="typedUrlsCheckbox" i18n-content="typedurls"></label> </td> </tr> <tr> <td> - <input id="passwordsCheckbox" type="checkbox"/> + <input id="passwordsCheckbox" name="dataTypeCheckbox" type="checkbox"/> <label id="passwordsCheckboxLabel" for="passwordsCheckbox" i18n-content="passwords"></label> </td> <td> @@ -231,6 +252,11 @@ input[type='submit'] { </table> </td> </tr> + <tr> + <td> + <span id="error_text" i18n-content="synczerodatatypeserror" style="visibility:hidden"></span> + </td> + </tr> <tr valign="bottom"> <td width="100%" class="endaligned"> <span id="throbber_container" style="visibility:hidden"> diff --git a/chrome/browser/sync/sync_setup_wizard.cc b/chrome/browser/sync/sync_setup_wizard.cc index 87e016d..47b5883 100644 --- a/chrome/browser/sync/sync_setup_wizard.cc +++ b/chrome/browser/sync/sync_setup_wizard.cc @@ -149,6 +149,8 @@ void SyncResourcesSource::StartDataRequest(const std::string& path_raw, l10n_util::GetString(IDS_SYNC_DATATYPE_EXTENSIONS)); localized_strings.SetString(L"typedurls", l10n_util::GetString(IDS_SYNC_DATATYPE_TYPED_URLS)); + localized_strings.SetString(L"synczerodatatypeserror", + l10n_util::GetString(IDS_SYNC_ZERO_DATA_TYPES_ERROR)); localized_strings.SetString(L"ok", l10n_util::GetString(IDS_OK)); localized_strings.SetString(L"cancel", |