Commit e382f304 authored by David's avatar David Committed by Commit Bot

Use Message.OPEN_FEEDBACK_DIALOG instead of the string.

chrome://media-app uses a postMessage API to communicate between its trusted and
untrusted contexts to gain access to privileged functionality such as opening
the feedback dialog. Use an object (Message) to indicate the action being
communicated across the postMessage API instead of strings which are more error
prone.

Bug: 996088, b/138961540
Change-Id: I17185bdde143f8fb061ec2000075dd4a463cd7cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2096057
Commit-Queue: David Lei <dlei@google.com>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749025}
parent 012ee46f
...@@ -32,7 +32,7 @@ let currentlyWritableFileHandle = null; ...@@ -32,7 +32,7 @@ let currentlyWritableFileHandle = null;
/** A pipe through which we can send messages to the guest frame. */ /** A pipe through which we can send messages to the guest frame. */
const guestMessagePipe = new MessagePipe('chrome://media-app-guest'); const guestMessagePipe = new MessagePipe('chrome://media-app-guest');
guestMessagePipe.registerHandler('openFeedbackDialog', () => { guestMessagePipe.registerHandler(Message.OPEN_FEEDBACK_DIALOG, () => {
let response = media_app.handler.openFeedbackDialog(); let response = media_app.handler.openFeedbackDialog();
if (response === null) { if (response === null) {
response = {errorMessage: 'Null response received'}; response = {errorMessage: 'Null response received'};
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
*/ */
const Message = { const Message = {
LOAD_FILE: 'load-file', LOAD_FILE: 'load-file',
OPEN_FEEDBACK_DIALOG: 'open-feedback-dialog',
OVERWRITE_FILE: 'overwrite-file', OVERWRITE_FILE: 'overwrite-file',
}; };
......
...@@ -74,7 +74,8 @@ parentMessagePipe.registerHandler(Message.LOAD_FILE, (message) => { ...@@ -74,7 +74,8 @@ parentMessagePipe.registerHandler(Message.LOAD_FILE, (message) => {
class Delegate { class Delegate {
/** @override */ /** @override */
async openFeedbackDialog() { async openFeedbackDialog() {
let response = await parentMessagePipe.sendMessage('openFeedbackDialog'); const response = await parentMessagePipe.sendMessage(
Message.OPEN_FEEDBACK_DIALOG);
return /** @type {?string} */ (response['errorMessage']); return /** @type {?string} */ (response['errorMessage']);
} }
}; };
......
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