diff options
author | raymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-30 00:05:32 +0000 |
---|---|---|
committer | raymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-30 00:05:32 +0000 |
commit | f9a4c41a40dc781ea6bbbeeeb77ee3713dc168e2 (patch) | |
tree | 2f06565b8aaf35996d1ff3a553801f6d5aa29565 /ppapi/cpp | |
parent | 1e1184a4047adf5096a5597e4adf1ad07130445a (diff) | |
download | chromium_src-f9a4c41a40dc781ea6bbbeeeb77ee3713dc168e2.zip chromium_src-f9a4c41a40dc781ea6bbbeeeb77ee3713dc168e2.tar.gz chromium_src-f9a4c41a40dc781ea6bbbeeeb77ee3713dc168e2.tar.bz2 |
Modified the pepper file chooser API to support filtering files by extensions.
Previously you could filter only by MIME type. This adds support for filtering by specific extensions as well, e.g. .txt,.html. This change is aligned with the web platform which now allows filtering by file extension for <input> elements (http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#attr-input-accept).
This also changes the linux implementation of the file dialog (SelectFileDialogImplGTK). In the past, it would turn file extensions to filter into MIME types. However this is a bit silly because in FileSelectHelper we do the reverse (turn MIME types into a list of file extensions to filter by). It also prevents us from filtering by a specific extensions when this is really what is desired.
BUG=129251
TEST=
Review URL: https://chromiumcodereview.appspot.com/10414085
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139434 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp')
-rw-r--r-- | ppapi/cpp/dev/file_chooser_dev.cc | 8 | ||||
-rw-r--r-- | ppapi/cpp/dev/file_chooser_dev.h | 21 | ||||
-rw-r--r-- | ppapi/cpp/trusted/file_chooser_trusted.cc | 4 | ||||
-rw-r--r-- | ppapi/cpp/trusted/file_chooser_trusted.h | 2 |
4 files changed, 17 insertions, 18 deletions
diff --git a/ppapi/cpp/dev/file_chooser_dev.cc b/ppapi/cpp/dev/file_chooser_dev.cc index a773def..b7124a1 100644 --- a/ppapi/cpp/dev/file_chooser_dev.cc +++ b/ppapi/cpp/dev/file_chooser_dev.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -30,13 +30,13 @@ template <> const char* interface_name<PPB_FileChooser_Dev_0_6>() { FileChooser_Dev::FileChooser_Dev(const InstanceHandle& instance, PP_FileChooserMode_Dev mode, - const Var& accept_mime_types) { + const Var& accept_types) { if (has_interface<PPB_FileChooser_Dev_0_6>()) { PassRefFromConstructor(get_interface<PPB_FileChooser_Dev_0_6>()->Create( - instance.pp_instance(), mode, accept_mime_types.pp_var())); + instance.pp_instance(), mode, accept_types.pp_var())); } else if (has_interface<PPB_FileChooser_Dev_0_5>()) { PassRefFromConstructor(get_interface<PPB_FileChooser_Dev_0_5>()->Create( - instance.pp_instance(), mode, accept_mime_types.pp_var())); + instance.pp_instance(), mode, accept_types.pp_var())); } } diff --git a/ppapi/cpp/dev/file_chooser_dev.h b/ppapi/cpp/dev/file_chooser_dev.h index b588ac85..4feee6a 100644 --- a/ppapi/cpp/dev/file_chooser_dev.h +++ b/ppapi/cpp/dev/file_chooser_dev.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -36,19 +36,18 @@ class FileChooser_Dev : public Resource { /// In order to get the list of files in a directory, the /// PPB_DirectoryReader_Dev interface must be used. /// - /// @param accept_mime_types A comma-separated list of MIME types such as - /// "audio/ *,text/plain" (note there should be no space between the '/' and - /// the '*', but one is added to avoid confusing C++ comments). The dialog - /// may restrict selectable files to the specified MIME types. An empty string - /// or an undefined var may be given to indicate that all types should be + /// @param accept_types A comma-separated list of MIME types and file + /// extensions such as "audio/ *,text/plain,.html" (note there should be + /// no space between the '/' and the '*', but one is added to avoid confusing + /// C++ comments). The dialog may restrict selectable files to the specified + /// MIME types and file extensions. If a string in the comma-separated list + /// begins with a period (.) then the string is interpreted as a file + /// extension, otherwise it is interpreted as a MIME-type. An empty string or + /// an undefined var may be given to indicate that all types should be /// accepted. - /// - /// TODO(darin): What if the mime type is unknown to the system? The plugin - /// may wish to describe the mime type and provide a matching file extension. - /// It is more webby to use mime types here instead of file extensions. FileChooser_Dev(const InstanceHandle& instance, PP_FileChooserMode_Dev mode, - const Var& accept_mime_types); + const Var& accept_types); FileChooser_Dev(const FileChooser_Dev& other); diff --git a/ppapi/cpp/trusted/file_chooser_trusted.cc b/ppapi/cpp/trusted/file_chooser_trusted.cc index 92fec74..caa1b73 100644 --- a/ppapi/cpp/trusted/file_chooser_trusted.cc +++ b/ppapi/cpp/trusted/file_chooser_trusted.cc @@ -30,10 +30,10 @@ FileChooser_Trusted::FileChooser_Trusted() : save_as_(false) { FileChooser_Trusted::FileChooser_Trusted(const InstanceHandle& instance, PP_FileChooserMode_Dev mode, - const Var& accept_mime_types, + const Var& accept_types, bool save_as, const std::string& suggested_file_name) - : FileChooser_Dev(instance, mode, accept_mime_types), + : FileChooser_Dev(instance, mode, accept_types), save_as_(save_as), suggested_file_name_(suggested_file_name) { } diff --git a/ppapi/cpp/trusted/file_chooser_trusted.h b/ppapi/cpp/trusted/file_chooser_trusted.h index 6b3c1c1..cdb70b0 100644 --- a/ppapi/cpp/trusted/file_chooser_trusted.h +++ b/ppapi/cpp/trusted/file_chooser_trusted.h @@ -18,7 +18,7 @@ class FileChooser_Trusted : public FileChooser_Dev { FileChooser_Trusted(const InstanceHandle& instance, PP_FileChooserMode_Dev mode, - const Var& accept_mime_types, + const Var& accept_types, bool save_as, const std::string& suggested_file_name); |