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..73e294f75bbbced4df49b923f23666b00eaeb013 |
| --- /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() { |
|
afakhry
2016/08/11 23:31:31
First, thank you for the detailed comments and the
apacible
2016/08/12 01:46:41
The snippet is definitely much simpler!
The style
afakhry
2016/08/12 19:22:38
Bear in mind that the webui doc you pointed out is
apacible
2016/08/29 17:00:20
+dbeam for thoughts (and/or future of WebUI guidel
Dan Beam
2016/09/14 05:11:21
what do you want my specific thoughts on? 'use st
|
| + 'use strict'; |
| + |
| + /** |
| + * 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('load', feedback.initialize); |
|
afakhry
2016/08/11 23:31:31
Do you need to wait for the page to fully load (DO
apacible
2016/08/12 01:46:41
Done.
|