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

Unified Diff: chrome/browser/resources/file_manager/js/image_editor/gallery.js

Issue 8818020: Fixed the editing of previously edited files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/file_manager/js/image_editor/gallery.js
diff --git a/chrome/browser/resources/file_manager/js/image_editor/gallery.js b/chrome/browser/resources/file_manager/js/image_editor/gallery.js
index 7a7e21945a89aa98212a1e21cbae9e8532b9c9cd..ce674f2a858f4b4253dac68b1ec7587d8aacf0dd 100644
--- a/chrome/browser/resources/file_manager/js/image_editor/gallery.js
+++ b/chrome/browser/resources/file_manager/js/image_editor/gallery.js
@@ -873,25 +873,26 @@ Ribbon.Item.prototype.createCopyName_ = function () {
name = name.substr(0, index);
}
- if (name.indexOf(Ribbon.Item.COPY_SIGNATURE) == 0) {
- // TODO(dgozman): add a number to form 'Copy (X) of File.jpg'.
- name = name.substr(Ribbon.Item.COPY_SIGNATURE.length);
+ var regExpCopyN =
+ new RegExp('^' + Ribbon.Item.COPY_SIGNATURE + '(.+) \\((\\d+)\\)$');
dgozman 2011/12/07 06:02:09 You can extract regExp constants and place them ne
Vladislav Kaznacheev 2011/12/07 13:11:14 Done.
+ var match = regExpCopyN.exec(name);
+ if (match && match[1] && match[2]) {
+ var copyNumber = parseInt(match[2], 10) + 1;
+ name = match[1] + ' (' + copyNumber + ')';
+ } else {
+ var regExpCopy0 =
+ new RegExp('^' + Ribbon.Item.COPY_SIGNATURE + '(.+)$');
+ match = regExpCopy0.exec(name);
+ if (match && match[1]) {
+ name = match[1] + ' (1)';
+ }
}
var mimeType = this.metadata_.mimeType.toLowerCase();
if (mimeType != 'image/jpeg') {
// Chrome can natively encode only two formats: JPEG and PNG.
// All non-JPEG images are saved in PNG, hence forcing the file extension.
- if (mimeType == 'image/png') {
- ext = '.png';
- } else {
- // All non-JPEG images get 'image/png' mimeType (see
- // ImageEncoder.MetadataEncoder constructor).
- // This code can be reached only if someone has added a metadata parser
- // for a format other than JPEG or PNG. The message below is to remind
- // that one must also come up with the way to encode the image data.
- console.error('Image encoding for ' + mimeType + ' is not supported');
- }
+ ext = '.png';
}
return Ribbon.Item.COPY_SIGNATURE + name + ext;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698