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

Side by Side Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 8727028: Eliminate use of assignments to innerHTML in File Browser (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/image_editor/gallery.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Setting the src of an img to an empty string can crash the browser, so we 5 // Setting the src of an img to an empty string can crash the browser, so we
6 // use an empty 1x1 gif instead. 6 // use an empty 1x1 gif instead.
7 const EMPTY_IMAGE_URI = 'data:image/gif;base64,' 7 const EMPTY_IMAGE_URI = 'data:image/gif;base64,'
8 + 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D'; 8 + 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D';
9 9
10 var g_slideshow_data = null; 10 var g_slideshow_data = null;
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 }, opt_errorCallback); 427 }, opt_errorCallback);
428 } 428 }
429 } 429 }
430 430
431 function isSystemDirEntry(dirEntry) { 431 function isSystemDirEntry(dirEntry) {
432 return dirEntry.fullPath == '/' || 432 return dirEntry.fullPath == '/' ||
433 dirEntry.fullPath == REMOVABLE_DIRECTORY || 433 dirEntry.fullPath == REMOVABLE_DIRECTORY ||
434 dirEntry.fullPath == ARCHIVE_DIRECTORY; 434 dirEntry.fullPath == ARCHIVE_DIRECTORY;
435 } 435 }
436 436
437 function removeChildren(element) {
arv (Not doing code reviews) 2011/11/29 22:53:27 element.textContent = '';
438 while (element.firstChild) {
439 element.removeChild(element.firstChild);
440 }
441 };
442
437 // Public statics. 443 // Public statics.
438 444
439 /** 445 /**
440 * List of dialog types. 446 * List of dialog types.
441 * 447 *
442 * Keep this in sync with FileManagerDialog::GetDialogTypeAsString, except 448 * Keep this in sync with FileManagerDialog::GetDialogTypeAsString, except
443 * FULL_PAGE which is specific to this code. 449 * FULL_PAGE which is specific to this code.
444 * 450 *
445 * @enum {string} 451 * @enum {string}
446 */ 452 */
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1821 urls: [], 1827 urls: [],
1822 totalCount: 0, 1828 totalCount: 0,
1823 fileCount: 0, 1829 fileCount: 0,
1824 directoryCount: 0, 1830 directoryCount: 0,
1825 bytes: 0, 1831 bytes: 0,
1826 iconType: null, 1832 iconType: null,
1827 indexes: this.currentList_.selectionModel.selectedIndexes 1833 indexes: this.currentList_.selectionModel.selectedIndexes
1828 }; 1834 };
1829 1835
1830 this.previewSummary_.textContent = str('COMPUTING_SELECTION'); 1836 this.previewSummary_.textContent = str('COMPUTING_SELECTION');
1831 this.taskButtons_.innerHTML = ''; 1837 removeChildren(this.taskButtons_);
1832 this.previewThumbnails_.innerHTML = ''; 1838 removeChildren(this.previewThumbnails_);
1833 1839
1834 if (!selection.indexes.length) { 1840 if (!selection.indexes.length) {
1835 this.updateCommonActionButtons_(); 1841 this.updateCommonActionButtons_();
1836 this.updatePreviewPanelVisibility_(); 1842 this.updatePreviewPanelVisibility_();
1837 cr.dispatchSimpleEvent(this, 'selection-summarized'); 1843 cr.dispatchSimpleEvent(this, 'selection-summarized');
1838 return; 1844 return;
1839 } 1845 }
1840 1846
1841 var fileCount = 0; 1847 var fileCount = 0;
1842 var byteCount = 0; 1848 var byteCount = 0;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 } 1912 }
1907 1913
1908 if (pendingFiles.length) { 1914 if (pendingFiles.length) {
1909 cacheEntrySize(pendingFiles.pop(), cacheNextFile); 1915 cacheEntrySize(pendingFiles.pop(), cacheNextFile);
1910 } else { 1916 } else {
1911 self.dispatchEvent(new cr.Event('selection-summarized')); 1917 self.dispatchEvent(new cr.Event('selection-summarized'));
1912 } 1918 }
1913 } 1919 }
1914 1920
1915 if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) { 1921 if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) {
1916 this.taskButtons_.innerHTML = ''; 1922 removeChildren(this.taskButtons_);
1917 // Some internal tasks cannot be defined in terms of file patterns, 1923 // Some internal tasks cannot be defined in terms of file patterns,
1918 // so we pass selection to check for them manually. 1924 // so we pass selection to check for them manually.
1919 if (selection.directoryCount == 0 && selection.fileCount > 0) { 1925 if (selection.directoryCount == 0 && selection.fileCount > 0) {
1920 // Only files, not directories, are supported for external tasks. 1926 // Only files, not directories, are supported for external tasks.
1921 chrome.fileBrowserPrivate.getFileTasks( 1927 chrome.fileBrowserPrivate.getFileTasks(
1922 selection.urls, 1928 selection.urls,
1923 this.onTasksFound_.bind(this, selection)); 1929 this.onTasksFound_.bind(this, selection));
1924 } else { 1930 } else {
1925 // There may be internal tasks for directories. 1931 // There may be internal tasks for directories.
1926 this.onTasksFound_(selection, []); 1932 this.onTasksFound_(selection, []);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2062 this.metadataProvider_ = new TestAwareMetadataProvider(); 2068 this.metadataProvider_ = new TestAwareMetadataProvider();
2063 }; 2069 };
2064 2070
2065 /** 2071 /**
2066 * Callback called when tasks for selected files are determined. 2072 * Callback called when tasks for selected files are determined.
2067 * @param {Object} selection Selection is passed here, since this.selection 2073 * @param {Object} selection Selection is passed here, since this.selection
2068 * can change before tasks were found, and we should be accurate. 2074 * can change before tasks were found, and we should be accurate.
2069 * @param {Array.<Task>} tasksList The tasks list. 2075 * @param {Array.<Task>} tasksList The tasks list.
2070 */ 2076 */
2071 FileManager.prototype.onTasksFound_ = function(selection, tasksList) { 2077 FileManager.prototype.onTasksFound_ = function(selection, tasksList) {
2072 this.taskButtons_.innerHTML = ''; 2078 removeChildren(this.taskButtons_);
2073 2079
2074 for (var i = 0; i < tasksList.length; i++) { 2080 for (var i = 0; i < tasksList.length; i++) {
2075 var task = tasksList[i]; 2081 var task = tasksList[i];
2076 2082
2077 // Tweak images, titles of internal tasks. 2083 // Tweak images, titles of internal tasks.
2078 var task_parts = task.taskId.split('|'); 2084 var task_parts = task.taskId.split('|');
2079 if (task_parts[0] == this.getExtensionId_()) { 2085 if (task_parts[0] == this.getExtensionId_()) {
2080 task.internal = true; 2086 task.internal = true;
2081 if (task_parts[1] == 'preview') { 2087 if (task_parts[1] == 'preview') {
2082 // TODO(serya): This hack needed until task.iconUrl get working 2088 // TODO(serya): This hack needed until task.iconUrl get working
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 galleryFrame.src = 'js/image_editor/gallery.html'; 2388 galleryFrame.src = 'js/image_editor/gallery.html';
2383 this.dialogDom_.appendChild(galleryFrame); 2389 this.dialogDom_.appendChild(galleryFrame);
2384 galleryFrame.focus(); 2390 galleryFrame.focus();
2385 }; 2391 };
2386 2392
2387 /** 2393 /**
2388 * Update the breadcrumb display to reflect the current directory. 2394 * Update the breadcrumb display to reflect the current directory.
2389 */ 2395 */
2390 FileManager.prototype.updateBreadcrumbs_ = function() { 2396 FileManager.prototype.updateBreadcrumbs_ = function() {
2391 var bc = this.dialogDom_.querySelector('.breadcrumbs'); 2397 var bc = this.dialogDom_.querySelector('.breadcrumbs');
2392 bc.innerHTML = ''; 2398 removeChildren(bc);
2393 2399
2394 var fullPath = this.currentDirEntry_.fullPath.replace(/\/$/, ''); 2400 var fullPath = this.currentDirEntry_.fullPath.replace(/\/$/, '');
2395 var pathNames = fullPath.split('/'); 2401 var pathNames = fullPath.split('/');
2396 var path = ''; 2402 var path = '';
2397 2403
2398 for (var i = 0; i < pathNames.length; i++) { 2404 for (var i = 0; i < pathNames.length; i++) {
2399 var pathName = pathNames[i]; 2405 var pathName = pathNames[i];
2400 path += pathName + '/'; 2406 path += pathName + '/';
2401 2407
2402 var div = this.document_.createElement('div'); 2408 var div = this.document_.createElement('div');
(...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after
3926 }); 3932 });
3927 }, onError); 3933 }, onError);
3928 3934
3929 function onError(err) { 3935 function onError(err) {
3930 console.log('Error while checking free space: ' + err); 3936 console.log('Error while checking free space: ' + err);
3931 setTimeout(doCheck, 1000 * 60); 3937 setTimeout(doCheck, 1000 * 60);
3932 } 3938 }
3933 } 3939 }
3934 } 3940 }
3935 })(); 3941 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/image_editor/gallery.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698