Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(803)

Side by Side Diff: ui/file_manager/gallery/js/gallery.js

Issue 816603002: Gallery: Register unload handler to 'pagehide' event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/file_manager/gallery/js/gallery_scripts.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * Called from the main frame when unloading.
7 * @param {boolean=} opt_exiting True if the app is exiting.
8 */
9 function unload(opt_exiting) { gallery.onUnload(opt_exiting); }
10
11 /**
12 * Overrided metadata worker's path. 6 * Overrided metadata worker's path.
13 * @type {string} 7 * @type {string}
14 */ 8 */
15 ContentProvider.WORKER_SCRIPT = '/js/metadata_worker.js'; 9 ContentProvider.WORKER_SCRIPT = '/js/metadata_worker.js';
16 10
17 /** 11 /**
18 * Data model for gallery. 12 * Data model for gallery.
19 * 13 *
20 * @param {!MetadataCache} metadataCache Metadata cache. 14 * @param {!MetadataCache} metadataCache Metadata cache.
21 * @constructor 15 * @constructor
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 // the observer is not going to work. 355 // the observer is not going to work.
362 if (!this.context_.searchResults && this.context_.curDirEntry) { 356 if (!this.context_.searchResults && this.context_.curDirEntry) {
363 this.metadataCacheObserverId_ = this.metadataCache_.addObserver( 357 this.metadataCacheObserverId_ = this.metadataCache_.addObserver(
364 this.context_.curDirEntry, 358 this.context_.curDirEntry,
365 MetadataCache.CHILDREN, 359 MetadataCache.CHILDREN,
366 'thumbnail', 360 'thumbnail',
367 this.updateThumbnails_.bind(this)); 361 this.updateThumbnails_.bind(this));
368 } 362 }
369 this.volumeManager_.addEventListener( 363 this.volumeManager_.addEventListener(
370 'externally-unmounted', this.onExternallyUnmountedBound_); 364 'externally-unmounted', this.onExternallyUnmountedBound_);
365 // The 'pagehide' event is called when the app window is closed.
366 window.addEventListener('pagehide', this.onPageHide_.bind(this));
371 } 367 }
372 368
373 /** 369 /**
374 * Gallery extends cr.EventTarget. 370 * Gallery extends cr.EventTarget.
375 */ 371 */
376 Gallery.prototype.__proto__ = cr.EventTarget.prototype; 372 Gallery.prototype.__proto__ = cr.EventTarget.prototype;
377 373
378 /** 374 /**
379 * Tools fade-out timeout in milliseconds. 375 * Tools fade-out timeout in milliseconds.
380 * @const 376 * @const
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 return; 410 return;
415 411
416 if (this.volumeManager_.getVolumeInfo(this.selectedEntry_) === 412 if (this.volumeManager_.getVolumeInfo(this.selectedEntry_) ===
417 event.volumeInfo) { 413 event.volumeInfo) {
418 window.close(); 414 window.close();
419 } 415 }
420 }; 416 };
421 417
422 /** 418 /**
423 * Unloads the Gallery. 419 * Unloads the Gallery.
424 * @param {boolean=} opt_exiting True if the app is exiting. 420 * @private
425 */ 421 */
426 Gallery.prototype.onUnload = function(opt_exiting) { 422 Gallery.prototype.onPageHide_ = function() {
427 if (this.metadataCacheObserverId_ !== null) 423 if (this.metadataCacheObserverId_ !== null)
428 this.metadataCache_.removeObserver(this.metadataCacheObserverId_); 424 this.metadataCache_.removeObserver(this.metadataCacheObserverId_);
429 this.volumeManager_.removeEventListener( 425 this.volumeManager_.removeEventListener(
430 'externally-unmounted', this.onExternallyUnmountedBound_); 426 'externally-unmounted', this.onExternallyUnmountedBound_);
431 }; 427 };
432 428
433 /** 429 /**
434 * Initializes a toolbar button. 430 * Initializes a toolbar button.
435 * 431 *
436 * @param {string} className Class to add. 432 * @param {string} className Class to add.
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 }; 1054 };
1059 1055
1060 /** 1056 /**
1061 * Loads entries. 1057 * Loads entries.
1062 * @param {!Array.<Entry>} entries Array of entries. 1058 * @param {!Array.<Entry>} entries Array of entries.
1063 * @param {!Array.<Entry>} selectedEntries Array of selected entries. 1059 * @param {!Array.<Entry>} selectedEntries Array of selected entries.
1064 */ 1060 */
1065 window.loadEntries = function(entries, selectedEntries) { 1061 window.loadEntries = function(entries, selectedEntries) {
1066 gallery.load(entries, selectedEntries); 1062 gallery.load(entries, selectedEntries);
1067 }; 1063 };
OLDNEW
« no previous file with comments | « no previous file | ui/file_manager/gallery/js/gallery_scripts.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698