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

Unified Diff: chrome/browser/resources/file_manager/js/directory_model.js

Issue 10198010: [filemanager] Open Downloads by default (instead of removable device). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Description. Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/file_manager.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/file_manager/js/directory_model.js
===================================================================
--- chrome/browser/resources/file_manager/js/directory_model.js (revision 133663)
+++ chrome/browser/resources/file_manager/js/directory_model.js (working copy)
@@ -807,7 +807,7 @@
var onBaseError = function(err) {
console.log('Unexpected error resolving default base "' +
baseName + '": ' + err);
- if (path != '/' + DirectoryModel.DOWNLOADS_DIRECTORY) {
+ if (path != this.getDefaultDirectory()) {
// Can't find the provided path, let's go to default one instead.
resolveCallback(!EXISTS);
if (!overridden)
@@ -832,51 +832,23 @@
}.bind(this);
var root = this.root_;
- if (baseName) {
- root.getDirectory(
- baseName, {create: false}, onBaseFound, onBaseError);
- } else {
- this.getDefaultDirectory_(function(defaultDir) {
- baseName = defaultDir;
- root.getDirectory(
- baseName, {create: false}, onBaseFound, onBaseError);
- });
- }
+ if (!baseName)
+ baseName = this.getDefaultDirectory();
+ root.getDirectory(baseName, {create: false}, onBaseFound, onBaseError);
};
/**
* @param {function} opt_callback Callback on done.
*/
DirectoryModel.prototype.setupDefaultPath = function(opt_callback) {
- var overridden = false;
- function onExternalDirChange() {
- overridden = true;
- }
- this.addEventListener('directory-changed', onExternalDirChange);
-
- this.getDefaultDirectory_(function(path) {
- this.removeEventListener('directory-changed', onExternalDirChange);
- if (!overridden)
- this.setupPath(path, opt_callback);
- }.bind(this));
+ this.setupPath(this.getDefaultDirectory(), opt_callback);
};
/**
- * @private
- * @param {function(string)} callback Called with the path to directory.
+ * @return {string} The default directory.
*/
-DirectoryModel.prototype.getDefaultDirectory_ = function(callback) {
- function onGetDirectoryComplete(entries, error) {
- if (entries.length > 0)
- callback(entries[0].fullPath);
- else
- callback('/' + DirectoryModel.DOWNLOADS_DIRECTORY);
- }
-
- // No preset given, find a good place to start.
- // Check for removable devices, if there are none, go to Downloads.
- util.readDirectory(this.root_, DirectoryModel.REMOVABLE_DIRECTORY,
- onGetDirectoryComplete);
+DirectoryModel.prototype.getDefaultDirectory = function() {
+ return '/' + DirectoryModel.DOWNLOADS_DIRECTORY;
};
/**
@@ -1067,8 +1039,8 @@
* @private
*/
DirectoryModel.prototype.updateRootsListSelection_ = function() {
- this.rootsListSelection_.selectedIndex =
- this.findRootsListItem_(this.rootPath);
+ var rootPath = DirectoryModel.getRootPath(this.currentDirEntry_.fullPath);
+ this.rootsListSelection_.selectedIndex = this.findRootsListItem_(rootPath);
};
/**
@@ -1140,7 +1112,7 @@
if (rootPath == this.rootPath) {
// TODO(kaznacheev): Consider changing to the most recently used root.
- this.changeDirectory('/' + DirectoryModel.DOWNLOADS_DIRECTORY);
+ this.changeDirectory(this.getDefaultDirectory());
}
};
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/file_manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698