Commit 5c3f8a53 authored by jhawkins@chromium.org's avatar jhawkins@chromium.org

Sync UI: Use camelCase for variables sent to JS.

BUG=119646
TEST=none
R=dbeam


Review URL: http://codereview.chromium.org/10200002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133734 0039d316-1c4b-4281-b951-d872f2087c98
parent 3788a207
......@@ -221,15 +221,15 @@ cr.define('options', function() {
// SyncSetupFlow::GetDataTypeChoiceData().
var result = JSON.stringify({
'syncAllDataTypes': syncAll,
'sync_bookmarks': syncAll || $('bookmarks-checkbox').checked,
'sync_preferences': syncAll || $('preferences-checkbox').checked,
'sync_themes': syncAll || $('themes-checkbox').checked,
'sync_passwords': syncAll || $('passwords-checkbox').checked,
'sync_autofill': syncAll || $('autofill-checkbox').checked,
'sync_extensions': syncAll || $('extensions-checkbox').checked,
'sync_typed_urls': syncAll || $('typed-urls-checkbox').checked,
'sync_apps': syncAll || $('apps-checkbox').checked,
'sync_sessions': syncAll || $('sessions-checkbox').checked,
'bookmarksSynced': syncAll || $('bookmarks-checkbox').checked,
'preferencesSynced': syncAll || $('preferences-checkbox').checked,
'themesSynced': syncAll || $('themes-checkbox').checked,
'passwordsSynced': syncAll || $('passwords-checkbox').checked,
'autofillSynced': syncAll || $('autofill-checkbox').checked,
'extensionsSynced': syncAll || $('extensions-checkbox').checked,
'typedUrlsSynced': syncAll || $('typed-urls-checkbox').checked,
'appsSynced': syncAll || $('apps-checkbox').checked,
'sessionsSynced': syncAll || $('sessions-checkbox').checked,
'encryptAllData': encryptAllData,
'usePassphrase': usePassphrase,
'isGooglePassphrase': googlePassphrase,
......@@ -286,46 +286,52 @@ cr.define('options', function() {
}
},
/**
* Shows or hides the Sync data type checkboxes in the advanced
* configuration screen.
* @param {Object} args The configuration data used to show/hide UI.
* @private
*/
setChooseDataTypesCheckboxes_: function(args) {
var datatypeSelect = $('sync-select-datatypes');
datatypeSelect.selectedIndex = args.syncAllDataTypes ? 0 : 1;
$('bookmarks-checkbox').checked = args.sync_bookmarks;
$('preferences-checkbox').checked = args.sync_preferences;
$('themes-checkbox').checked = args.sync_themes;
$('bookmarks-checkbox').checked = args.bookmarksSynced;
$('preferences-checkbox').checked = args.preferencesSynced;
$('themes-checkbox').checked = args.themesSynced;
if (args.passwords_registered) {
$('passwords-checkbox').checked = args.sync_passwords;
if (args.passwordsRegistered) {
$('passwords-checkbox').checked = args.passwordsSynced;
$('passwords-item').hidden = false;
} else {
$('passwords-item').hidden = true;
}
if (args.autofill_registered) {
$('autofill-checkbox').checked = args.sync_autofill;
if (args.autofillRegistered) {
$('autofill-checkbox').checked = args.autofillSynced;
$('autofill-item').hidden = false;
} else {
$('autofill-item').hidden = true;
}
if (args.extensions_registered) {
$('extensions-checkbox').checked = args.sync_extensions;
if (args.extensionsRegistered) {
$('extensions-checkbox').checked = args.extensionsSynced;
$('extensions-item').hidden = false;
} else {
$('extensions-item').hidden = true;
}
if (args.typed_urls_registered) {
$('typed-urls-checkbox').checked = args.sync_typed_urls;
if (args.typedUrlsRegistered) {
$('typed-urls-checkbox').checked = args.typedUrlsSynced;
$('omnibox-item').hidden = false;
} else {
$('omnibox-item').hidden = true;
}
if (args.apps_registered) {
$('apps-checkbox').checked = args.sync_apps;
if (args.appsRegistered) {
$('apps-checkbox').checked = args.appsSynced;
$('apps-item').hidden = false;
} else {
$('apps-item').hidden = true;
}
if (args.sessions_registered) {
$('sessions-checkbox').checked = args.sync_sessions;
if (args.sessionsRegistered) {
$('sessions-checkbox').checked = args.sessionsSynced;
$('sessions-item').hidden = false;
} else {
$('sessions-item').hidden = true;
......@@ -335,7 +341,7 @@ cr.define('options', function() {
},
setEncryptionRadios_: function(args) {
if (args['encryptAllData']) {
if (args.encryptAllData) {
$('encrypt-all-option').checked = true;
this.disableEncryptionRadioGroup_();
} else {
......@@ -344,7 +350,7 @@ cr.define('options', function() {
},
setPassphraseRadios_: function(args) {
if (args['usePassphrase']) {
if (args.usePassphrase) {
$('explicit-option').checked = true;
// The passphrase, once set, cannot be unset, but we show a reset link.
......@@ -383,14 +389,14 @@ cr.define('options', function() {
if (args) {
this.setCheckboxesAndErrors_(args);
this.useEncryptEverything_ = args['encryptAllData'];
this.useEncryptEverything_ = args.encryptAllData;
// Whether to display the 'Sync everything' confirmation page or the
// customize data types page.
var syncAllDataTypes = args['syncAllDataTypes'];
this.usePassphrase_ = args['usePassphrase'];
if (args['showSyncEverythingPage'] == false || this.usePassphrase_ ||
syncAllDataTypes == false || args['show_passphrase']) {
var syncAllDataTypes = args.syncAllDataTypes;
this.usePassphrase_ = args.usePassphrase;
if (args.showSyncEverythingPage == false || this.usePassphrase_ ||
syncAllDataTypes == false || args.showPassphrase) {
this.showCustomizePage_(args, syncAllDataTypes);
} else {
this.showSyncEverythingPage_();
......@@ -448,7 +454,7 @@ cr.define('options', function() {
$('google-passphrase-needed-body').hidden = true;
// Display the correct prompt to the user depending on what type of
// passphrase is needed.
if (args['usePassphrase'])
if (args.usePassphrase)
$('normal-body').hidden = false;
else
$('google-passphrase-needed-body').hidden = false;
......@@ -458,7 +464,7 @@ cr.define('options', function() {
// and the passphrase field is non-empty (meaning they tried to set it
// previously but failed).
$('incorrect-passphrase').hidden =
!(args['usePassphrase'] && args['passphrase_failed']);
!(args.usePassphrase && args.passphraseFailed);
$('sync-passphrase-warning').hidden = false;
$('passphrase').focus();
......@@ -483,7 +489,7 @@ cr.define('options', function() {
// set focus before that logic.
$('choose-datatypes-ok').focus();
if (args && args['show_passphrase']) {
if (args && args.showPassphrase) {
this.showPassphraseContainer_(args);
} else {
// We only show the 'Use Default' link if we're not prompting for an
......@@ -655,7 +661,7 @@ cr.define('options', function() {
email.value = args.user;
}
if (!args.editable_user) {
if (!args.editableUser) {
$('email-row').hidden = true;
var span = $('email-readonly');
span.textContent = email.value;
......@@ -667,25 +673,25 @@ cr.define('options', function() {
}
if (1 == args.error) {
var access_code = $('access-code');
if (access_code.value) {
var accessCode = $('access-code');
if (accessCode.value) {
$('errormsg-0-access-code').hidden = false;
this.showAccessCodeRequired_();
} else {
$('errormsg-1-password').hidden = false;
}
this.setBlurbError_(args.error_message);
this.setBlurbError_(args.errorMessage);
} else if (3 == args.error) {
$('errormsg-0-connection').hidden = false;
this.setBlurbError_(args.error_message);
this.setBlurbError_(args.errorMessage);
} else if (4 == args.error) {
this.showCaptcha_(args);
} else if (7 == args.error) {
this.setBlurbError_(localStrings.getString('serviceUnavailableError'));
} else if (8 == args.error) {
this.showAccessCodeRequired_();
} else if (args.error_message) {
this.setBlurbError_(args.error_message);
} else if (args.errorMessage) {
this.setBlurbError_(args.errorMessage);
}
if (args.fatalError) {
......@@ -707,14 +713,14 @@ cr.define('options', function() {
$('errormsg-0-access-code').hidden = true;
},
setBlurbError_: function(error_message) {
setBlurbError_: function(errorMessage) {
if (this.captchaChallengeActive_)
return; // No blurb in captcha challenge mode.
if (error_message) {
if (errorMessage) {
$('error-signing-in').hidden = true;
$('error-custom').hidden = false;
$('error-custom').textContent = error_message;
$('error-custom').textContent = errorMessage;
} else {
$('error-signing-in').hidden = false;
$('error-custom').hidden = true;
......@@ -783,7 +789,7 @@ cr.define('options', function() {
var result = JSON.stringify({'user' : email.value,
'pass' : passwd.value,
'captcha' : f.captchaValue.value,
'access_code' : f.accessCode.value});
'accessCode' : f.accessCode.value});
$('sign-in').disabled = true;
chrome.send('SyncSetupSubmitAuth', [result]);
},
......
......@@ -71,7 +71,7 @@ const char* kDataTypeNames[] = {
"preferences",
"sessions",
"themes",
"typed_urls"
"typedUrls"
};
const syncable::ModelType kDataTypes[] = {
......@@ -103,7 +103,7 @@ bool GetAuthData(const std::string& json,
if (!result->GetString("user", username) ||
!result->GetString("pass", password) ||
!result->GetString("captcha", captcha) ||
!result->GetString("access_code", access_code)) {
!result->GetString("accessCode", access_code)) {
return false;
}
return true;
......@@ -123,7 +123,7 @@ bool GetConfiguration(const std::string& json, SyncConfigInfo* config) {
}
for (size_t i = 0; i < arraysize(kDataTypeNames); ++i) {
std::string key_name = std::string("sync_") + kDataTypeNames[i];
std::string key_name = kDataTypeNames[i] + std::string("Synced");
bool sync_value;
if (!result->GetBoolean(key_name, &sync_value)) {
DLOG(ERROR) << "GetConfiguration() not passed a value for " << key_name;
......@@ -349,14 +349,13 @@ void SyncSetupHandler::DisplayConfigureSync(bool show_advanced,
// Setup args for the sync configure screen:
// showSyncEverythingPage: false to skip directly to the configure screen
// syncAllDataTypes: true if the user wants to sync everything
// <data_type>_registered: true if the associated data type is supported
// sync_<data_type>: true if the user wants to sync that specific data type
// <data_type>Registered: true if the associated data type is supported
// <data_type>Synced: true if the user wants to sync that specific data type
// encryptionEnabled: true if sync supports encryption
// encryptAllData: true if user wants to encrypt all data (not just
// passwords)
// usePassphrase: true if the data is encrypted with a secondary passphrase
// show_passphrase: true if a passphrase is needed to decrypt the sync data
// TODO(atwilson): Convert all to unix_hacker style (http://crbug.com/119646).
DictionaryValue args;
// Tell the UI layer which data types are registered/enabled by the user.
......@@ -366,12 +365,12 @@ void SyncSetupHandler::DisplayConfigureSync(bool show_advanced,
service->GetPreferredDataTypes();
for (size_t i = 0; i < kNumDataTypes; ++i) {
const std::string key_name = kDataTypeNames[i];
args.SetBoolean(key_name + "_registered",
args.SetBoolean(key_name + "Registered",
registered_types.Has(kDataTypes[i]));
args.SetBoolean("sync_" + key_name, preferred_types.Has(kDataTypes[i]));
args.SetBoolean(key_name + "Synced", preferred_types.Has(kDataTypes[i]));
}
browser_sync::SyncPrefs sync_prefs(GetProfile()->GetPrefs());
args.SetBoolean("passphrase_failed", passphrase_failed);
args.SetBoolean("passphraseFailed", passphrase_failed);
args.SetBoolean("showSyncEverythingPage", !show_advanced);
args.SetBoolean("syncAllDataTypes", sync_prefs.HasKeepEverythingSynced());
args.SetBoolean("encryptAllData", service->EncryptEverythingEnabled());
......@@ -379,7 +378,7 @@ void SyncSetupHandler::DisplayConfigureSync(bool show_advanced,
// We call IsPassphraseRequired() here, instead of calling
// IsPassphraseRequiredForDecryption(), because we want to show the passphrase
// UI even if no encrypted data types are enabled.
args.SetBoolean("show_passphrase", service->IsPassphraseRequired());
args.SetBoolean("showPassphrase", service->IsPassphraseRequired());
StringValue page("configure");
web_ui()->CallJavascriptFunction(
......@@ -483,9 +482,9 @@ void SyncSetupHandler::DisplayGaiaLoginWithErrorMessage(
DictionaryValue args;
args.SetString("user", user);
args.SetInteger("error", error);
args.SetBoolean("editable_user", editable_user);
args.SetBoolean("editableUser", editable_user);
if (!error_message.empty())
args.SetString("error_message", error_message);
args.SetString("errorMessage", error_message);
if (fatal_error)
args.SetBoolean("fatalError", true);
args.SetString("captchaUrl", captcha);
......
......@@ -87,15 +87,15 @@ std::string GetConfiguration(const DictionaryValue* extra_values,
if (!passphrase.empty())
result.SetString("passphrase", passphrase);
// Add all of our data types.
result.SetBoolean("sync_apps", types.Has(syncable::APPS));
result.SetBoolean("sync_autofill", types.Has(syncable::AUTOFILL));
result.SetBoolean("sync_bookmarks", types.Has(syncable::BOOKMARKS));
result.SetBoolean("sync_extensions", types.Has(syncable::EXTENSIONS));
result.SetBoolean("sync_passwords", types.Has(syncable::PASSWORDS));
result.SetBoolean("sync_preferences", types.Has(syncable::PREFERENCES));
result.SetBoolean("sync_sessions", types.Has(syncable::SESSIONS));
result.SetBoolean("sync_themes", types.Has(syncable::THEMES));
result.SetBoolean("sync_typed_urls", types.Has(syncable::TYPED_URLS));
result.SetBoolean("appsSynced", types.Has(syncable::APPS));
result.SetBoolean("autofillSynced", types.Has(syncable::AUTOFILL));
result.SetBoolean("bookmarksSynced", types.Has(syncable::BOOKMARKS));
result.SetBoolean("extensionsSynced", types.Has(syncable::EXTENSIONS));
result.SetBoolean("passwordsSynced", types.Has(syncable::PASSWORDS));
result.SetBoolean("preferencesSynced", types.Has(syncable::PREFERENCES));
result.SetBoolean("sessionsSynced", types.Has(syncable::SESSIONS));
result.SetBoolean("themesSynced", types.Has(syncable::THEMES));
result.SetBoolean("typedUrlsSynced", types.Has(syncable::TYPED_URLS));
std::string args;
base::JSONWriter::Write(&result, &args);
return args;
......@@ -171,12 +171,12 @@ void CheckShowSyncSetupArgs(const DictionaryValue* dictionary,
//
// The code below validates these arguments.
CheckString(dictionary, "error_message", error_message, true);
CheckString(dictionary, "errorMessage", error_message, true);
CheckString(dictionary, "user", user, false);
CheckString(dictionary, "captchaUrl", captcha_url, false);
CheckInt(dictionary, "error", error);
CheckBool(dictionary, "fatalError", fatal_error, true);
CheckBool(dictionary, "editable_user", user_is_editable);
CheckBool(dictionary, "editableUser", user_is_editable);
}
// Checks to make sure that the values stored in |dictionary| match the values
......@@ -186,15 +186,15 @@ void CheckConfigDataTypeArguments(DictionaryValue* dictionary,
SyncAllDataConfig config,
syncable::ModelTypeSet types) {
CheckBool(dictionary, "syncAllDataTypes", config == SYNC_ALL_DATA);
CheckBool(dictionary, "sync_apps", types.Has(syncable::APPS));
CheckBool(dictionary, "sync_autofill", types.Has(syncable::AUTOFILL));
CheckBool(dictionary, "sync_bookmarks", types.Has(syncable::BOOKMARKS));
CheckBool(dictionary, "sync_extensions", types.Has(syncable::EXTENSIONS));
CheckBool(dictionary, "sync_passwords", types.Has(syncable::PASSWORDS));
CheckBool(dictionary, "sync_preferences", types.Has(syncable::PREFERENCES));
CheckBool(dictionary, "sync_sessions", types.Has(syncable::SESSIONS));
CheckBool(dictionary, "sync_themes", types.Has(syncable::THEMES));
CheckBool(dictionary, "sync_typed_urls", types.Has(syncable::TYPED_URLS));
CheckBool(dictionary, "appsSynced", types.Has(syncable::APPS));
CheckBool(dictionary, "autofillSynced", types.Has(syncable::AUTOFILL));
CheckBool(dictionary, "bookmarksSynced", types.Has(syncable::BOOKMARKS));
CheckBool(dictionary, "extensionsSynced", types.Has(syncable::EXTENSIONS));
CheckBool(dictionary, "passwordsSynced", types.Has(syncable::PASSWORDS));
CheckBool(dictionary, "preferencesSynced", types.Has(syncable::PREFERENCES));
CheckBool(dictionary, "sessionsSynced", types.Has(syncable::SESSIONS));
CheckBool(dictionary, "themesSynced", types.Has(syncable::THEMES));
CheckBool(dictionary, "typedUrlsSynced", types.Has(syncable::TYPED_URLS));
}
......@@ -649,7 +649,7 @@ TEST_F(SyncSetupHandlerTest, SuccessfullySetPassphrase) {
std::string args = GetConfiguration(&dict,
SYNC_ALL_DATA,
GetAllTypes(),
"gaia_passphrase",
"gaiaPassphrase",
ENCRYPT_PASSWORDS);
ListValue list_args;
list_args.Append(new StringValue(args));
......@@ -662,7 +662,7 @@ TEST_F(SyncSetupHandlerTest, SuccessfullySetPassphrase) {
.WillRepeatedly(Return(false));
SetupInitializedProfileSyncService();
EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _));
EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("gaia_passphrase")).
EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("gaiaPassphrase")).
WillOnce(Return(true));
handler_->HandleConfigure(&list_args);
......@@ -729,7 +729,7 @@ TEST_F(SyncSetupHandlerTest, UnsuccessfullySetPassphrase) {
const TestWebUI::CallData& data = web_ui_.call_data()[0];
DictionaryValue* dictionary;
ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary));
CheckBool(dictionary, "passphrase_failed", true);
CheckBool(dictionary, "passphraseFailed", true);
}
// Walks through each user selectable type, and tries to sync just that single
......@@ -841,18 +841,18 @@ TEST_F(SyncSetupHandlerTest, ShowSetupSyncEverything) {
ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary));
CheckBool(dictionary, "showSyncEverythingPage", false);
CheckBool(dictionary, "syncAllDataTypes", true);
CheckBool(dictionary, "apps_registered", true);
CheckBool(dictionary, "autofill_registered", true);
CheckBool(dictionary, "bookmarks_registered", true);
CheckBool(dictionary, "extensions_registered", true);
CheckBool(dictionary, "passwords_registered", true);
CheckBool(dictionary, "preferences_registered", true);
CheckBool(dictionary, "sessions_registered", true);
CheckBool(dictionary, "themes_registered", true);
CheckBool(dictionary, "typed_urls_registered", true);
CheckBool(dictionary, "show_passphrase", false);
CheckBool(dictionary, "appsRegistered", true);
CheckBool(dictionary, "autofillRegistered", true);
CheckBool(dictionary, "bookmarksRegistered", true);
CheckBool(dictionary, "extensionsRegistered", true);
CheckBool(dictionary, "passwordsRegistered", true);
CheckBool(dictionary, "preferencesRegistered", true);
CheckBool(dictionary, "sessionsRegistered", true);
CheckBool(dictionary, "themesRegistered", true);
CheckBool(dictionary, "typedUrlsRegistered", true);
CheckBool(dictionary, "showPassphrase", false);
CheckBool(dictionary, "usePassphrase", false);
CheckBool(dictionary, "passphrase_failed", false);
CheckBool(dictionary, "passphraseFailed", false);
CheckBool(dictionary, "encryptAllData", false);
CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes());
}
......@@ -923,9 +923,9 @@ TEST_F(SyncSetupHandlerTest, ShowSetupGaiaPassphraseRequired) {
const TestWebUI::CallData& data = web_ui_.call_data()[0];
DictionaryValue* dictionary;
ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary));
CheckBool(dictionary, "show_passphrase", true);
CheckBool(dictionary, "showPassphrase", true);
CheckBool(dictionary, "usePassphrase", false);
CheckBool(dictionary, "passphrase_failed", false);
CheckBool(dictionary, "passphraseFailed", false);
}
TEST_F(SyncSetupHandlerTest, ShowSetupCustomPassphraseRequired) {
......@@ -943,9 +943,9 @@ TEST_F(SyncSetupHandlerTest, ShowSetupCustomPassphraseRequired) {
const TestWebUI::CallData& data = web_ui_.call_data()[0];
DictionaryValue* dictionary;
ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary));
CheckBool(dictionary, "show_passphrase", true);
CheckBool(dictionary, "showPassphrase", true);
CheckBool(dictionary, "usePassphrase", true);
CheckBool(dictionary, "passphrase_failed", false);
CheckBool(dictionary, "passphraseFailed", false);
}
TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAll) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment