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) { ...@@ -622,7 +622,7 @@ DialogType.isModal = function(type) {
FileManager.prototype.onMaximize = function() { FileManager.prototype.onMaximize = function() {
// Do not maximize when running via chrome://files in a browser. // Do not maximize when running via chrome://files in a browser.
if (!chrome.app.window.contentWindow) if (util.platform.runningInBrowser())
return; return;
var appWindow = chrome.app.window.current(); var appWindow = chrome.app.window.current();
...@@ -634,7 +634,7 @@ DialogType.isModal = function(type) { ...@@ -634,7 +634,7 @@ DialogType.isModal = function(type) {
FileManager.prototype.onClose = function() { FileManager.prototype.onClose = function() {
// Do not close when running via chrome://files in a browser. // Do not close when running via chrome://files in a browser.
if (!chrome.app.window.contentWindow) if (util.platform.runningInBrowser())
return; return;
window.close(); window.close();
...@@ -886,16 +886,11 @@ DialogType.isModal = function(type) { ...@@ -886,16 +886,11 @@ DialogType.isModal = function(type) {
this.initDialogType_(); this.initDialogType_();
// Show the window as soon as the UI pre-initialization is done. // Show the window as soon as the UI pre-initialization is done.
if (this.dialogType == DialogType.FULL_PAGE && util.platform.v2()) { if (this.dialogType == DialogType.FULL_PAGE &&
// Do not call show() when running via chrome://files in a browser. util.platform.v2() &&
if (chrome.app.window.contentWindow) { !util.platform.runningInBrowser()) {
chrome.app.window.current().show(); chrome.app.window.current().show();
setTimeout(callback, 100); // Wait until the animation is finished. 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();
}
} else { } else {
callback(); callback();
} }
......
...@@ -803,6 +803,13 @@ util.platform = { ...@@ -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. * @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