Gallery: Register unload handler to 'pagehide' event. (issue 816603002 by hirono@chromium.org)

6 views
Skip to first unread message

hir...@chromium.org

unread,
Dec 17, 2014, 8:46:46 PM12/17/14
to yaw...@chromium.org, chromium...@chromium.org, rginda...@chromium.org, mtomas...@chromium.org
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;

})();


yaw...@chromium.org

unread,
Dec 18, 2014, 2:00:50 AM12/18/14
to hir...@chromium.org, chromium...@chromium.org, rginda...@chromium.org, mtomas...@chromium.org
On 2014/12/18 01:46:45, hirono wrote:
> PTAL the CL? Thanks!

lgtm. Thank you!

https://codereview.chromium.org/816603002/

commi...@chromium.org

unread,
Dec 18, 2014, 2:04:24 AM12/18/14
to hir...@chromium.org, yaw...@chromium.org, chromium...@chromium.org, rginda...@chromium.org, mtomas...@chromium.org

commi...@chromium.org

unread,
Dec 18, 2014, 2:17:22 AM12/18/14
to hir...@chromium.org, yaw...@chromium.org, chromium...@chromium.org, rginda...@chromium.org, mtomas...@chromium.org
Committed patchset #1 (id:1)

https://codereview.chromium.org/816603002/

commi...@chromium.org

unread,
Dec 18, 2014, 2:18:03 AM12/18/14
to hir...@chromium.org, yaw...@chromium.org, chromium...@chromium.org, rginda...@chromium.org, mtomas...@chromium.org
Patchset 1 (id:??) landed as
https://crrev.com/372a9183889718b7c11eb63d08841c5ca2e43ac0
Cr-Commit-Position: refs/heads/master@{#308962}

https://codereview.chromium.org/816603002/
Reply all
Reply to author
Forward
0 new messages