Commit 8f854c97 authored by yoshiki@chromium.org's avatar yoshiki@chromium.org

Files.app: Fix errors when launching Files.app via "chrome://files" (2)

The previous patch (r203795) is not a good way because chrome.app.window.contentWindow is always undefined. This patch introduced another method to check if it is running as apps instead.

BUG=243414
TEST=Confirm a close button works correctly on normal Files.app and doesn't work on chrome://files.
R=mtomasz@chromium.org

Review URL: https://chromiumcodereview.appspot.com/16207004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203969 0039d316-1c4b-4281-b951-d872f2087c98
parent ac2d27b0
......@@ -622,7 +622,7 @@ DialogType.isModal = function(type) {
FileManager.prototype.onMaximize = function() {
// Do not maximize when running via chrome://files in a browser.
if (!chrome.app.window.contentWindow)
if (util.platform.runningInBrowser())
return;
var appWindow = chrome.app.window.current();
......@@ -634,7 +634,7 @@ DialogType.isModal = function(type) {
FileManager.prototype.onClose = function() {
// Do not close when running via chrome://files in a browser.
if (!chrome.app.window.contentWindow)
if (util.platform.runningInBrowser())
return;
window.close();
......@@ -886,16 +886,11 @@ DialogType.isModal = function(type) {
this.initDialogType_();
// Show the window as soon as the UI pre-initialization is done.
if (this.dialogType == DialogType.FULL_PAGE && util.platform.v2()) {
// Do not call show() when running via chrome://files in a browser.
if (chrome.app.window.contentWindow) {
chrome.app.window.current().show();
setTimeout(callback, 100); // Wait until the animation is finished.
} else {
console.info('Files.app window is not created yet. Maybe launched ' +
'via chrome://files in a browser?');
callback();
}
if (this.dialogType == DialogType.FULL_PAGE &&
util.platform.v2() &&
!util.platform.runningInBrowser()) {
chrome.app.window.current().show();
setTimeout(callback, 100); // Wait until the animation is finished.
} else {
callback();
}
......
......@@ -803,6 +803,13 @@ util.platform = {
}
},
/**
* @return {boolean} True if Files.app is running via "chrome://files".
*/
runningInBrowser: function() {
return util.platform.v2() && !window.appID;
},
/**
* @return {boolean} True for the new ui.
*/
......
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