Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Unified Diff: chrome/test/data/extensions/platform_apps/web_view/dialog/inject_dialog.js

Issue 19679002: <webview>: Implement dialog API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Describes |user_input| Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/platform_apps/web_view/dialog/inject_dialog.js
diff --git a/chrome/test/data/extensions/platform_apps/web_view/dialog/inject_dialog.js b/chrome/test/data/extensions/platform_apps/web_view/dialog/inject_dialog.js
new file mode 100644
index 0000000000000000000000000000000000000000..5aa734aeca5c9b71c69fb106dcb1488d58aec3b1
--- /dev/null
+++ b/chrome/test/data/extensions/platform_apps/web_view/dialog/inject_dialog.js
@@ -0,0 +1,72 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var embedder = null;
+
+function reportConnected() {
+ if (!embedder) {
lazyboy 2013/07/23 18:45:01 Just curious, is this for correctness or do these
Fady Samuel 2013/07/23 19:40:52 It's 'correctness'. Since these are unnecessary I'
+ return;
+ }
+
+ var msg = ['connected'];
+ embedder.postMessage(JSON.stringify(msg), '*');
+}
+
+function reportAlertCompletion(messageText) {
+ if (!embedder) {
+ return;
+ }
+
+ window.alert(messageText);
+ var msg = ['alert-dialog-requested'];
lazyboy 2013/07/23 18:45:01 This line getting executed means dialog has been d
Fady Samuel 2013/07/23 19:40:52 Done.
+ embedder.postMessage(JSON.stringify(msg), '*');
+}
+
+function reportConfirmDialogResult(messageText) {
+ if (!embedder) {
+ return;
+ }
+
+ var result = window.confirm(messageText);
+ var msg = ['confirm-dialog-result', result];
+ embedder.postMessage(JSON.stringify(msg), '*');
+}
+
+function reportPromptDialogResult(messageText, defaultPromptText) {
+ if (!embedder) {
+ return;
+ }
+
+ var result = window.prompt(messageText, defaultPromptText);
+ var msg = ['prompt-dialog-result', result];
+ embedder.postMessage(JSON.stringify(msg), '*');
+}
+
+window.addEventListener('message', function(e) {
+ embedder = e.source;
+ var data = JSON.parse(e.data);
+ if (data[0] == 'connect') {
lazyboy 2013/07/23 18:45:01 a switch (data[0]) might be more readable.
Fady Samuel 2013/07/23 19:40:52 Done.
+ reportConnected();
+ return;
+ }
+
+ if (data[0] == 'start-confirm-dialog-test') {
+ var messageText = data[1];
+ reportConfirmDialogResult(messageText);
+ return;
+ }
+
+ if (data[0] == 'start-alert-dialog-test') {
+ var messageText = data[1];
+ reportAlertCompletion(messageText);
+ return;
+ }
+
+ if (data[0] == 'start-prompt-dialog-test') {
+ var messageText = data[1];
+ var defaultPromptText = data[2];
+ reportPromptDialogResult(messageText, defaultPromptText);
+ return;
+ }
+});

Powered by Google App Engine
This is Rietveld 408576698