Commit 4b2cedf0 authored by Ahmed Fakhry's avatar Ahmed Fakhry Committed by Commit Bot

Don't use window.open in feedback app

Instead open links in app windows. See details
on the bug.

BUG=899092
TEST=Manual; all links open inside app windows rather than tabs.

Change-Id: I2fc0dc02a17fb37daec9c715ba1801d35cc1a629
Reviewed-on: https://chromium-review.googlesource.com/c/1320216Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605822}
parent 4bd7bf49
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<include name="IDR_FEEDBACK_BLUETOOTHLOGSINFO_HTML" file="feedback/html/bluetooth_logs_info.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> <include name="IDR_FEEDBACK_BLUETOOTHLOGSINFO_HTML" file="feedback/html/bluetooth_logs_info.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_FEEDBACK_DEFAULT_HTML" file="feedback/html/default.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> <include name="IDR_FEEDBACK_DEFAULT_HTML" file="feedback/html/default.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_FEEDBACK_SYSINFO_HTML" file="feedback/html/sys_info.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> <include name="IDR_FEEDBACK_SYSINFO_HTML" file="feedback/html/sys_info.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_FEEDBACK_FEEDBACK_DATA_JS" file="feedback/js/data.js" flattenhtml="true" type="BINDATA" /> <include name="IDR_FEEDBACK_FEEDBACK_UTIL_JS" file="feedback/js/feedback_util.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_FEEDBACK_EVENT_HANDLER_JS" file="feedback/js/event_handler.js" flattenhtml="true" type="BINDATA" /> <include name="IDR_FEEDBACK_EVENT_HANDLER_JS" file="feedback/js/event_handler.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_FEEDBACK_FEEDBACK_JS" file="feedback/js/feedback.js" flattenhtml="true" type="BINDATA" /> <include name="IDR_FEEDBACK_FEEDBACK_JS" file="feedback/js/feedback.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_FEEDBACK_SYSINFO_JS" file="feedback/js/sys_info.js" flattenhtml="true" type="BINDATA" /> <include name="IDR_FEEDBACK_SYSINFO_JS" file="feedback/js/sys_info.js" flattenhtml="true" type="BINDATA" />
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<script src="chrome://resources/js/load_time_data.js"></script> <script src="chrome://resources/js/load_time_data.js"></script>
<script src="chrome://resources/js/i18n_template_no_process.js"></script> <script src="chrome://resources/js/i18n_template_no_process.js"></script>
<script src="chrome://resources/js/util.js"></script> <script src="chrome://resources/js/util.js"></script>
<script src="../js/data.js"></script> <script src="../js/feedback_util.js"></script>
<script src="../js/take_screenshot.js"></script> <script src="../js/take_screenshot.js"></script>
<script src="../js/topbar_handlers.js"></script> <script src="../js/topbar_handlers.js"></script>
<script src="../js/feedback.js"></script> <script src="../js/feedback.js"></script>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// 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.
// <include src="data.js"> // <include src="feedback_util.js">
/** /**
* @type {number} * @type {number}
...@@ -187,7 +187,7 @@ class FeedbackRequest { ...@@ -187,7 +187,7 @@ class FeedbackRequest {
chrome.feedbackPrivate.LandingPageType.NORMAL ? chrome.feedbackPrivate.LandingPageType.NORMAL ?
FEEDBACK_LANDING_PAGE : FEEDBACK_LANDING_PAGE :
FEEDBACK_LANDING_PAGE_TECHSTOP; FEEDBACK_LANDING_PAGE_TECHSTOP;
window.open(landingPage, '_blank'); openUrlInAppWindow(landingPage);
} }
} else { } else {
console.log( console.log(
......
...@@ -46,11 +46,6 @@ var MAX_SCREENSHOT_WIDTH = 100; ...@@ -46,11 +46,6 @@ var MAX_SCREENSHOT_WIDTH = 100;
*/ */
var SYSINFO_WINDOW_ID = 'sysinfo_window'; var SYSINFO_WINDOW_ID = 'sysinfo_window';
/** @type {string}
* @const
*/
var STATS_WINDOW_ID = 'stats_window';
/** /**
* SRT Prompt Result defined in feedback_private.idl. * SRT Prompt Result defined in feedback_private.idl.
* @enum {string} * @enum {string}
...@@ -157,19 +152,6 @@ function clearAttachedFile() { ...@@ -157,19 +152,6 @@ function clearAttachedFile() {
$('attach-file').hidden = false; $('attach-file').hidden = false;
} }
/**
* Creates a closure that creates or shows a window with the given url.
* @param {string} windowId A string with the ID of the window we are opening.
* @param {string} url The destination URL of the new window.
* @return {function()} A function to be called to open the window.
*/
function windowOpener(windowId, url) {
return function(e) {
e.preventDefault();
chrome.app.window.create(url, {id: windowId});
};
}
/** /**
* Sets up the event handlers for the given |anchorElement|. * Sets up the event handlers for the given |anchorElement|.
* @param {HTMLElement} anchorElement The <a> html element. * @param {HTMLElement} anchorElement The <a> html element.
...@@ -178,7 +160,7 @@ function windowOpener(windowId, url) { ...@@ -178,7 +160,7 @@ function windowOpener(windowId, url) {
function setupLinkHandlers(anchorElement, url) { function setupLinkHandlers(anchorElement, url) {
anchorElement.onclick = function(e) { anchorElement.onclick = function(e) {
e.preventDefault(); e.preventDefault();
window.open(url, '_blank'); openUrlInAppWindow(url);
}; };
anchorElement.onauxclick = function(e) { anchorElement.onauxclick = function(e) {
...@@ -378,7 +360,7 @@ function initialize() { ...@@ -378,7 +360,7 @@ function initialize() {
$('srt-accept-button').onclick = function() { $('srt-accept-button').onclick = function() {
chrome.feedbackPrivate.logSrtPromptResult(SrtPromptResult.ACCEPTED); chrome.feedbackPrivate.logSrtPromptResult(SrtPromptResult.ACCEPTED);
window.open(SRT_DOWNLOAD_PAGE, '_blank'); openUrlInAppWindow(SRT_DOWNLOAD_PAGE);
scheduleWindowClose(); scheduleWindowClose();
}; };
...@@ -528,12 +510,7 @@ function initialize() { ...@@ -528,12 +510,7 @@ function initialize() {
var histogramUrlElement = $('histograms-url'); var histogramUrlElement = $('histograms-url');
if (histogramUrlElement) { if (histogramUrlElement) {
// Opens a new window showing the histogram metrics. // Opens a new window showing the histogram metrics.
histogramUrlElement.onclick = setupLinkHandlers(histogramUrlElement, 'chrome://histograms');
windowOpener(STATS_WINDOW_ID, 'chrome://histograms');
histogramUrlElement.onauxclick = function(e) {
e.preventDefault();
};
} }
var legalHelpPageUrlElement = $('legal-help-page-url'); var legalHelpPageUrlElement = $('legal-help-page-url');
......
...@@ -28,3 +28,18 @@ var FEEDBACK_PRIVACY_POLICY_URL = 'https://policies.google.com/privacy'; ...@@ -28,3 +28,18 @@ var FEEDBACK_PRIVACY_POLICY_URL = 'https://policies.google.com/privacy';
* @const * @const
*/ */
var FEEDBACK_TERM_OF_SERVICE_URL = 'https://policies.google.com/terms'; var FEEDBACK_TERM_OF_SERVICE_URL = 'https://policies.google.com/terms';
/**
* Opens the supplied url in an app window. It uses the url as the window ID.
* @param {string} url The destination URL for the link.
*/
function openUrlInAppWindow(url) {
chrome.app.window.create(url, {
frame: 'chrome',
id: url,
width: 640,
height: 400,
hidden: false,
resizable: true
});
}
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