• Trent Apted's avatar
    Automatically attach file extensions in the ChromeOS "Save As" dialog. · a1305df7
    Trent Apted authored
    The behaviour is similar to the file pickers on other platforms.
    
    When clicking "OK", a file extension is only added if:
     - A FileType filter is active that has a default extension (i.e.
         not the all files filter, or an extensionless filter), and
     - The user-provided filename does not already have an extension.
    
    The file picker already has logic for adding extensions, but it's only
    applied when changing the currently active filter in the UI (and only
    when the filename already has an extension that isn't *any* of the
    possible extensions for the current filter). Repurpose it.
    
    The approach taken updates the UI field when clicking close, so the user
    briefly sees the extension being added before the dialog dismisses.
    
    To keep logic & tests simple/robust it was necessary to ensure filters
    are applied in the dialog correctly when there is only one filter
    available, which regressed recently (https://crbug.com/1097448).
    
    Bug: 1082624, 1097448, 1097633
    Change-Id: I1488880be8c289853b864d4bea0e193beb5464ac
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2255918
    Commit-Queue: Trent Apted <tapted@chromium.org>
    Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
    Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#781157}
    a1305df7
launch.js 20 KB