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

Unified Diff: ui/file_manager/file_manager/foreground/js/naming_controller.js

Issue 693503002: Files.app: Make NamingControll class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: try Created 6 years, 2 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 | « ui/file_manager/file_manager/foreground/js/main_scripts.js ('k') | ui/file_manager/file_manager/main.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/foreground/js/naming_controller.js
diff --git a/ui/file_manager/file_manager/foreground/js/naming_controller.js b/ui/file_manager/file_manager/foreground/js/naming_controller.js
new file mode 100644
index 0000000000000000000000000000000000000000..3833a0736625735d201d5009f5d41ccff35efd09
--- /dev/null
+++ b/ui/file_manager/file_manager/foreground/js/naming_controller.js
@@ -0,0 +1,52 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * Controller to handle naming.
+ *
+ * @param {!FileFilter} fileFilter
+ * @param {!cr.ui.dialogs.AlertDialog} alertDialog
+ * @constructor
+ * @struct
+ */
+function NamingController(fileFilter, alertDialog) {
+ /**
+ * File filter.
+ * @type {!FileFilter}
+ * @const
+ * @private
+ */
+ this.fileFilter_ = fileFilter;
+
+ /**
+ * Alert dialog.
+ * @type {!cr.ui.dialogs.AlertDialog}
+ * @const
+ * @private
+ */
+ this.alertDialog_ = alertDialog;
+}
+
+/**
+ * Verifies the user entered name for file or folder to be created or
+ * renamed to. See also util.validateFileName.
+ *
+ * @param {DirectoryEntry} parentEntry The URL of the parent directory entry.
+ * @param {string} name New file or folder name.
+ * @param {function(boolean)} onDone Function to invoke when user closes the
+ * warning box or immediatelly if file name is correct. If the name was
+ * valid it is passed true, and false otherwise.
+ */
+NamingController.prototype.validateFileName = function(
+ parentEntry, name, onDone) {
+ var fileNameErrorPromise = util.validateFileName(
+ parentEntry,
+ name,
+ this.fileFilter_.isFilterHiddenOn());
+ fileNameErrorPromise.then(onDone.bind(null, true), function(message) {
+ this.alertDialog_.show(message, onDone.bind(null, false));
+ }.bind(this)).catch(function(error) {
+ console.error(error.stack || error);
+ });
+};
« no previous file with comments | « ui/file_manager/file_manager/foreground/js/main_scripts.js ('k') | ui/file_manager/file_manager/main.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698