Commit 0d6075a7 authored by Bailey Berro's avatar Bailey Berro Committed by Commit Bot

Add policy checks to SmbShare UI.

If the policy for NetworkFileSharesAllowed is set to false, users will
not be able to mount shares nor will the be able to access the mount ui


Bug: chromium:757625
Change-Id: Ief64c9a9c3c2a574b931bc3f21516d471c26bcd4
Reviewed-on: https://chromium-review.googlesource.com/1152490Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarScott Chen <scottchen@chromium.org>
Commit-Queue: Bailey Berro <baileyberro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584443}
parent 14e88d0d
......@@ -179,6 +179,10 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetWhitelistedKeys() {
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[drive::prefs::kDisableDrive] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
#if defined(OS_CHROMEOS)
(*s_whitelist)[::prefs::kNetworkFileSharesAllowed] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
#endif
// Printing settings.
(*s_whitelist)[::prefs::kLocalDiscoveryNotificationsEnabled] =
......
......@@ -81,7 +81,7 @@
<settings-subpage
associated-control="[[$$('#smbShares')]]"
page-title="$i18n{smbSharesTitle}">
<settings-smb-shares-page>
<settings-smb-shares-page prefs="[[prefs]]">
</settings-smb-shares-page>
</settings-subpage>
</template>
......
......@@ -24,8 +24,16 @@
$i18n{requireNetworkMessage}
</div>
</div>
<template is="dom-if" if="[[!prefs.network_file_shares.allowed.value]]"
restamp>
<cr-policy-pref-indicator
pref="[[prefs.network_file_shares.allowed]]"
icon-aria-label="$i18n{smbSharesTitle}">
</cr-policy-pref-indicator>
</template>
<paper-button class="action-button" id="addShare"
on-click="onAddShareTap_">
on-click="onAddShareTap_"
disabled="[[!prefs.network_file_shares.allowed.value]]">
$i18n{addSmbShare}
</paper-button>
</div>
......
......@@ -8,6 +8,14 @@ Polymer({
behaviors: [WebUIListenerBehavior],
properties: {
/**
* Preferences state.
*/
prefs: {
type: Object,
notify: true,
},
/** @private */
showAddSmbDialog_: Boolean,
......
......@@ -104,4 +104,18 @@ suite('AddSmbShareDialogTests', function() {
return smbBrowserProxy.whenCalled('startDiscovery');
});
test('ControlledByPolicy', function() {
const button = page.$$('#addShare');
assertFalse(!!page.$$('cr-policy-pref-indicator'));
expectFalse(button.disabled);
page.prefs = {
network_file_shares: {allowed: {value: false}},
};
Polymer.dom.flush();
assertTrue(!!page.$$('cr-policy-pref-indicator'));
assertTrue(button.disabled);
});
});
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