Commit 7217b543 authored by dpapad's avatar dpapad Committed by Commit Bot

WebUI cleanup: Remove calls to cr.exportPath() in chrome://management.

Bug: 986481
Change-Id: I3eb011a34bb225eb137c1ee80e95774ed0d6753f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1714384
Auto-Submit: Demetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Roman Aleksandrov <raleksandrov@google.com>
Reviewed-by: default avatarRoman Aleksandrov <raleksandrov@google.com>
Cr-Commit-Position: refs/heads/master@{#680056}
parent 2bd73443
...@@ -2,70 +2,69 @@ ...@@ -2,70 +2,69 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
cr.exportPath('management');
/**
* @typedef {{
* name: string,
* permissions: !Array<string>
* }}
*/
management.Extension;
/** @enum {string} */
management.ReportingType = {
SECURITY: 'security',
DEVICE: 'device',
USER: 'user',
USER_ACTIVITY: 'user-activity',
EXTENSIONS: 'extensions'
};
/**
* @typedef {{
* messageId: string,
* reportingType: !management.ReportingType,
* }}
*/
management.BrowserReportingResponse;
/**
* @typedef {{
* browserManagementNotice: string,
* extensionReportingTitle: string,
* pageSubtitle: string,
* managed: boolean,
* overview: string,
* customerLogo: string,
* }}
*/
management.ManagedDataResponse;
// <if expr="chromeos">
/**
* @enum {string} Look at ToJSDeviceReportingType usage in
* management_ui_handler.cc for more details.
*/
management.DeviceReportingType = {
SUPERVISED_USER: 'supervised user',
DEVICE_ACTIVITY: 'device activity',
STATISTIC: 'device statistics',
DEVICE: 'device',
LOGS: 'logs',
PRINT: 'print',
CROSTINI: 'crostini'
};
/**
* @typedef {{
* messageId: string,
* reportingType: !management.DeviceReportingType,
* }}
*/
management.DeviceReportingResponse;
// </if>
cr.define('management', function() { cr.define('management', function() {
/**
* @typedef {{
* name: string,
* permissions: !Array<string>
* }}
*/
let Extension;
/** @enum {string} */
const ReportingType = {
SECURITY: 'security',
DEVICE: 'device',
USER: 'user',
USER_ACTIVITY: 'user-activity',
EXTENSIONS: 'extensions'
};
/**
* @typedef {{
* messageId: string,
* reportingType: !management.ReportingType,
* }}
*/
let BrowserReportingResponse;
/**
* @typedef {{
* browserManagementNotice: string,
* extensionReportingTitle: string,
* pageSubtitle: string,
* managed: boolean,
* overview: string,
* customerLogo: string,
* }}
*/
let ManagedDataResponse;
// <if expr="chromeos">
/**
* @enum {string} Look at ToJSDeviceReportingType usage in
* management_ui_handler.cc for more details.
*/
const DeviceReportingType = {
SUPERVISED_USER: 'supervised user',
DEVICE_ACTIVITY: 'device activity',
STATISTIC: 'device statistics',
DEVICE: 'device',
LOGS: 'logs',
PRINT: 'print',
CROSTINI: 'crostini'
};
/**
* @typedef {{
* messageId: string,
* reportingType: !management.DeviceReportingType,
* }}
*/
let DeviceReportingResponse;
// </if>
/** @interface */ /** @interface */
class ManagementBrowserProxy { class ManagementBrowserProxy {
/** @return {!Promise<!Array<!management.Extension>>} */ /** @return {!Promise<!Array<!management.Extension>>} */
...@@ -128,7 +127,15 @@ cr.define('management', function() { ...@@ -128,7 +127,15 @@ cr.define('management', function() {
cr.addSingletonGetter(ManagementBrowserProxyImpl); cr.addSingletonGetter(ManagementBrowserProxyImpl);
return { return {
BrowserReportingResponse: BrowserReportingResponse,
// <if expr="chromeos">
DeviceReportingResponse: DeviceReportingResponse,
DeviceReportingType: DeviceReportingType,
// </if>
Extension: Extension,
ManagedDataResponse: ManagedDataResponse,
ManagementBrowserProxyImpl: ManagementBrowserProxyImpl,
ManagementBrowserProxy: ManagementBrowserProxy, ManagementBrowserProxy: ManagementBrowserProxy,
ManagementBrowserProxyImpl: ManagementBrowserProxyImpl ReportingType: ReportingType,
}; };
}); });
...@@ -2,264 +2,270 @@ ...@@ -2,264 +2,270 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
cr.exportPath('management'); cr.define('management', function() {
/** /**
* @typedef {{ * @typedef {{
* messageIds: !Array<string>, * messageIds: !Array<string>,
* icon: string, * icon: string,
* }} * }}
*/ */
management.BrowserReportingData; let BrowserReportingData;
Polymer({
is: 'management-ui',
behaviors: [
I18nBehavior,
WebUIListenerBehavior,
],
properties: {
/**
* List of messages related to browser reporting.
* @private {?Array<!management.BrowserReportingData>}
*/
browserReportingInfo_: Array,
/** Polymer({
* List of messages related to browser reporting. is: 'management-ui',
* @private {?Array<!management.Extension>}
*/
extensions_: Array,
// <if expr="chromeos"> behaviors: [
/** I18nBehavior,
* List of messages related to device reporting. WebUIListenerBehavior,
* @private {?Array<!management.DeviceReportingResponse>} ],
*/
deviceReportingInfo_: Array,
/** properties: {
* Message stating if the Trust Roots are configured. /**
* @private * List of messages related to browser reporting.
*/ * @private {?Array<!management.BrowserReportingData>}
localTrustRoots_: String, */
browserReportingInfo_: Array,
/** @private */ /**
customerLogo_: String, * List of messages related to browser reporting.
* @private {?Array<!management.Extension>}
*/
extensions_: Array,
/** @private */ // <if expr="chromeos">
managementOverview_: String, /**
* List of messages related to device reporting.
* @private {?Array<!management.DeviceReportingResponse>}
*/
deviceReportingInfo_: Array,
// </if> /**
* Message stating if the Trust Roots are configured.
* @private
*/
localTrustRoots_: String,
/** @private */ /** @private */
subtitle_: String, customerLogo_: String,
// <if expr="not chromeos"> /** @private */
/** @private */ managementOverview_: String,
managementNoticeHtml_: String,
// </if>
/** @private */ // </if>
managed_: Boolean,
/** @private */ /** @private */
extensionReportingSubtitle_: String, subtitle_: String,
},
// <if expr="not chromeos">
/** @private */
managementNoticeHtml_: String,
// </if>
/** @private {?management.ManagementBrowserProxy} */ /** @private */
browserProxy_: null, managed_: Boolean,
/** @override */ /** @private */
attached() { extensionReportingSubtitle_: String,
document.documentElement.classList.remove('loading'); },
this.browserProxy_ = management.ManagementBrowserProxyImpl.getInstance();
this.updateManagedFields_();
this.initBrowserReportingInfo_();
this.addWebUIListener( /** @private {?management.ManagementBrowserProxy} */
'browser-reporting-info-updated', browserProxy_: null,
reportingInfo => this.onBrowserReportingInfoReceived_(reportingInfo));
this.addWebUIListener('managed_data_changed', () => { /** @override */
attached() {
document.documentElement.classList.remove('loading');
this.browserProxy_ = management.ManagementBrowserProxyImpl.getInstance();
this.updateManagedFields_(); this.updateManagedFields_();
}); this.initBrowserReportingInfo_();
this.getExtensions_(); this.addWebUIListener(
// <if expr="chromeos"> 'browser-reporting-info-updated',
this.getDeviceReportingInfo_(); reportingInfo => this.onBrowserReportingInfoReceived_(reportingInfo));
this.getLocalTrustRootsInfo_();
// </if>
},
/** @private */ this.addWebUIListener('managed_data_changed', () => {
initBrowserReportingInfo_() { this.updateManagedFields_();
this.browserProxy_.initBrowserReportingInfo().then( });
reportingInfo => this.onBrowserReportingInfoReceived_(reportingInfo));
},
/** this.getExtensions_();
* @param {!Array<!management.BrowserReportingResponse>} reportingInfo // <if expr="chromeos">
* @private this.getDeviceReportingInfo_();
*/ this.getLocalTrustRootsInfo_();
onBrowserReportingInfoReceived_(reportingInfo) { // </if>
const reportingInfoMap = reportingInfo.reduce((info, response) => { },
info[response.reportingType] = info[response.reportingType] || {
icon: this.getIconForReportingType_(response.reportingType), /** @private */
messageIds: [] initBrowserReportingInfo_() {
this.browserProxy_.initBrowserReportingInfo().then(
reportingInfo => this.onBrowserReportingInfoReceived_(reportingInfo));
},
/**
* @param {!Array<!management.BrowserReportingResponse>} reportingInfo
* @private
*/
onBrowserReportingInfoReceived_(reportingInfo) {
const reportingInfoMap = reportingInfo.reduce((info, response) => {
info[response.reportingType] = info[response.reportingType] || {
icon: this.getIconForReportingType_(response.reportingType),
messageIds: []
};
info[response.reportingType].messageIds.push(response.messageId);
return info;
}, {});
const reportingTypeOrder = {
[management.ReportingType.SECURITY]: 1,
[management.ReportingType.EXTENSIONS]: 2,
[management.ReportingType.USER]: 3,
[management.ReportingType.USER_ACTIVITY]: 4,
[management.ReportingType.DEVICE]: 5,
}; };
info[response.reportingType].messageIds.push(response.messageId);
return info;
}, {});
const reportingTypeOrder = {
[management.ReportingType.SECURITY]: 1,
[management.ReportingType.EXTENSIONS]: 2,
[management.ReportingType.USER]: 3,
[management.ReportingType.USER_ACTIVITY]: 4,
[management.ReportingType.DEVICE]: 5,
};
this.browserReportingInfo_ =
Object.keys(reportingInfoMap)
.sort((a, b) => reportingTypeOrder[a] - reportingTypeOrder[b])
.map(reportingType => reportingInfoMap[reportingType]);
},
/** @private */
getExtensions_() {
this.browserProxy_.getExtensions().then(extensions => {
this.extensions_ = extensions;
});
},
// <if expr="chromeos">
/** @private */
getLocalTrustRootsInfo_() {
this.browserProxy_.getLocalTrustRootsInfo().then(trustRootsConfigured => {
this.localTrustRoots_ = trustRootsConfigured ?
loadTimeData.getString('managementTrustRootsConfigured') :
'';
});
},
/** @private */
getDeviceReportingInfo_() {
this.browserProxy_.getDeviceReportingInfo().then(reportingInfo => {
this.deviceReportingInfo_ = reportingInfo;
});
},
/** this.browserReportingInfo_ =
* @return {boolean} True of there are device reporting info to show. Object.keys(reportingInfoMap)
* @private .sort((a, b) => reportingTypeOrder[a] - reportingTypeOrder[b])
*/ .map(reportingType => reportingInfoMap[reportingType]);
showDeviceReportingInfo_() { },
return !!this.deviceReportingInfo_ && this.deviceReportingInfo_.length > 0;
},
/** /** @private */
* @param {management.DeviceReportingType} reportingType getExtensions_() {
* @return {string} The associated icon. this.browserProxy_.getExtensions().then(extensions => {
* @private this.extensions_ = extensions;
*/ });
getIconForDeviceReportingType_(reportingType) { },
switch (reportingType) {
case management.DeviceReportingType.SUPERVISED_USER:
return 'management:supervised-user';
case management.DeviceReportingType.DEVICE_ACTIVITY:
return 'management:timelapse';
case management.DeviceReportingType.STATISTIC:
return 'management:bar-chart';
case management.DeviceReportingType.DEVICE:
return 'cr:computer';
case management.DeviceReportingType.LOGS:
return 'management:report';
case management.DeviceReportingType.PRINT:
return 'cr:print';
case management.DeviceReportingType.CROSTINI:
return 'management:linux';
default:
return 'cr:computer';
}
},
// </if>
/** // <if expr="chromeos">
* @return {boolean} True of there are browser reporting info to show. /** @private */
* @private getLocalTrustRootsInfo_() {
*/ this.browserProxy_.getLocalTrustRootsInfo().then(trustRootsConfigured => {
showBrowserReportingInfo_() { this.localTrustRoots_ = trustRootsConfigured ?
return !!this.browserReportingInfo_ && loadTimeData.getString('managementTrustRootsConfigured') :
this.browserReportingInfo_.length > 0; '';
}, });
},
/** /** @private */
* @return {boolean} True of there are extension reporting info to show. getDeviceReportingInfo_() {
* @private this.browserProxy_.getDeviceReportingInfo().then(reportingInfo => {
*/ this.deviceReportingInfo_ = reportingInfo;
showExtensionReportingInfo_() { });
return !!this.extensions_ && this.extensions_.length > 0; },
},
/** /**
* @param {management.ReportingType} reportingType * @return {boolean} True of there are device reporting info to show.
* @returns {string} The associated icon. * @private
* @private */
*/ showDeviceReportingInfo_() {
getIconForReportingType_(reportingType) { return !!this.deviceReportingInfo_ &&
switch (reportingType) { this.deviceReportingInfo_.length > 0;
case management.ReportingType.SECURITY: },
return 'cr:security';
case management.ReportingType.DEVICE:
return 'cr:computer';
case management.ReportingType.EXTENSIONS:
return 'cr:extension';
case management.ReportingType.USER:
return 'management:account-circle';
case management.ReportingType.USER_ACTIVITY:
return 'management:public';
default:
return 'cr:security';
}
},
/** /**
* Handles the 'search-changed' event fired from the toolbar. * @param {management.DeviceReportingType} reportingType
* Redirects to the settings page initialized the the current * @return {string} The associated icon.
* search query. * @private
* @param {!CustomEvent<string>} e */
* @private getIconForDeviceReportingType_(reportingType) {
*/ switch (reportingType) {
onSearchChanged_: function(e) { case management.DeviceReportingType.SUPERVISED_USER:
const query = e.detail; return 'management:supervised-user';
window.location.href = case management.DeviceReportingType.DEVICE_ACTIVITY:
`chrome://settings?search=${encodeURIComponent(query)}`; return 'management:timelapse';
}, case management.DeviceReportingType.STATISTIC:
return 'management:bar-chart';
/** @private */ case management.DeviceReportingType.DEVICE:
onTapBack_() { return 'cr:computer';
if (history.length > 1) { case management.DeviceReportingType.LOGS:
history.back(); return 'management:report';
} else { case management.DeviceReportingType.PRINT:
window.location.href = 'chrome://settings/help'; return 'cr:print';
} case management.DeviceReportingType.CROSTINI:
}, return 'management:linux';
default:
/** @private */ return 'cr:computer';
updateManagedFields_() { }
this.browserProxy_.getContextualManagedData().then(data => { },
this.managed_ = data.managed; // </if>
this.extensionReportingSubtitle_ = data.extensionReportingTitle;
this.subtitle_ = data.pageSubtitle; /**
// <if expr="chromeos"> * @return {boolean} True of there are browser reporting info to show.
this.customerLogo_ = data.customerLogo; * @private
this.managementOverview_ = data.overview; */
// </if> showBrowserReportingInfo_() {
// <if expr="not chromeos"> return !!this.browserReportingInfo_ &&
this.managementNoticeHtml_ = data.browserManagementNotice; this.browserReportingInfo_.length > 0;
// </if> },
});
}, /**
* @return {boolean} True of there are extension reporting info to show.
* @private
*/
showExtensionReportingInfo_() {
return !!this.extensions_ && this.extensions_.length > 0;
},
/**
* @param {management.ReportingType} reportingType
* @returns {string} The associated icon.
* @private
*/
getIconForReportingType_(reportingType) {
switch (reportingType) {
case management.ReportingType.SECURITY:
return 'cr:security';
case management.ReportingType.DEVICE:
return 'cr:computer';
case management.ReportingType.EXTENSIONS:
return 'cr:extension';
case management.ReportingType.USER:
return 'management:account-circle';
case management.ReportingType.USER_ACTIVITY:
return 'management:public';
default:
return 'cr:security';
}
},
/**
* Handles the 'search-changed' event fired from the toolbar.
* Redirects to the settings page initialized the the current
* search query.
* @param {!CustomEvent<string>} e
* @private
*/
onSearchChanged_: function(e) {
const query = e.detail;
window.location.href =
`chrome://settings?search=${encodeURIComponent(query)}`;
},
/** @private */
onTapBack_() {
if (history.length > 1) {
history.back();
} else {
window.location.href = 'chrome://settings/help';
}
},
/** @private */
updateManagedFields_() {
this.browserProxy_.getContextualManagedData().then(data => {
this.managed_ = data.managed;
this.extensionReportingSubtitle_ = data.extensionReportingTitle;
this.subtitle_ = data.pageSubtitle;
// <if expr="chromeos">
this.customerLogo_ = data.customerLogo;
this.managementOverview_ = data.overview;
// </if>
// <if expr="not chromeos">
this.managementNoticeHtml_ = data.browserManagementNotice;
// </if>
});
},
});
return {
BrowserReportingData: BrowserReportingData,
};
}); });
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