Reviewers: yawano,
Message:
PTAL the CL? Thanks!
Description:
Gallery: Register unload handler to 'pagehide' event.
Previously the unload handler is assigned to window.unload, but the method
is
not called in packaged apps.
BUG=441647
TEST=None
Please review this at
https://codereview.chromium.org/816603002/
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Affected files (+4, -9 lines):
M ui/file_manager/gallery/js/gallery.js
M ui/file_manager/gallery/js/gallery_scripts.js
Index: ui/file_manager/gallery/js/gallery.js
diff --git a/ui/file_manager/gallery/js/gallery.js
b/ui/file_manager/gallery/js/gallery.js
index
61176466beb8cac90801067a8958c1b392c39885..34a66b97d03bf62a41fb4083231a686e755a6a5c
100644
--- a/ui/file_manager/gallery/js/gallery.js
+++ b/ui/file_manager/gallery/js/gallery.js
@@ -3,12 +3,6 @@
// found in the LICENSE file.
/**
- * Called from the main frame when unloading.
- * @param {boolean=} opt_exiting True if the app is exiting.
- */
-function unload(opt_exiting) { gallery.onUnload(opt_exiting); }
-
-/**
* Overrided metadata worker's path.
* @type {string}
*/
@@ -368,6 +362,8 @@ function Gallery(volumeManager) {
}
this.volumeManager_.addEventListener(
'externally-unmounted', this.onExternallyUnmountedBound_);
+ // The 'pagehide' event is called when the app window is closed.
+ window.addEventListener('pagehide', this.onPageHide_.bind(this));
}
/**
@@ -421,9 +417,9 @@ Gallery.prototype.onExternallyUnmounted_ =
function(event) {
/**
* Unloads the Gallery.
- * @param {boolean=} opt_exiting True if the app is exiting.
+ * @private
*/
-Gallery.prototype.onUnload = function(opt_exiting) {
+Gallery.prototype.onPageHide_ = function() {
if (this.metadataCacheObserverId_ !== null)
this.metadataCache_.removeObserver(this.metadataCacheObserverId_);
this.volumeManager_.removeEventListener(
Index: ui/file_manager/gallery/js/gallery_scripts.js
diff --git a/ui/file_manager/gallery/js/gallery_scripts.js
b/ui/file_manager/gallery/js/gallery_scripts.js
index
072b675831355d59f5133309bff459626e6b69e2..98366b97e5cb4d68cb820dee4223de3aecbb9c00
100644
--- a/ui/file_manager/gallery/js/gallery_scripts.js
+++ b/ui/file_manager/gallery/js/gallery_scripts.js
@@ -71,7 +71,6 @@
window.ImageUtil = ImageUtil;
window.ImageUtil.metrics = metrics;
window.Gallery = Gallery;
-window.unload = unload;
window.util = util;
})();