From 0f3db35be89698ea3f6affd469ec372dbf1fe23b Mon Sep 17 00:00:00 2001 From: "csilv@chromium.org" Date: Mon, 23 Aug 2010 19:36:04 +0000 Subject: dom-ui options: record user metrics for pref changes. BUG=52520 TEST=Verify metrics are saved when changing options in dom-ui options window (--enable-tabbed-options). Review URL: http://codereview.chromium.org/3190004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57093 0039d316-1c4b-4281-b951-d872f2087c98 --- .../dom_ui/core_chromeos_options_handler.cc | 9 ++++- .../dom_ui/core_chromeos_options_handler.h | 3 +- chrome/browser/dom_ui/advanced_options_handler.cc | 12 ++++++ chrome/browser/dom_ui/browser_options_handler.cc | 6 +++ chrome/browser/dom_ui/core_options_handler.cc | 42 ++++++++++++++++---- chrome/browser/dom_ui/core_options_handler.h | 12 +++++- .../resources/options/advanced_options.html | 43 ++++++++++++--------- .../browser/resources/options/advanced_options.js | 6 +++ .../resources/options/autofill_options.html | 3 +- .../browser/resources/options/browser_options.html | 30 +++++++++------ .../browser/resources/options/browser_options.js | 2 + .../browser/resources/options/content_settings.js | 1 + .../resources/options/font_settings_overlay.html | 21 ++++++---- .../resources/options/personal_options.html | 8 ++-- .../browser/resources/options/personal_options.js | 5 +++ chrome/browser/resources/options/pref_ui.js | 45 ++++++++++++++++++---- chrome/browser/resources/options/preferences.js | 28 ++++++++++---- 17 files changed, 206 insertions(+), 70 deletions(-) (limited to 'chrome') diff --git a/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.cc b/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.cc index 4f66cd7..a8355cd 100644 --- a/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.cc +++ b/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.cc @@ -7,6 +7,7 @@ #include "base/json/json_reader.h" #include "base/string_number_conversions.h" #include "chrome/browser/chromeos/cros_settings.h" +#include "chrome/browser/metrics/user_metrics.h" #include "chrome/common/notification_service.h" namespace chromeos { @@ -30,9 +31,11 @@ void CoreChromeOSOptionsHandler::ObservePref(const std::string& pref_name) { void CoreChromeOSOptionsHandler::SetPref(const std::string& pref_name, Value::ValueType pref_type, - const std::string& value_string) { + const std::string& value_string, + const std::string& metric) { if (!CrosSettings::IsCrosSettings(pref_name)) - return ::CoreOptionsHandler::SetPref(pref_name, pref_type, value_string); + return ::CoreOptionsHandler::SetPref(pref_name, pref_type, value_string, + metric); CrosSettings* cros_settings = CrosSettings::Get(); switch (pref_type) { @@ -57,6 +60,8 @@ void CoreChromeOSOptionsHandler::SetPref(const std::string& pref_name, break; } } + + ProcessUserMetric(pref_type, value_string, metric); } void CoreChromeOSOptionsHandler::Observe(NotificationType type, diff --git a/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.h b/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.h index 80acdd3..aa58c29 100644 --- a/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.h +++ b/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.h @@ -20,7 +20,8 @@ class CoreChromeOSOptionsHandler : public ::CoreOptionsHandler { virtual void ObservePref(const std::string& pref_name); virtual void SetPref(const std::string& pref_name, Value::ValueType pref_type, - const std::string& value_string); + const std::string& value_string, + const std::string& metric); // NotificationObserver implementation. virtual void Observe(NotificationType type, diff --git a/chrome/browser/dom_ui/advanced_options_handler.cc b/chrome/browser/dom_ui/advanced_options_handler.cc index 21095e7..d23dfeb 100644 --- a/chrome/browser/dom_ui/advanced_options_handler.cc +++ b/chrome/browser/dom_ui/advanced_options_handler.cc @@ -218,11 +218,15 @@ void AdvancedOptionsHandler::HandleSelectDownloadLocation( void AdvancedOptionsHandler::FileSelected(const FilePath& path, int index, void* params) { + UserMetricsRecordAction(UserMetricsAction("Options_SetDownloadDirectory"), + NULL); default_download_location_.SetValue(path); SetupDownloadLocationPath(); } void AdvancedOptionsHandler::HandleAutoOpenButton(const ListValue* args) { + UserMetricsRecordAction(UserMetricsAction("Options_ResetAutoOpenFiles"), + NULL); DCHECK(dom_ui_); DownloadManager* manager = dom_ui_->GetProfile()->GetDownloadManager(); if (manager) manager->ResetAutoOpenFiles(); @@ -231,12 +235,20 @@ void AdvancedOptionsHandler::HandleAutoOpenButton(const ListValue* args) { #if defined(OS_WIN) void AdvancedOptionsHandler::HandleCheckRevocationCheckbox( const ListValue* args) { + UserMetricsRecordAction(UserMetricsAction(metric.c_str()), NULL); std::string checked_str = WideToUTF8(ExtractStringValue(args)); + std::string metric = + (checked_str == "true" ? "Options_CheckCertRevocation_Enable" + : "Options_CheckCertRevocation_Disable"); net::SSLConfigServiceWin::SetRevCheckingEnabled(checked_str == "true"); } void AdvancedOptionsHandler::HandleUseSSL2Checkbox(const ListValue* args) { + UserMetricsRecordAction(UserMetricsAction(metric.c_str()), NULL); std::string checked_str = WideToUTF8(ExtractStringValue(args)); + std::string metric = + (checked_str == "true" ? "Options_SSL2_Enable" + : "Options_SSL2_Disable"); net::SSLConfigServiceWin::SetSSL2Enabled(checked_str == "true"); } diff --git a/chrome/browser/dom_ui/browser_options_handler.cc b/chrome/browser/dom_ui/browser_options_handler.cc index bcad24b..1405d1e 100644 --- a/chrome/browser/dom_ui/browser_options_handler.cc +++ b/chrome/browser/dom_ui/browser_options_handler.cc @@ -15,6 +15,7 @@ #include "chrome/browser/custom_home_pages_table_model.h" #include "chrome/browser/dom_ui/dom_ui_favicon_source.h" #include "chrome/browser/dom_ui/options_managed_banner_handler.h" +#include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/profile.h" #include "chrome/browser/options_window.h" @@ -139,6 +140,8 @@ void BrowserOptionsHandler::UpdateDefaultBrowserState() { } void BrowserOptionsHandler::BecomeDefaultBrowser(const ListValue* args) { + UserMetricsRecordAction(UserMetricsAction("Options_SetAsDefaultBrowser"), + NULL); #if defined(OS_MACOSX) if (ShellIntegration::SetAsDefaultBrowser()) UpdateDefaultBrowserState(); @@ -226,6 +229,9 @@ void BrowserOptionsHandler::SetDefaultSearchEngine(const ListValue* args) { if (selected_index >= 0 && selected_index < static_cast(model_urls.size())) template_url_model_->SetDefaultSearchProvider(model_urls[selected_index]); + + UserMetricsRecordAction(UserMetricsAction("Options_SearchEngineChanged"), + NULL); } void BrowserOptionsHandler::UpdateSearchEngines() { diff --git a/chrome/browser/dom_ui/core_options_handler.cc b/chrome/browser/dom_ui/core_options_handler.cc index 9137326..37171cf 100644 --- a/chrome/browser/dom_ui/core_options_handler.cc +++ b/chrome/browser/dom_ui/core_options_handler.cc @@ -9,10 +9,11 @@ #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "base/values.h" -#include "chrome/common/notification_service.h" -#include "chrome/common/notification_type.h" +#include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/pref_service.h" #include "chrome/browser/profile.h" +#include "chrome/common/notification_service.h" +#include "chrome/common/notification_type.h" #include "grit/browser_resources.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" @@ -110,6 +111,8 @@ void CoreOptionsHandler::RegisterMessages() { NewCallback(this, &CoreOptionsHandler::HandleSetStringPref)); dom_ui_->RegisterMessageCallback("setObjectPref", NewCallback(this, &CoreOptionsHandler::HandleSetObjectPref)); + dom_ui_->RegisterMessageCallback("coreOptionsUserMetricsAction", + NewCallback(this, &CoreOptionsHandler::HandleUserMetricsAction)); } void CoreOptionsHandler::HandleInitialize(const ListValue* args) { @@ -143,7 +146,8 @@ void CoreOptionsHandler::ObservePref(const std::string& pref_name) { void CoreOptionsHandler::SetPref(const std::string& pref_name, Value::ValueType pref_type, - const std::string& value_string) { + const std::string& value_string, + const std::string& metric) { DCHECK(dom_ui_); PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs(); @@ -162,6 +166,22 @@ void CoreOptionsHandler::SetPref(const std::string& pref_name, default: NOTREACHED(); } + + ProcessUserMetric(pref_type, value_string, metric); +} + +void CoreOptionsHandler::ProcessUserMetric(Value::ValueType pref_type, + const std::string& value_string, + const std::string& metric) { + if (metric.empty()) + return; + + std::string metric_string = metric; + if (pref_type == Value::TYPE_BOOLEAN) + metric_string += (value_string == "true" ? "_Enable" : "_Disable"); + + UserMetricsRecordAction(UserMetricsAction(metric_string.c_str()), + dom_ui_->GetProfile()->GetPrefs()); } void CoreOptionsHandler::HandleFetchPrefs(const ListValue* args) { @@ -202,8 +222,6 @@ void CoreOptionsHandler::HandleFetchPrefs(const ListValue* args) { } void CoreOptionsHandler::HandleObservePrefs(const ListValue* args) { - DictionaryValue result_value; - // First param is name is JS callback function name, the rest are pref // identifiers that we are observing. const size_t kMinObservePrefsParamCount = 2; @@ -254,7 +272,7 @@ void CoreOptionsHandler::HandleSetObjectPref(const ListValue* args) { void CoreOptionsHandler::HandleSetPref(const ListValue* args, Value::ValueType type) { - if (args->GetSize() != 2) + if (args->GetSize() < 2) return; std::string pref_name; @@ -265,7 +283,17 @@ void CoreOptionsHandler::HandleSetPref(const ListValue* args, if (!args->GetString(1, &value_string)) return; - SetPref(pref_name, type, value_string); + std::string metric; + if (args->GetSize() > 2) + args->GetString(2, &metric); + + SetPref(pref_name, type, value_string, metric); +} + +void CoreOptionsHandler::HandleUserMetricsAction(const ListValue* args) { + std::string metric = WideToUTF8(ExtractStringValue(args)); + if (!metric.empty()) + UserMetricsRecordAction(UserMetricsAction(metric.c_str()), NULL); } void CoreOptionsHandler::NotifyPrefChanged(const std::string* pref_name) { diff --git a/chrome/browser/dom_ui/core_options_handler.h b/chrome/browser/dom_ui/core_options_handler.h index 4a51cad..9eaf44a 100644 --- a/chrome/browser/dom_ui/core_options_handler.h +++ b/chrome/browser/dom_ui/core_options_handler.h @@ -41,7 +41,13 @@ class CoreOptionsHandler : public OptionsPageUIHandler { // Sets a pref value |value_string| of |pref_type| to given |pref_name|. virtual void SetPref(const std::string& pref_name, Value::ValueType pref_type, - const std::string& value_string); + const std::string& value_string, + const std::string& metric); + + // Records a user metric action for the given value. + void ProcessUserMetric(Value::ValueType pref_type, + const std::string& value_string, + const std::string& metric); typedef std::multimap PreferenceCallbackMap; PreferenceCallbackMap pref_callback_map_; @@ -71,6 +77,10 @@ class CoreOptionsHandler : public OptionsPageUIHandler { void HandleSetPref(const ListValue* args, Value::ValueType type); + // Callback for the "coreOptionsUserMetricsAction" message. This records + // an action that should be tracked if metrics recording is enabled. + void HandleUserMetricsAction(const ListValue* args); + void NotifyPrefChanged(const std::string* pref_name); DISALLOW_COPY_AND_ASSIGN(CoreOptionsHandler); diff --git a/chrome/browser/resources/options/advanced_options.html b/chrome/browser/resources/options/advanced_options.html index c76b52e..de1cbeb 100644 --- a/chrome/browser/resources/options/advanced_options.html +++ b/chrome/browser/resources/options/advanced_options.html @@ -13,21 +13,24 @@
+ pref="search.suggest_enabled" metric="Options_UseSuggestCheckbox" + type="checkbox"> + pref="dns_prefetching.enabled" metric="Options_DnsPrefetchCheckbox" + type="checkbox"> + pref="safebrowsing.enabled" metric="Options_SafeBrowsingCheckbox" + type="checkbox"> + @@ -44,8 +47,8 @@

+ pref="translate.enabled" metric="Options_Translate" type="checkbox"> +
@@ -59,7 +62,8 @@ i18n-content="downloadLocationBrowseButton">
@@ -72,8 +76,8 @@
+ pref="webkit.webprefs.tabs_to_links" metric="Options_TabsToLinks" + type="checkbox">
@@ -108,16 +112,17 @@ + pref="ssl.rev_checking.enabled" metric="Options_CheckCertRevocation" + type="checkbox"> + diff --git a/chrome/browser/resources/options/advanced_options.js b/chrome/browser/resources/options/advanced_options.js index 57ef20f..d03e26e 100644 --- a/chrome/browser/resources/options/advanced_options.js +++ b/chrome/browser/resources/options/advanced_options.js @@ -30,15 +30,19 @@ var OptionsPage = options.OptionsPage; $('privacyContentSettingsButton').onclick = function(event) { OptionsPage.showPageByName('content'); OptionsPage.showTab($('cookies-nav-tab')); + chrome.send('coreOptionsUserMetricsAction', + ['Options_ContentSettings']); }; $('privacyClearDataButton').onclick = function(event) { OptionsPage.showOverlay('clearBrowserDataOverlay'); + chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']); }; $('autoOpenFileTypesResetToDefault').onclick = function(event) { chrome.send('autoOpenFileTypesAction'); }; $('fontSettingsConfigureFontsOnlyButton').onclick = function(event) { OptionsPage.showOverlay('fontSettingsOverlay'); + chrome.send('coreOptionsUserMetricsAction', ['Options_FontSettings']); }; if (!cr.isChromeOS) { @@ -61,6 +65,8 @@ var OptionsPage = options.OptionsPage; } else { $('proxiesConfigureButton').onclick = function(event) { OptionsPage.showPageByName('proxy'); + chrome.send('coreOptionsUserMetricsAction', + ['Options_ShowProxySettings']); }; } diff --git a/chrome/browser/resources/options/autofill_options.html b/chrome/browser/resources/options/autofill_options.html index ccd4f88..46b1601 100644 --- a/chrome/browser/resources/options/autofill_options.html +++ b/chrome/browser/resources/options/autofill_options.html @@ -6,7 +6,8 @@
-
diff --git a/chrome/browser/resources/options/browser_options.html b/chrome/browser/resources/options/browser_options.html index d9ae42a..3e9a9c5 100644 --- a/chrome/browser/resources/options/browser_options.html +++ b/chrome/browser/resources/options/browser_options.html @@ -4,14 +4,17 @@

+ pref="session.restore_on_startup" value="0" + metric="Options_Startup_Homepage"> + + pref="session.restore_on_startup" value="1" + metric="Options_Startup_LastSession"> + + pref="session.restore_on_startup" value="4" + metric="Options_Startup_Custom"> +
@@ -33,18 +36,21 @@

+ pref="homepage_is_newtabpage" value="true" + metric="Options_Homepage_IsNewTabPage"> + + pref="homepage_is_newtabpage" value="false" + metric="Options_Homepage_IsNewTabPage"> +
+ pref="browser.show_home_button" + metric="Options_Homepage_HomeButton" type="checkbox"> +
diff --git a/chrome/browser/resources/options/browser_options.js b/chrome/browser/resources/options/browser_options.js index d4f725d..71465c1 100644 --- a/chrome/browser/resources/options/browser_options.js +++ b/chrome/browser/resources/options/browser_options.js @@ -39,6 +39,8 @@ cr.define('options', function() { }; $('defaultSearchManageEnginesButton').onclick = function(event) { OptionsPage.showPageByName('searchEngines'); + chrome.send('coreOptionsUserMetricsAction', + ['Options_ManageSearchEngines']); }; if (!cr.isChromeOS) { $('defaultBrowserUseAsDefaultButton').onclick = function(event) { diff --git a/chrome/browser/resources/options/content_settings.js b/chrome/browser/resources/options/content_settings.js index 5756ce9..38bd04a 100644 --- a/chrome/browser/resources/options/content_settings.js +++ b/chrome/browser/resources/options/content_settings.js @@ -55,6 +55,7 @@ cr.define('options', function() { }; $('show-cookies-button').onclick = function(event) { + chrome.send('coreOptionsUserMetricsAction', ['Options_ShowCookies']); // TODO(estade): show cookies and other site data page. }; }, diff --git a/chrome/browser/resources/options/font_settings_overlay.html b/chrome/browser/resources/options/font_settings_overlay.html index 4a6757c..1efed64 100644 --- a/chrome/browser/resources/options/font_settings_overlay.html +++ b/chrome/browser/resources/options/font_settings_overlay.html @@ -7,12 +7,14 @@
@@ -20,12 +22,14 @@
@@ -33,12 +37,14 @@
@@ -50,7 +56,8 @@ diff --git a/chrome/browser/resources/options/personal_options.html b/chrome/browser/resources/options/personal_options.html index a90cb50..879f14e 100644 --- a/chrome/browser/resources/options/personal_options.html +++ b/chrome/browser/resources/options/personal_options.html @@ -29,14 +29,14 @@ + type="radio" value="true" metric="Options_PasswordManager">
diff --git a/chrome/browser/resources/options/personal_options.js b/chrome/browser/resources/options/personal_options.js index 4ffd2b9..7b9f170 100644 --- a/chrome/browser/resources/options/personal_options.js +++ b/chrome/browser/resources/options/personal_options.js @@ -50,10 +50,14 @@ cr.define('options', function() { PasswordsExceptions.load(); OptionsPage.showPageByName('passwordsExceptions'); OptionsPage.showTab($('passwords-nav-tab')); + chrome.send('coreOptionsUserMetricsAction', + ['Options_ShowPasswordsExceptions']); }; $('autofill_options').onclick = function(event) { OptionsPage.showPageByName('autoFillOptions'); + chrome.send('coreOptionsUserMetricsAction', + ['Options_ShowAutoFillSettings']); }; if (!cr.isChromeOS) { @@ -63,6 +67,7 @@ cr.define('options', function() { $('import_data').onclick = function(event) { ImportDataOverlay.loadImporter(); OptionsPage.showOverlay('importDataOverlay'); + chrome.send('coreOptionsUserMetricsAction', ['Import_ShowDlg']); }; } diff --git a/chrome/browser/resources/options/pref_ui.js b/chrome/browser/resources/options/pref_ui.js index a09e737e..ffc7ae7 100644 --- a/chrome/browser/resources/options/pref_ui.js +++ b/chrome/browser/resources/options/pref_ui.js @@ -33,7 +33,7 @@ cr.define('options', function() { // Listen to user events. this.addEventListener('click', function(e) { - Preferences.setBooleanPref(self.pref, self.checked); + Preferences.setBooleanPref(self.pref, self.checked, self.metric); }); } }; @@ -44,6 +44,12 @@ cr.define('options', function() { */ cr.defineProperty(PrefCheckbox, 'pref', cr.PropertyKind.ATTR); + /** + * The user metric string. + * @type {string} + */ + cr.defineProperty(PrefCheckbox, 'metric', cr.PropertyKind.ATTR); + ///////////////////////////////////////////////////////////////////////////// // PrefRadio class: @@ -74,10 +80,10 @@ cr.define('options', function() { function(e) { if(self.value == 'true' || self.value == 'false') { Preferences.setBooleanPref(self.pref, - self.value == 'true'); + self.value == 'true', self.metric); } else { Preferences.setIntegerPref(self.pref, - parseInt(self.value, 10)); + parseInt(self.value, 10), self.metric); } }); }, @@ -97,6 +103,11 @@ cr.define('options', function() { } }; + /** + * The user metric string. + * @type {string} + */ + cr.defineProperty(PrefRadio, 'metric', cr.PropertyKind.ATTR); ///////////////////////////////////////////////////////////////////////////// // PrefNumeric class: @@ -124,7 +135,7 @@ cr.define('options', function() { // Listen to user events. this.addEventListener('change', function(e) { - Preferences.setIntegerPref(self.pref, self.value); + Preferences.setIntegerPref(self.pref, self.value, self.metric); }); } }; @@ -135,6 +146,12 @@ cr.define('options', function() { */ cr.defineProperty(PrefNumeric, 'pref', cr.PropertyKind.ATTR); + /** + * The user metric string. + * @type {string} + */ + cr.defineProperty(PrefNumeric, 'metric', cr.PropertyKind.ATTR); + ///////////////////////////////////////////////////////////////////////////// // PrefNumber class: @@ -209,15 +226,15 @@ cr.define('options', function() { switch(self.dataType) { case 'number': Preferences.setIntegerPref(self.pref, - self.options[self.selectedIndex].value); + self.options[self.selectedIndex].value, self.metric); break; case 'boolean': Preferences.setBooleanValue(self.pref, - self.options[self.selectedIndex].value); + self.options[self.selectedIndex].value, self.metric); break; case 'string': Preferences.setStringPref(self.pref, - self.options[self.selectedIndex].value); + self.options[self.selectedIndex].value, self.metric); break; } }); @@ -255,6 +272,12 @@ cr.define('options', function() { */ cr.defineProperty(PrefSelect, 'pref', cr.PropertyKind.ATTR); + /** + * The user metric string. + * @type {string} + */ + cr.defineProperty(PrefSelect, 'metric', cr.PropertyKind.ATTR); + ///////////////////////////////////////////////////////////////////////////// // PrefTextField class: @@ -282,7 +305,7 @@ cr.define('options', function() { // Listen to user events. this.addEventListener('change', function(e) { - Preferences.setStringPref(self.pref, self.value); + Preferences.setStringPref(self.pref, self.value, self.metric); }); window.addEventListener('unload', @@ -299,6 +322,12 @@ cr.define('options', function() { */ cr.defineProperty(PrefTextField, 'pref', cr.PropertyKind.ATTR); + /** + * The user metric string. + * @type {string} + */ + cr.defineProperty(PrefTextField, 'metric', cr.PropertyKind.ATTR); + // Export return { PrefCheckbox: PrefCheckbox, diff --git a/chrome/browser/resources/options/preferences.js b/chrome/browser/resources/options/preferences.js index 72d1a09..b641f37 100644 --- a/chrome/browser/resources/options/preferences.js +++ b/chrome/browser/resources/options/preferences.js @@ -41,9 +41,12 @@ cr.define('options', function() { * and signals its changed value. * @param {string} name Preference name. * @param {boolean} value New preference value. + * @param {string} metric User metrics identifier. */ - Preferences.setBooleanPref = function (name, value) { - chrome.send('setBooleanPref', [name, value ? 'true' : 'false']); + Preferences.setBooleanPref = function (name, value, metric) { + var arguments = [name, value ? 'true' : 'false']; + if (metric != undefined) arguments.push(metric); + chrome.send('setBooleanPref', arguments); }; /** @@ -51,9 +54,12 @@ cr.define('options', function() { * and signals its changed value. * @param {string} name Preference name. * @param {number} value New preference value. + * @param {string} metric User metrics identifier. */ - Preferences.setIntegerPref = function(name, value) { - chrome.send('setIntegerPref', [name, String(value)]); + Preferences.setIntegerPref = function(name, value, metric) { + var arguments = [name, String(value)]; + if (metric != undefined) arguments.push(metric); + chrome.send('setIntegerPref', arguments); }; /** @@ -61,9 +67,12 @@ cr.define('options', function() { * and signals its changed value. * @param {string} name Preference name. * @param {string} value New preference value. + * @param {string} metric User metrics identifier. */ - Preferences.setStringPref = function(name, value) { - chrome.send('setStringPref', [name, value]); + Preferences.setStringPref = function(name, value, metric) { + var arguments = [name, value]; + if (metric != undefined) arguments.push(metric); + chrome.send('setStringPref', arguments); }; /** @@ -71,9 +80,12 @@ cr.define('options', function() { * and signals its changed value. * @param {string} name Preference name. * @param {string} value New preference value. + * @param {string} metric User metrics identifier. */ - Preferences.setObjectPref = function(name, value) { - chrome.send('setObjectPref', [name, JSON.stringify(value)]); + Preferences.setObjectPref = function(name, value, metric) { + var arguments = [name, JSON.stringify(value)]; + if (metric != undefined) arguments.push(metric); + chrome.send('setObjectPref', arguments); }; Preferences.prototype = { -- cgit v1.1