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

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

Issue 12257002: [Cleanup] Files.app: Remove 'this' from class methods. #1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 var harness = { 5 var harness = {
6 /** 6 /**
7 * Kick off the test harness. 7 * Kick off the test harness.
8 * 8 *
9 * Called by harness.html after the dom has been parsed. 9 * Called by harness.html after the dom has been parsed.
10 */ 10 */
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 chrome.fileBrowserPrivate.FS_TYPE, 96 chrome.fileBrowserPrivate.FS_TYPE,
97 grantedBytes, 97 grantedBytes,
98 onFilesystem, 98 onFilesystem,
99 util.flog('Error initializing filesystem')); 99 util.flog('Error initializing filesystem'));
100 }, 100 },
101 util.flog('Error requesting filesystem quota')); 101 util.flog('Error requesting filesystem quota'));
102 }, 102 },
103 103
104 initPathControls: function() { 104 initPathControls: function() {
105 var paramstr = decodeURIComponent(document.location.search.substr(1)); 105 var paramstr = decodeURIComponent(document.location.search.substr(1));
106 this.params = paramstr ? JSON.parse(paramstr) : {}; 106 harness.params = paramstr ? JSON.parse(paramstr) : {};
107 107
108 var input = document.querySelector('#default-path'); 108 var input = document.querySelector('#default-path');
109 input.value = this.params.defaultPath || ''; 109 input.value = harness.params.defaultPath || '';
110 input.addEventListener('keyup', this.onInputKeyUp.bind(this)); 110 input.addEventListener('keyup', harness.onInputKeyUp);
111 }, 111 },
112 112
113 initListeners: function() { 113 initListeners: function() {
114 document.querySelector('input[type="file"]'). 114 document.querySelector('input[type="file"]').
115 addEventListener('change', this.onFilesChange.bind(this)); 115 addEventListener('change', harness.onFilesChange);
116 document.querySelector('button#reset'). 116 document.querySelector('button#reset').
117 addEventListener('click', this.onClearClick.bind(this)); 117 addEventListener('click', harness.onClearClick);
118 document.querySelector('button#populate'). 118 document.querySelector('button#populate').
119 addEventListener('click', this.onPopulateClick.bind(this)); 119 addEventListener('click', harness.onPopulateClick);
120 }, 120 },
121 121
122 onInputKeyUp: function(event) { 122 onInputKeyUp: function(event) {
123 if (event.keyCode != 13) 123 if (event.keyCode != 13)
124 return; 124 return;
125 125
126 this.changePath(); 126 harness.changePath();
127 }, 127 },
128 128
129 changePath: function() { 129 changePath: function() {
130 var input = document.querySelector('#default-path'); 130 var input = document.querySelector('#default-path');
131 this.changeParam('defaultPath', input.value); 131 harness.changeParam('defaultPath', input.value);
132 }, 132 },
133 133
134 changeParam: function(name, value) { 134 changeParam: function(name, value) {
135 this.params[name] = value; 135 harness.params[name] = value;
136 document.location.href = '?' + JSON.stringify(this.params); 136 document.location.href = '?' + JSON.stringify(harness.params);
137 }, 137 },
138 138
139 /** 139 /**
140 * 'Reset Filesystem' button click handler. 140 * 'Reset Filesystem' button click handler.
141 */ 141 */
142 onClearClick: function() { 142 onClearClick: function() {
143 harness.resetFilesystem(this.filesystem, harness.initFileSystem); 143 harness.resetFilesystem(harness.filesystem, harness.initFileSystem);
144 }, 144 },
145 145
146 resetFilesystem: function(filesystem, opt_callback) { 146 resetFilesystem: function(filesystem, opt_callback) {
147 util.forEachDirEntry(filesystem.root, function(dirEntry) { 147 util.forEachDirEntry(filesystem.root, function(dirEntry) {
148 if (!dirEntry) { 148 if (!dirEntry) {
149 console.log('Filesystem reset.'); 149 console.log('Filesystem reset.');
150 if (opt_callback) opt_callback(); 150 if (opt_callback) opt_callback();
151 return; 151 return;
152 } 152 }
153 util.removeFileOrDirectory( 153 util.removeFileOrDirectory(
154 dirEntry, 154 dirEntry,
155 util.flog('Removed ' + dirEntry.name), 155 util.flog('Removed ' + dirEntry.name),
156 util.flog('Error deleting ' + dirEntry.name)); 156 util.flog('Error deleting ' + dirEntry.name));
157 }); 157 });
158 }, 158 },
159 159
160 /** 160 /**
161 * 'Auto-populate' button click handler. 161 * 'Auto-populate' button click handler.
162 */ 162 */
163 onPopulateClick: function() { 163 onPopulateClick: function() {
164 harness.importWebDirectory(this.filesystem, 164 harness.importWebDirectory(harness.filesystem,
165 'Downloads', 'harness_files', function() {}, harness.refreshDirectory); 165 'Downloads', 'harness_files', function() {}, harness.refreshDirectory);
166 }, 166 },
167 167
168 /** 168 /**
169 * Change handler for the 'input type=file' element. 169 * Change handler for the 'input type=file' element.
170 */ 170 */
171 onFilesChange: function(event) { 171 onFilesChange: function(event) {
172 this.importFiles(harness.filesystem, 172 harness.importFiles(harness.filesystem,
173 harness.fileManager.getCurrentDirectory(), 173 harness.fileManager.getCurrentDirectory(),
174 [].slice.call(event.target.files), 174 [].slice.call(event.target.files),
175 harness.refreshDirectory.bind(harness)); 175 harness.refreshDirectory.bind(harness));
176 }, 176 },
177 177
178 /** 178 /**
179 * Force the file manager to refresh the current directory. 179 * Force the file manager to refresh the current directory.
180 */ 180 */
181 refreshDirectory: function() { 181 refreshDirectory: function() {
182 harness.chrome.fileBrowserPrivate.onDirectoryChanged.notify({ 182 harness.chrome.fileBrowserPrivate.onDirectoryChanged.notify({
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 childNames.push(links[i].match(/href="(.*)"/)[1]); 317 childNames.push(links[i].match(/href="(.*)"/)[1]);
318 } 318 }
319 console.log( 319 console.log(
320 'Importing ' + childNames.length + ' entries from ' + srcDirUrl); 320 'Importing ' + childNames.length + ' entries from ' + srcDirUrl);
321 processNextChild(); 321 processNextChild();
322 }); 322 });
323 } 323 }
324 }; 324 };
325 325
326 document.addEventListener('DOMContentLoaded', harness.init.bind(harness)); 326 document.addEventListener('DOMContentLoaded', harness.init.bind(harness));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698