Commit 86eed02d authored by Sonny Sasaka's avatar Sonny Sasaka Committed by Commit Bot

settings: Disallow non-primary users to change Bluetooth settings

Since Bluetooth power preference became user-specific, we disallowed
non-primary users to change Bluetooth power setting for UX consistency
with system tray.

Bug: 853374
Change-Id: If61d2c0c048e7d8c764e24798da0ebbf2ab6c68f
Reviewed-on: https://chromium-review.googlesource.com/1187601
Commit-Queue: Sonny Sasaka <sonnysasaka@chromium.org>
Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586088}
parent a14ec485
...@@ -937,6 +937,9 @@ ...@@ -937,6 +937,9 @@
<message name="IDS_SETTINGS_BLUETOOTH_CONNECT_WRITE_NOT_PERMITTED"> <message name="IDS_SETTINGS_BLUETOOTH_CONNECT_WRITE_NOT_PERMITTED">
Write operation is not permitted on: "<ph name="DEVICE_NAME">$1<ex>Nexus 4</ex></ph>". Write operation is not permitted on: "<ph name="DEVICE_NAME">$1<ex>Nexus 4</ex></ph>".
</message> </message>
<message name="IDS_SETTINGS_BLUETOOTH_PRIMARY_USER_CONTROLLED" desc="Settings > Bluetooth > Text to show when Bluetooth configuration is controlled by the primary user.">
Bluetooth configuration is controlled by <ph name="USER_EMAIL">$1<ex>joe@gmail.com</ex></ph>.
</message>
</if> </if>
<if expr="use_nss_certs"> <if expr="use_nss_certs">
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html"> <link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html"> <link rel="import" href="chrome://resources/cr_elements/icons.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_pref_indicator.html"> <link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_pref_indicator.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/neon-animation/neon-animatable.html"> <link rel="import" href="chrome://resources/polymer/v1_0/neon-animation/neon-animatable.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html">
<link rel="import" href="../i18n_setup.html"> <link rel="import" href="../i18n_setup.html">
...@@ -21,36 +22,47 @@ ...@@ -21,36 +22,47 @@
<settings-animated-pages id="pages" section="bluetooth" <settings-animated-pages id="pages" section="bluetooth"
focus-config="[[focusConfig_]]"> focus-config="[[focusConfig_]]">
<neon-animatable route-path="default"> <neon-animatable route-path="default">
<div id="bluetoothDevices" <template is="dom-if" if="[[!isSecondaryUser_]]">
class="settings-box two-line" actionable on-click="onTap_"> <div id="bluetoothDevices"
<iron-icon icon="[[getIcon_(bluetoothToggleState_)]]"></iron-icon> class="settings-box two-line" actionable on-click="onTap_">
<div class="middle"> <iron-icon icon="[[getIcon_(bluetoothToggleState_)]]"></iron-icon>
$i18n{bluetoothPageTitle} <div class="middle">
<div class="secondary" id="bluetoothSecondary"> $i18n{bluetoothPageTitle}
[[getOnOffString_(bluetoothToggleState_, <div class="secondary" id="bluetoothSecondary">
'$i18nPolymer{deviceOn}', '$i18nPolymer{deviceOff}')]] [[getOnOffString_(bluetoothToggleState_,
'$i18nPolymer{deviceOn}', '$i18nPolymer{deviceOff}')]]
</div>
</div> </div>
<cr-policy-pref-indicator
icon-aria-label="$i18n{bluetoothPageTitle}"
pref="[[prefs.cros.device.allow_bluetooth]]"
hidden="[[prefs.cros.device.allow_bluetooth.value]]">
</cr-policy-pref-indicator>
<template is="dom-if" if="[[bluetoothToggleState_]]">
<paper-icon-button-light class="subpage-arrow">
<button on-click="onSubpageArrowTap_"
aria-label="$i18n{bluetoothPageTitle}"
aria-describedby="bluetoothSecondary">
</button>
</paper-icon-button-light>
</template>
<div class="separator"></div>
<cr-toggle id="enableBluetooth"
checked="{{bluetoothToggleState_}}"
disabled$="[[!isToggleEnabled_(
adapterState_, stateChangeInProgress_)]]"
aria-label="$i18n{bluetoothToggleA11yLabel}">
</cr-toggle>
</div> </div>
<cr-policy-pref-indicator icon-aria-label="$i18n{bluetoothPageTitle}" </template>
pref="[[prefs.cros.device.allow_bluetooth]]" <template is="dom-if" if="[[isSecondaryUser_]]">
hidden="[[prefs.cros.device.allow_bluetooth.value]]"> <div id="bluetoothDevices" class="settings-box two-line">
</cr-policy-pref-indicator> <iron-icon class="policy" icon="cr:group"></iron-icon>
<template is="dom-if" if="[[bluetoothToggleState_]]"> <div class="middle">
<paper-icon-button-light class="subpage-arrow"> [[i18n('bluetoothPrimaryUserControlled', primaryUserEmail_)]]
<button on-click="onSubpageArrowTap_" </div>
aria-label="$i18n{bluetoothPageTitle}" </div>
aria-describedby="bluetoothSecondary"> </template>
</button>
</paper-icon-button-light>
</template>
<div class="separator"></div>
<cr-toggle id="enableBluetooth"
checked="{{bluetoothToggleState_}}"
disabled$=
"[[!isToggleEnabled_(adapterState_, stateChangeInProgress_)]]"
aria-label="$i18n{bluetoothToggleA11yLabel}">
</cr-toggle>
</div>
</neon-animatable> </neon-animatable>
<template is="dom-if" route-path="/bluetoothDevices"> <template is="dom-if" route-path="/bluetoothDevices">
......
...@@ -25,7 +25,7 @@ const bluetoothApis = window['bluetoothApis'] || { ...@@ -25,7 +25,7 @@ const bluetoothApis = window['bluetoothApis'] || {
Polymer({ Polymer({
is: 'settings-bluetooth-page', is: 'settings-bluetooth-page',
behaviors: [PrefsBehavior], behaviors: [I18nBehavior, PrefsBehavior],
properties: { properties: {
/** Preferences state. */ /** Preferences state. */
...@@ -99,6 +99,30 @@ Polymer({ ...@@ -99,6 +99,30 @@ Polymer({
type: Object, type: Object,
value: chrome.bluetoothPrivate, value: chrome.bluetoothPrivate,
}, },
/**
* Whether the user is a secondary user.
* @private
*/
isSecondaryUser_: {
type: Boolean,
value: function() {
return loadTimeData.getBoolean('isSecondaryUser');
},
readOnly: true,
},
/**
* Email address for the primary user.
* @private
*/
primaryUserEmail_: {
type: String,
value: function() {
return loadTimeData.getString('primaryUserEmail');
},
readOnly: true,
},
}, },
observers: ['deviceListChanged_(deviceList_.*)'], observers: ['deviceListChanged_(deviceList_.*)'],
......
...@@ -493,6 +493,8 @@ void AddBluetoothStrings(content::WebUIDataSource* html_source) { ...@@ -493,6 +493,8 @@ void AddBluetoothStrings(content::WebUIDataSource* html_source) {
{"bluetoothPairDevicePageTitle", {"bluetoothPairDevicePageTitle",
IDS_SETTINGS_BLUETOOTH_PAIR_DEVICE_TITLE}, IDS_SETTINGS_BLUETOOTH_PAIR_DEVICE_TITLE},
{"bluetoothRemove", IDS_SETTINGS_BLUETOOTH_REMOVE}, {"bluetoothRemove", IDS_SETTINGS_BLUETOOTH_REMOVE},
{"bluetoothPrimaryUserControlled",
IDS_SETTINGS_BLUETOOTH_PRIMARY_USER_CONTROLLED},
}; };
AddLocalizedStringsBulk(html_source, localized_strings, AddLocalizedStringsBulk(html_source, localized_strings,
arraysize(localized_strings)); arraysize(localized_strings));
......
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