Commit 23d96d61 authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Chromium LUCI CQ

[CrOS PhoneHub] Update Phone Hub notification settings row

If Phone Hub notification access is prohibited due to the user having a
work profile on their phone, disable the toggle and show a (?) icon with
a tooltip explaining why the toggle is disabled.

Note that currently, the prohibited value is never passed; a follow-up
CL passes this value when appropriate.

Screenshot:
http://go/chrome-ss/c999f0fb3f14985d9eef8b59bd8c1cb0e09f6282

Bug: 1155151, 1106937
Change-Id: I3062f37731d5b21fecc8a1da642d0d0e4b5e97d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2575423
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarJimmy Gong <jimmyxgong@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834053}
parent 70591e5e
...@@ -2475,6 +2475,9 @@ ...@@ -2475,6 +2475,9 @@
<message name="IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_ACCESS_PROHIBITED_SUMMARY" desc="The title of the dialog containing the Phone Hub notification opt-in flow when access to notifications is prohibited because the user's phone has a work profile."> <message name="IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_ACCESS_PROHIBITED_SUMMARY" desc="The title of the dialog containing the Phone Hub notification opt-in flow when access to notifications is prohibited because the user's phone has a work profile.">
Notification syncing is not supported for phones in a work profile. <ph name="LINK_BEGIN">&lt;a target="_blank" href="$1<ex>https://google.com/</ex>"&gt;</ph>Learn more<ph name="LINK_END">&lt;/a&gt;</ph> Notification syncing is not supported for phones in a work profile. <ph name="LINK_BEGIN">&lt;a target="_blank" href="$1<ex>https://google.com/</ex>"&gt;</ph>Learn more<ph name="LINK_END">&lt;/a&gt;</ph>
</message> </message>
<message name="IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_PROHIBITED_TOOLTIP" desc="Tooltip shown to users when hovering the help icon in settings next to the Phone Hub notification syncing feature. The tooltip describes how users with work profiles cannot opt into this feature.">
Notification syncing is not supported for phones in a work profile
</message>
<message name="IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_GET_STARTED_BUTTON_LABEL" desc="The label to a button in the Phone Hub notification opt-in flow that appears when the dialog first opens. Clicking the button will allow the user to try enabling the feature."> <message name="IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_GET_STARTED_BUTTON_LABEL" desc="The label to a button in the Phone Hub notification opt-in flow that appears when the dialog first opens. Clicking the button will allow the user to try enabling the feature.">
Get started Get started
</message> </message>
......
...@@ -74,6 +74,7 @@ js_library("multidevice_page") { ...@@ -74,6 +74,7 @@ js_library("multidevice_page") {
"../../controls:password_prompt_dialog", "../../controls:password_prompt_dialog",
"../../prefs:prefs_behavior", "../../prefs:prefs_behavior",
"../localized_link:localized_link", "../localized_link:localized_link",
"//ui/webui/resources/js:assert",
"//ui/webui/resources/js:cr", "//ui/webui/resources/js:cr",
"//ui/webui/resources/js:web_ui_listener_behavior", "//ui/webui/resources/js:web_ui_listener_behavior",
] ]
...@@ -399,10 +400,8 @@ polymer_modulizer("multidevice_page") { ...@@ -399,10 +400,8 @@ polymer_modulizer("multidevice_page") {
migrated_imports = os_settings_migrated_imports migrated_imports = os_settings_migrated_imports
namespace_rewrites = os_settings_namespace_rewrites namespace_rewrites = os_settings_namespace_rewrites
auto_imports = auto_imports =
os_settings_auto_imports + [ os_settings_auto_imports +
"ui/webui/resources/html/polymer.html|Polymer,html,beforeNextRender", [ "ui/webui/resources/html/polymer.html|Polymer,html,beforeNextRender" ]
"ui/webui/resources/html/assert.html|assert",
]
} }
polymer_modulizer("multidevice_notification_access_setup_dialog") { polymer_modulizer("multidevice_notification_access_setup_dialog") {
......
...@@ -65,6 +65,17 @@ cr.define('settings', function() { ...@@ -65,6 +65,17 @@ cr.define('settings', function() {
UNAVAILABLE_TOP_LEVEL_FEATURE_DISABLED: 9, UNAVAILABLE_TOP_LEVEL_FEATURE_DISABLED: 9,
}; };
/**
* Possible states of Phone Hub's notification access. Access can be
* prohibited if the user is using a work profile on their phone.
* @enum {number}
*/
/* #export */ const PhoneHubNotificationAccessStatus = {
PROHIBITED: 0,
AVAILABLE_BUT_NOT_GRANTED: 1,
ACCESS_GRANTED: 2,
};
/** /**
* Container for the initial data that the page requires in order to display * Container for the initial data that the page requires in order to display
* the correct content. It is also used for receiving status updates during * the correct content. It is also used for receiving status updates during
...@@ -90,7 +101,7 @@ cr.define('settings', function() { ...@@ -90,7 +101,7 @@ cr.define('settings', function() {
* phoneHubTaskContinuationState: !settings.MultiDeviceFeatureState, * phoneHubTaskContinuationState: !settings.MultiDeviceFeatureState,
* wifiSyncState: !settings.MultiDeviceFeatureState, * wifiSyncState: !settings.MultiDeviceFeatureState,
* isAndroidSmsPairingComplete: boolean, * isAndroidSmsPairingComplete: boolean,
* isNotificationAccessGranted: boolean * notificationAccessStatus: !settings.PhoneHubNotificationAccessStatus
* }} * }}
*/ */
/* #export */ let MultiDevicePageContentData; /* #export */ let MultiDevicePageContentData;
...@@ -101,6 +112,7 @@ cr.define('settings', function() { ...@@ -101,6 +112,7 @@ cr.define('settings', function() {
MultiDeviceFeature, MultiDeviceFeature,
MultiDeviceFeatureState, MultiDeviceFeatureState,
MultiDevicePageContentData, MultiDevicePageContentData,
PhoneHubNotificationAccessStatus,
SmartLockSignInEnabledState SmartLockSignInEnabledState
}; };
}); });
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// clang-format off // clang-format off
// #import {MultiDeviceSettingsMode, MultiDeviceFeature, MultiDeviceFeatureState, MultiDevicePageContentData } from './multidevice_constants.m.js'; // #import {MultiDeviceSettingsMode, MultiDeviceFeature, MultiDeviceFeatureState, MultiDevicePageContentData, PhoneHubNotificationAccessStatus} from './multidevice_constants.m.js';
// #import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; // #import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js';
// clang-format on // clang-format on
...@@ -71,6 +71,16 @@ const MultiDeviceFeatureBehaviorImpl = { ...@@ -71,6 +71,16 @@ const MultiDeviceFeatureBehaviorImpl = {
].includes(this.getFeatureState(feature)); ].includes(this.getFeatureState(feature));
}, },
/**
* @return {boolean} Whether or not Phone Hub notification access is
* prohibited (i.e., due to the user having a work profile).
*/
isPhoneHubNotificationAccessProhibited() {
return this.pageContentData &&
this.pageContentData.notificationAccessStatus ===
settings.PhoneHubNotificationAccessStatus.PROHIBITED;
},
/** /**
* Whether the user is prevented from attempted to change a given feature. In * Whether the user is prevented from attempted to change a given feature. In
* the UI this corresponds to a disabled toggle. * the UI this corresponds to a disabled toggle.
...@@ -85,6 +95,13 @@ const MultiDeviceFeatureBehaviorImpl = { ...@@ -85,6 +95,13 @@ const MultiDeviceFeatureBehaviorImpl = {
return false; return false;
} }
// Cannot edit the Phone Hub notification toggle if notification access is
// prohibited.
if (feature === settings.MultiDeviceFeature.PHONE_HUB_NOTIFICATIONS &&
this.isPhoneHubNotificationAccessProhibited()) {
return false;
}
return [ return [
settings.MultiDeviceFeatureState.DISABLED_BY_USER, settings.MultiDeviceFeatureState.DISABLED_BY_USER,
settings.MultiDeviceFeatureState.ENABLED_BY_USER settings.MultiDeviceFeatureState.ENABLED_BY_USER
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<dom-module id="settings-multidevice-feature-item"> <dom-module id="settings-multidevice-feature-item">
<template> <template>
<style include="settings-shared"> <style include="settings-shared">
:host([is-sub-feature]) iron-icon { :host([is-sub-feature]) #feature-icon {
display: none; display: none;
} }
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
padding: var(--feature-item-row-padding); padding: var(--feature-item-row-padding);
} }
iron-icon { #feature-icon {
padding: 2px; padding: 2px;
} }
...@@ -45,7 +45,8 @@ ...@@ -45,7 +45,8 @@
feature, pageContentData, subpageRoute)]]" feature, pageContentData, subpageRoute)]]"
on-click="handleItemClick_"> on-click="handleItemClick_">
<slot name="icon"> <slot name="icon">
<iron-icon icon="[[getIconName(feature)]]"></iron-icon> <iron-icon id="feature-icon" icon="[[getIconName(feature)]]">
</iron-icon>
</slot> </slot>
<div id="item-text-container" class="middle"> <div id="item-text-container" class="middle">
<div id="featureName">[[getFeatureName(feature)]]</div> <div id="featureName">[[getFeatureName(feature)]]</div>
...@@ -58,18 +59,24 @@ ...@@ -58,18 +59,24 @@
</slot> </slot>
</div> </div>
<template is="dom-if" <template is="dom-if"
if="[[hasSubpageClickHandler_( if="[[hasSubpageClickHandler_(feature, pageContentData,
feature, pageContentData, subpageRoute)]]" subpageRoute)]]"
restamp> restamp>
<cr-icon-button id="subpageButton" class="subpage-arrow" <cr-icon-button id="subpageButton" class="subpage-arrow"
aria-labelledby="featureName" aria-describedby="featureSecondary" aria-labelledby="featureName" aria-describedby="featureSecondary"
aria-roledescription="$i18n{subpageArrowRoleDescription}"> aria-roledescription="$i18n{subpageArrowRoleDescription}">
</cr-icon-button> </cr-icon-button>
</template> </template>
<template is="dom-if" if="[[infoTooltip]]" restamp>
<iron-icon id="help-icon" icon="cr:help-outline"></iron-icon>
<paper-tooltip for="help-icon" position="top" fit-to-visible-bounds>
[[infoTooltip]]
</paper-tooltip>
</template>
</div> </div>
<template is="dom-if" <template is="dom-if"
if="[[hasSubpageClickHandler_( if="[[shouldShowSeparator_(
feature, pageContentData, subpageRoute)]]" feature, pageContentData, subpageRoute)]]"
restamp> restamp>
<div class="separator"></div> <div class="separator"></div>
</template> </template>
......
...@@ -27,6 +27,11 @@ Polymer({ ...@@ -27,6 +27,11 @@ Polymer({
*/ */
subpageRoute: Object, subpageRoute: Object,
/**
* A tooltip to show over an info icon. If unset, no info icon is shown.
*/
infoTooltip: String,
/** /**
* URLSearchParams for subpage route. No param is provided if it is * URLSearchParams for subpage route. No param is provided if it is
* undefined. * undefined.
...@@ -76,6 +81,14 @@ Polymer({ ...@@ -76,6 +81,14 @@ Polymer({
return !!this.subpageRoute && this.isFeatureAllowedByPolicy(this.feature); return !!this.subpageRoute && this.isFeatureAllowedByPolicy(this.feature);
}, },
/**
* @return {boolean}
* @private
*/
shouldShowSeparator_() {
return this.hasSubpageClickHandler_() || !!this.infoTooltip;
},
/** @private */ /** @private */
handleItemClick_(event) { handleItemClick_(event) {
// We do not navigate away if the click was on a link. // We do not navigate away if the click was on a link.
......
...@@ -62,6 +62,13 @@ Polymer({ ...@@ -62,6 +62,13 @@ Polymer({
* @private * @private
*/ */
resetChecked_() { resetChecked_() {
// If Phone Hub notification access is prohibited, the toggle is always off.
if (this.feature === settings.MultiDeviceFeature.PHONE_HUB_NOTIFICATIONS &&
this.isPhoneHubNotificationAccessProhibited()) {
this.checked_ = false;
return;
}
this.checked_ = this.getFeatureState(this.feature) === this.checked_ = this.getFeatureState(this.feature) ===
settings.MultiDeviceFeatureState.ENABLED_BY_USER; settings.MultiDeviceFeatureState.ENABLED_BY_USER;
}, },
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> <link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> <link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html">
<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/html/assert.html">
<link rel="import" href="chrome://resources/html/cr.html"> <link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html"> <link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> <link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="../../i18n_setup.html"> <link rel="import" href="../../i18n_setup.html">
<link rel="import" href="../deep_linking_behavior.html"> <link rel="import" href="../deep_linking_behavior.html">
......
...@@ -351,9 +351,19 @@ Polymer({ ...@@ -351,9 +351,19 @@ Polymer({
// If the feature to enable is Phone Hub Notifications, notification access // If the feature to enable is Phone Hub Notifications, notification access
// must have been granted before the feature can be enabled. // must have been granted before the feature can be enabled.
if (feature === settings.MultiDeviceFeature.PHONE_HUB_NOTIFICATIONS && if (feature === settings.MultiDeviceFeature.PHONE_HUB_NOTIFICATIONS &&
enabled && !this.pageContentData.isNotificationAccessGranted) { enabled) {
this.showNotificationAccessSetupDialog_ = true; switch (this.pageContentData.notificationAccessStatus) {
return; case settings.PhoneHubNotificationAccessStatus.PROHIBITED:
assertNotReached('Cannot enable notification access; prohibited');
return;
case settings.PhoneHubNotificationAccessStatus
.AVAILABLE_BUT_NOT_GRANTED:
this.showNotificationAccessSetupDialog_ = true;
return;
default:
// Fall through and attempt to toggle feature.
break;
}
} }
// Disabling any feature does not require authentication, and enable some // Disabling any feature does not require authentication, and enable some
...@@ -440,7 +450,8 @@ Polymer({ ...@@ -440,7 +450,8 @@ Polymer({
onInitialPageContentDataFetched_(newData) { onInitialPageContentDataFetched_(newData) {
this.onPageContentDataChanged_(newData); this.onPageContentDataChanged_(newData);
if (this.pageContentData.isNotificationAccessGranted) { if (this.pageContentData.notificationAccessStatus !==
settings.PhoneHubNotificationAccessStatus.AVAILABLE_BUT_NOT_GRANTED) {
return; return;
} }
......
...@@ -124,6 +124,8 @@ ...@@ -124,6 +124,8 @@
restamp> restamp>
<settings-multidevice-feature-item id="phoneHubNotificationsItem" <settings-multidevice-feature-item id="phoneHubNotificationsItem"
feature="[[MultiDeviceFeature.PHONE_HUB_NOTIFICATIONS]]" feature="[[MultiDeviceFeature.PHONE_HUB_NOTIFICATIONS]]"
info-tooltip="[[getPhoneHubNotificationsTooltip_(
pageContentData)]]"
page-content-data="[[pageContentData]]" is-sub-feature page-content-data="[[pageContentData]]" is-sub-feature
deep-link-focus-id$="[[Setting.kPhoneHubNotificationsOnOff]]"> deep-link-focus-id$="[[Setting.kPhoneHubNotificationsOnOff]]">
</settings-multidevice-feature-item> </settings-multidevice-feature-item>
......
...@@ -157,5 +157,13 @@ Polymer({ ...@@ -157,5 +157,13 @@ Polymer({
return !this.isSuiteOn() || return !this.isSuiteOn() ||
messagesFeatureState === messagesFeatureState ===
settings.MultiDeviceFeatureState.PROHIBITED_BY_POLICY; settings.MultiDeviceFeatureState.PROHIBITED_BY_POLICY;
} },
getPhoneHubNotificationsTooltip_() {
if (!this.isPhoneHubNotificationAccessProhibited()) {
return '';
}
return this.i18n('multideviceNotificationAccessProhibitedTooltip');
},
}); });
...@@ -65,6 +65,7 @@ os_settings_namespace_rewrites = settings_namespace_rewrites + ...@@ -65,6 +65,7 @@ os_settings_namespace_rewrites = settings_namespace_rewrites +
"settings.OsResetBrowserProxy|OsResetBrowserProxy", "settings.OsResetBrowserProxy|OsResetBrowserProxy",
"settings.OsSyncBrowserProxy|OsSyncBrowserProxy", "settings.OsSyncBrowserProxy|OsSyncBrowserProxy",
"settings.OsSyncPrefs|OsSyncPrefs", "settings.OsSyncPrefs|OsSyncPrefs",
"settings.PhoneHubNotificationAccessStatus|PhoneHubNotificationAccessStatus",
"settings.recordLockScreenProgress|recordLockScreenProgress", "settings.recordLockScreenProgress|recordLockScreenProgress",
"settings.recordSettingChange|recordSettingChange", "settings.recordSettingChange|recordSettingChange",
"settings.Route|Route", "settings.Route|Route",
...@@ -106,7 +107,7 @@ os_settings_auto_imports = settings_auto_imports + ...@@ -106,7 +107,7 @@ os_settings_auto_imports = settings_auto_imports +
"chrome/browser/resources/settings/chromeos/google_assistant_page/google_assistant_browser_proxy.html|GoogleAssistantBrowserProxy,GoogleAssistantBrowserProxyImpl", "chrome/browser/resources/settings/chromeos/google_assistant_page/google_assistant_browser_proxy.html|GoogleAssistantBrowserProxy,GoogleAssistantBrowserProxyImpl",
"chrome/browser/resources/settings/chromeos/metrics_recorder.html|recordSettingChange", "chrome/browser/resources/settings/chromeos/metrics_recorder.html|recordSettingChange",
"chrome/browser/resources/settings/chromeos/multidevice_page/multidevice_browser_proxy.html|MultiDeviceBrowserProxy,MultiDeviceBrowserProxyImpl", "chrome/browser/resources/settings/chromeos/multidevice_page/multidevice_browser_proxy.html|MultiDeviceBrowserProxy,MultiDeviceBrowserProxyImpl",
"chrome/browser/resources/settings/chromeos/multidevice_page/multidevice_constants.html|MultiDeviceSettingsMode,MultiDeviceFeature,MultiDeviceFeatureState,MultiDevicePageContentData,SmartLockSignInEnabledState", "chrome/browser/resources/settings/chromeos/multidevice_page/multidevice_constants.html|MultiDeviceSettingsMode,MultiDeviceFeature,MultiDeviceFeatureState,MultiDevicePageContentData,PhoneHubNotificationAccessStatus,SmartLockSignInEnabledState",
"chrome/browser/resources/settings/chromeos/multidevice_page/multidevice_feature_behavior.html|MultiDeviceFeatureBehavior", "chrome/browser/resources/settings/chromeos/multidevice_page/multidevice_feature_behavior.html|MultiDeviceFeatureBehavior",
"chrome/browser/resources/settings/chromeos/multidevice_page/multidevice_browser_proxy.html|MultiDeviceBrowserProxy,MultiDeviceBrowserProxyImpl", "chrome/browser/resources/settings/chromeos/multidevice_page/multidevice_browser_proxy.html|MultiDeviceBrowserProxy,MultiDeviceBrowserProxyImpl",
"chrome/browser/resources/settings/chromeos/nearby_share_page/nearby_account_manager_browser_proxy.html|NearbyAccountManagerBrowserProxy,NearbyAccountManagerBrowserProxyImpl", "chrome/browser/resources/settings/chromeos/nearby_share_page/nearby_account_manager_browser_proxy.html|NearbyAccountManagerBrowserProxy,NearbyAccountManagerBrowserProxyImpl",
......
...@@ -56,7 +56,7 @@ export {GoogleAssistantBrowserProxyImpl} from './google_assistant_page/google_as ...@@ -56,7 +56,7 @@ export {GoogleAssistantBrowserProxyImpl} from './google_assistant_page/google_as
export {ConsentStatus, DspHotwordState} from './google_assistant_page/google_assistant_page.m.js'; export {ConsentStatus, DspHotwordState} from './google_assistant_page/google_assistant_page.m.js';
export {InternetPageBrowserProxy, InternetPageBrowserProxyImpl} from './internet_page/internet_page_browser_proxy.m.js'; export {InternetPageBrowserProxy, InternetPageBrowserProxyImpl} from './internet_page/internet_page_browser_proxy.m.js';
export {MultiDeviceBrowserProxy, MultiDeviceBrowserProxyImpl} from './multidevice_page/multidevice_browser_proxy.m.js'; export {MultiDeviceBrowserProxy, MultiDeviceBrowserProxyImpl} from './multidevice_page/multidevice_browser_proxy.m.js';
export {MultiDeviceFeature, MultiDeviceFeatureState, MultiDevicePageContentData, MultiDeviceSettingsMode, SmartLockSignInEnabledState} from './multidevice_page/multidevice_constants.m.js'; export {MultiDeviceFeature, MultiDeviceFeatureState, MultiDevicePageContentData, MultiDeviceSettingsMode, PhoneHubNotificationAccessStatus, SmartLockSignInEnabledState} from './multidevice_page/multidevice_constants.m.js';
export {Account, NearbyAccountManagerBrowserProxy, NearbyAccountManagerBrowserProxyImpl} from './nearby_share_page/nearby_account_manager_browser_proxy.m.js'; export {Account, NearbyAccountManagerBrowserProxy, NearbyAccountManagerBrowserProxyImpl} from './nearby_share_page/nearby_account_manager_browser_proxy.m.js';
export {getReceiveManager, observeReceiveManager, setReceiveManagerForTesting} from './nearby_share_page/nearby_share_receive_manager.m.js'; export {getReceiveManager, observeReceiveManager, setReceiveManagerForTesting} from './nearby_share_page/nearby_share_receive_manager.m.js';
export {dataUsageStringToEnum, NearbyShareDataUsage} from './nearby_share_page/types.m.js'; export {dataUsageStringToEnum, NearbyShareDataUsage} from './nearby_share_page/types.m.js';
......
...@@ -43,7 +43,7 @@ const char kPageContentDataPhoneHubTaskContinuationStateKey[] = ...@@ -43,7 +43,7 @@ const char kPageContentDataPhoneHubTaskContinuationStateKey[] =
"phoneHubTaskContinuationState"; "phoneHubTaskContinuationState";
const char kPageContentDataWifiSyncStateKey[] = "wifiSyncState"; const char kPageContentDataWifiSyncStateKey[] = "wifiSyncState";
const char kPageContentDataSmartLockStateKey[] = "smartLockState"; const char kPageContentDataSmartLockStateKey[] = "smartLockState";
const char kIsNotificationAccessGranted[] = "isNotificationAccessGranted"; const char kNotificationAccessStatus[] = "notificationAccessStatus";
const char kIsAndroidSmsPairingComplete[] = "isAndroidSmsPairingComplete"; const char kIsAndroidSmsPairingComplete[] = "isAndroidSmsPairingComplete";
constexpr char kAndroidSmsInfoOriginKey[] = "origin"; constexpr char kAndroidSmsInfoOriginKey[] = "origin";
...@@ -473,11 +473,16 @@ MultideviceHandler::GeneratePageContentDataDictionary() { ...@@ -473,11 +473,16 @@ MultideviceHandler::GeneratePageContentDataDictionary() {
? android_sms_pairing_state_tracker_->IsAndroidSmsPairingComplete() ? android_sms_pairing_state_tracker_->IsAndroidSmsPairingComplete()
: false); : false);
page_content_dictionary->SetBoolean( // TODO(khorimoto): Send prohibited value if notification access is
kIsNotificationAccessGranted, // prohibited.
notification_access_manager_ static const int kAccessNotGranted = 1;
? notification_access_manager_->HasAccessBeenGranted() static const int kAccessGranted = 2;
: false); int access_value = kAccessNotGranted;
if (notification_access_manager_ &&
notification_access_manager_->HasAccessBeenGranted()) {
access_value = kAccessGranted;
}
page_content_dictionary->SetInteger(kNotificationAccessStatus, access_value);
return page_content_dictionary; return page_content_dictionary;
} }
......
...@@ -303,6 +303,8 @@ void MultiDeviceSection::AddLoadTimeData( ...@@ -303,6 +303,8 @@ void MultiDeviceSection::AddLoadTimeData(
IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_COULD_NOT_ESTABLISH_CONNECTION_SUMMARY}, IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_COULD_NOT_ESTABLISH_CONNECTION_SUMMARY},
{"multideviceNotificationAccessSetupAccessProhibitedTitle", {"multideviceNotificationAccessSetupAccessProhibitedTitle",
IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_ACCESS_PROHIBITED_TITLE}, IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_ACCESS_PROHIBITED_TITLE},
{"multideviceNotificationAccessProhibitedTooltip",
IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_PROHIBITED_TOOLTIP},
{"multideviceInstantTetheringItemTitle", {"multideviceInstantTetheringItemTitle",
IDS_SETTINGS_MULTIDEVICE_INSTANT_TETHERING}, IDS_SETTINGS_MULTIDEVICE_INSTANT_TETHERING},
{"multideviceInstantTetheringItemSummary", {"multideviceInstantTetheringItemSummary",
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// clang-format off // clang-format off
// #import 'chrome://os-settings/chromeos/os_settings.js'; // #import 'chrome://os-settings/chromeos/os_settings.js';
// #import {MultiDeviceFeature, MultiDeviceFeatureState} from 'chrome://os-settings/chromeos/os_settings.js'; // #import {MultiDeviceFeature, MultiDeviceFeatureState, PhoneHubNotificationAccessStatus} from 'chrome://os-settings/chromeos/os_settings.js';
// #import {assertEquals, assertFalse, assertTrue} from '../../chai_assert.js'; // #import {assertEquals, assertFalse, assertTrue} from '../../chai_assert.js';
// #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; // #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
// clang-format on // clang-format on
...@@ -21,17 +21,31 @@ suite('Multidevice', () => { ...@@ -21,17 +21,31 @@ suite('Multidevice', () => {
let featureToggle = null; let featureToggle = null;
/** @type {?CrToggleElement} */ /** @type {?CrToggleElement} */
let crToggle = null; let crToggle = null;
/** @type {!settings.MultiDeviceFeature} */
let featureToTest;
/** @type {string} */
let pageContentDataKey;
/** /**
* Sets the state of the feature shown in the toggle (i.e. Messages). Note * Sets the state of the feature shown in the toggle. Note that in order to
* that in order to trigger featureToggle's bindings to update, we set its * trigger featureToggle's bindings to update, we set its pageContentData to a
* pageContentData to a new object as the actual UI does. * new object as the actual UI does.
* @param {?settings.MultiDeviceFeatureState} newMessagesState. New value for * @param {?settings.MultiDeviceFeatureState} newFeatureState
* featureToggle.pageContentData.messagesState.
*/ */
function setMessagesState(newMessagesState) { function setFeatureState(newFeatureState) {
featureToggle.pageContentData = Object.assign( featureToggle.pageContentData = Object.assign(
{}, featureToggle.pageContentData, {messagesState: newMessagesState}); {}, featureToggle.pageContentData,
{[pageContentDataKey]: newFeatureState});
Polymer.dom.flush();
}
/**
* @param {!settings.PhoneHubNotificationAccessStatus} accessStatus
*/
function setNotificationAccessStatus(accessStatus) {
featureToggle.pageContentData = Object.assign(
{}, featureToggle.pageContentData,
{notificationAccessStatus: accessStatus});
Polymer.dom.flush(); Polymer.dom.flush();
} }
...@@ -49,19 +63,25 @@ suite('Multidevice', () => { ...@@ -49,19 +63,25 @@ suite('Multidevice', () => {
Polymer.dom.flush(); Polymer.dom.flush();
} }
setup(() => { /**
PolymerTest.clearBody(); * @param {!settings.MultiDeviceFeature} feature
* @param {string} key
*/
function init(feature, key) {
featureToTest = feature;
pageContentDataKey = key;
featureToggle = featureToggle =
document.createElement('settings-multidevice-feature-toggle'); document.createElement('settings-multidevice-feature-toggle');
featureToggle.feature = settings.MultiDeviceFeature.MESSAGES; featureToggle.feature = feature;
// Initially toggle will be unchecked but not disabled. Note that the word // Initially toggle will be unchecked but not disabled. Note that the word
// "disabled" is ambiguous for feature toggles because it can refer to the // "disabled" is ambiguous for feature toggles because it can refer to the
// feature or the cr-toggle property/attribute. DISABLED_BY_USER refers to // feature or the cr-toggle property/attribute. DISABLED_BY_USER refers to
// the former so it unchecks but does not functionally disable the toggle. // the former so it unchecks but does not functionally disable the toggle.
featureToggle.pageContentData = { featureToggle.pageContentData = {
betterTogetherState: settings.MultiDeviceFeatureState.ENABLED_BY_USER, betterTogetherState: settings.MultiDeviceFeatureState.ENABLED_BY_USER,
messagesState: settings.MultiDeviceFeatureState.DISABLED_BY_USER, [pageContentDataKey]: settings.MultiDeviceFeatureState.DISABLED_BY_USER,
}; };
document.body.appendChild(featureToggle); document.body.appendChild(featureToggle);
Polymer.dom.flush(); Polymer.dom.flush();
...@@ -71,44 +91,56 @@ suite('Multidevice', () => { ...@@ -71,44 +91,56 @@ suite('Multidevice', () => {
assertFalse(featureToggle.checked_); assertFalse(featureToggle.checked_);
assertFalse(crToggle.checked); assertFalse(crToggle.checked);
assertFalse(crToggle.disabled); assertFalse(crToggle.disabled);
}
setup(() => {
PolymerTest.clearBody();
}); });
test('checked property can be set by feature state', () => { test('checked property can be set by feature state', () => {
setMessagesState(settings.MultiDeviceFeatureState.ENABLED_BY_USER); init(settings.MultiDeviceFeature.MESSAGES, 'messagesState');
setFeatureState(settings.MultiDeviceFeatureState.ENABLED_BY_USER);
assertTrue(featureToggle.checked_); assertTrue(featureToggle.checked_);
assertTrue(crToggle.checked); assertTrue(crToggle.checked);
setMessagesState(settings.MultiDeviceFeatureState.DISABLED_BY_USER); setFeatureState(settings.MultiDeviceFeatureState.DISABLED_BY_USER);
assertFalse(featureToggle.checked_); assertFalse(featureToggle.checked_);
assertFalse(crToggle.checked); assertFalse(crToggle.checked);
}); });
test('disabled property can be set by feature state', () => { test('disabled property can be set by feature state', () => {
setMessagesState(settings.MultiDeviceFeatureState.PROHIBITED_BY_POLICY); init(settings.MultiDeviceFeature.MESSAGES, 'messagesState');
setFeatureState(settings.MultiDeviceFeatureState.PROHIBITED_BY_POLICY);
assertTrue(crToggle.disabled); assertTrue(crToggle.disabled);
setMessagesState(settings.MultiDeviceFeatureState.DISABLED_BY_USER); setFeatureState(settings.MultiDeviceFeatureState.DISABLED_BY_USER);
assertFalse(crToggle.disabled); assertFalse(crToggle.disabled);
}); });
test('disabled and checked properties update simultaneously', () => { test('disabled and checked properties update simultaneously', () => {
setMessagesState(settings.MultiDeviceFeatureState.ENABLED_BY_USER); init(settings.MultiDeviceFeature.MESSAGES, 'messagesState');
setFeatureState(settings.MultiDeviceFeatureState.ENABLED_BY_USER);
assertTrue(featureToggle.checked_); assertTrue(featureToggle.checked_);
assertTrue(crToggle.checked); assertTrue(crToggle.checked);
assertFalse(crToggle.disabled); assertFalse(crToggle.disabled);
setMessagesState(settings.MultiDeviceFeatureState.PROHIBITED_BY_POLICY); setFeatureState(settings.MultiDeviceFeatureState.PROHIBITED_BY_POLICY);
assertFalse(featureToggle.checked_); assertFalse(featureToggle.checked_);
assertFalse(crToggle.checked); assertFalse(crToggle.checked);
assertTrue(crToggle.disabled); assertTrue(crToggle.disabled);
setMessagesState(settings.MultiDeviceFeatureState.DISABLED_BY_USER); setFeatureState(settings.MultiDeviceFeatureState.DISABLED_BY_USER);
assertFalse(featureToggle.checked_); assertFalse(featureToggle.checked_);
assertFalse(crToggle.checked); assertFalse(crToggle.checked);
assertFalse(crToggle.disabled); assertFalse(crToggle.disabled);
}); });
test('disabled property can be set by suite pref', () => { test('disabled property can be set by suite pref', () => {
init(settings.MultiDeviceFeature.MESSAGES, 'messagesState');
setSuiteState(settings.MultiDeviceFeatureState.DISABLED_BY_USER); setSuiteState(settings.MultiDeviceFeatureState.DISABLED_BY_USER);
Polymer.dom.flush(); Polymer.dom.flush();
assertTrue(crToggle.disabled); assertTrue(crToggle.disabled);
...@@ -119,7 +151,9 @@ suite('Multidevice', () => { ...@@ -119,7 +151,9 @@ suite('Multidevice', () => {
}); });
test('checked property is unaffected by suite pref', () => { test('checked property is unaffected by suite pref', () => {
setMessagesState(settings.MultiDeviceFeatureState.ENABLED_BY_USER); init(settings.MultiDeviceFeature.MESSAGES, 'messagesState');
setFeatureState(settings.MultiDeviceFeatureState.ENABLED_BY_USER);
assertTrue(featureToggle.checked_); assertTrue(featureToggle.checked_);
assertTrue(crToggle.checked); assertTrue(crToggle.checked);
assertFalse(crToggle.disabled); assertFalse(crToggle.disabled);
...@@ -132,9 +166,28 @@ suite('Multidevice', () => { ...@@ -132,9 +166,28 @@ suite('Multidevice', () => {
}); });
test('clicking toggle does not change checked property', () => { test('clicking toggle does not change checked property', () => {
init(settings.MultiDeviceFeature.MESSAGES, 'messagesState');
const preClickCrToggleChecked = crToggle.checked; const preClickCrToggleChecked = crToggle.checked;
crToggle.click(); crToggle.click();
Polymer.dom.flush(); Polymer.dom.flush();
assertEquals(crToggle.checked, preClickCrToggleChecked); assertEquals(crToggle.checked, preClickCrToggleChecked);
}); });
test('notification access is prohibited', () => {
init(
settings.MultiDeviceFeature.PHONE_HUB_NOTIFICATIONS,
'phoneHubNotificationsState');
setFeatureState(settings.MultiDeviceFeatureState.ENABLED_BY_USER);
assertTrue(featureToggle.checked_);
assertTrue(crToggle.checked);
assertFalse(crToggle.disabled);
setNotificationAccessStatus(
settings.PhoneHubNotificationAccessStatus.PROHIBITED);
assertFalse(featureToggle.checked_);
assertFalse(crToggle.checked);
assertTrue(crToggle.disabled);
});
}); });
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
// #import 'chrome://os-settings/chromeos/os_settings.js'; // #import 'chrome://os-settings/chromeos/os_settings.js';
// #import {TestLifetimeBrowserProxy} from './test_os_lifetime_browser_proxy.m.js'; // #import {TestLifetimeBrowserProxy} from './test_os_lifetime_browser_proxy.m.js';
// #import {MultiDeviceSettingsMode, MultiDeviceFeature, MultiDeviceFeatureState, MultiDevicePageContentData, MultiDeviceBrowserProxyImpl, Router, routes} from 'chrome://os-settings/chromeos/os_settings.js'; // #import {MultiDeviceSettingsMode, MultiDeviceFeature, MultiDeviceFeatureState, MultiDevicePageContentData, MultiDeviceBrowserProxyImpl, PhoneHubNotificationAccessStatus, Router, routes} from 'chrome://os-settings/chromeos/os_settings.js';
// #import {TestOsResetBrowserProxy} from './test_os_reset_browser_proxy.m.js'; // #import {TestOsResetBrowserProxy} from './test_os_reset_browser_proxy.m.js';
// #import {assertEquals, assertFalse, assertNotEquals, assertTrue} from '../../chai_assert.js'; // #import {assertEquals, assertFalse, assertNotEquals, assertTrue} from '../../chai_assert.js';
// #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; // #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
...@@ -73,9 +73,12 @@ suite('Multidevice', function() { ...@@ -73,9 +73,12 @@ suite('Multidevice', function() {
* @param {boolean} accessGranted * @param {boolean} accessGranted
*/ */
function setPhoneHubNotificationAccessGranted(accessGranted) { function setPhoneHubNotificationAccessGranted(accessGranted) {
const accessState = accessGranted ?
settings.PhoneHubNotificationAccessStatus.ACCESS_GRANTED :
settings.PhoneHubNotificationAccessStatus.AVAILABLE_BUT_NOT_GRANTED;
setPageContentData(Object.assign( setPageContentData(Object.assign(
{}, multidevicePage.pageContentData, {}, multidevicePage.pageContentData,
{isNotificationAccessGranted: accessGranted})); {notificationAccessStatus: accessState}));
} }
/** /**
...@@ -111,8 +114,10 @@ suite('Multidevice', function() { ...@@ -111,8 +114,10 @@ suite('Multidevice', function() {
const accessDialog = multidevicePage.$$( const accessDialog = multidevicePage.$$(
'settings-multidevice-notification-access-setup-dialog'); 'settings-multidevice-notification-access-setup-dialog');
assertEquals( assertEquals(
!accessDialog, !!accessDialog,
multidevicePage.pageContentData.isNotificationAccessGranted); multidevicePage.pageContentData.notificationAccessStatus ===
settings.PhoneHubNotificationAccessStatus
.AVAILABLE_BUT_NOT_GRANTED);
return; return;
} }
...@@ -207,6 +212,8 @@ suite('Multidevice', function() { ...@@ -207,6 +212,8 @@ suite('Multidevice', function() {
PolymerTest.clearBody(); PolymerTest.clearBody();
browserProxy = new multidevice.TestMultideviceBrowserProxy(); browserProxy = new multidevice.TestMultideviceBrowserProxy();
settings.MultiDeviceBrowserProxyImpl.instance_ = browserProxy; settings.MultiDeviceBrowserProxyImpl.instance_ = browserProxy;
browserProxy.data.notificationAccessStatus =
settings.PhoneHubNotificationAccessStatus.AVAILABLE_BUT_NOT_GRANTED;
multidevicePage = document.createElement('settings-multidevice-page'); multidevicePage = document.createElement('settings-multidevice-page');
assertTrue(!!multidevicePage); assertTrue(!!multidevicePage);
......
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