Chromium Code Reviews| Index: chrome/browser/resources/md_feedback/feedback.js |
| diff --git a/chrome/browser/resources/md_feedback/feedback.js b/chrome/browser/resources/md_feedback/feedback.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2a5b457e52953c6dfd911c09ef206e1e411c35f3 |
| --- /dev/null |
| +++ b/chrome/browser/resources/md_feedback/feedback.js |
| @@ -0,0 +1,72 @@ |
| +// Copyright 2016 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. |
| + |
| +cr.define('feedback', function() { |
| + 'use strict'; |
|
afakhry
2016/09/14 01:48:15
No word from dbeam yet?
apacible
2016/09/14 17:53:20
He commented right after your's last set of commen
afakhry
2016/09/14 18:07:37
Thanks! I hope it doesn't cause you trouble with t
apacible
2016/09/14 18:12:11
Got it working, there were just a few small tweaks
|
| + |
| + /** |
| + * The feedback-container element. Initialized after Polymer is ready. |
| + * @type {?FeedbackContainer} |
| + */ |
| + var container = null; |
| + |
| + /** |
| + * Initialize the Feedback WebUI by requesting data to populate the current |
| + * feedback form. |
| + */ |
| + function initialize() { |
| + container = /** @type {!FeedbackContainerElement} */ |
| + ($('container')); |
| + |
| + feedback.browserApi.requestData(); |
| + } |
| + |
| + return { |
| + initialize: initialize, |
| + }; |
| +}); |
| + |
| +// API invoked by the browser MdFeedbackWebUIMessageHandler to communicate |
| +// with this UI. |
| +cr.define('feedback.ui', function() { |
| + 'use strict'; |
| + |
| + /** |
| + * Populates the feedback form with data. |
| + * |
| + * @param {{email: string|undefined, |
| + * url: string|undefined}} data |
| + * Parameters in data: |
| + * email - user's email, if available. |
| + * url - url of the tab the user was on before triggering feedback. |
| + */ |
| + function setData(data) { |
| + container.email = data['email']; |
| + container.url = data['url']; |
| + } |
| + |
| + return { |
| + setData: setData, |
| + }; |
| +}); |
| + |
| +// API invoked by this UI to communicate with the browser WebUI message |
| +// handler. |
| +cr.define('feedback.browserApi', function() { |
| + 'use strict'; |
| + |
| + /** |
| + * Requests data to initialize the WebUI with. |
| + * The data will be returned via feedback.ui.setData. |
| + */ |
| + function requestData() { |
| + chrome.send('requestData'); |
| + } |
| + |
| + return { |
| + requestData: requestData, |
| + }; |
| +}); |
| + |
| +window.addEventListener('DOMContentLoaded', feedback.initialize); |