| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_FILE_CHOOSER_IMPL_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_FILE_CHOOSER_IMPL_H_ |
| 6 #define WEBKIT_PLUGINS_PPAPI_PPB_FILE_CHOOSER_IMPL_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PPB_FILE_CHOOSER_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "ppapi/c/dev/ppb_file_chooser_dev.h" | 13 #include "ppapi/c/dev/ppb_file_chooser_dev.h" |
| 14 #include "ppapi/shared_impl/array_writer.h" |
| 14 #include "ppapi/shared_impl/resource.h" | 15 #include "ppapi/shared_impl/resource.h" |
| 15 #include "ppapi/thunk/ppb_file_chooser_api.h" | 16 #include "ppapi/thunk/ppb_file_chooser_api.h" |
| 16 #include "webkit/plugins/webkit_plugins_export.h" | 17 #include "webkit/plugins/webkit_plugins_export.h" |
| 17 | 18 |
| 18 struct PP_CompletionCallback; | 19 struct PP_CompletionCallback; |
| 19 | 20 |
| 20 namespace ppapi { | 21 namespace ppapi { |
| 21 class TrackedCallback; | 22 class TrackedCallback; |
| 22 } | 23 } |
| 23 | 24 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // |PP_ERROR_...| to be returned to the plugin. | 57 // |PP_ERROR_...| to be returned to the plugin. |
| 57 int32_t ValidateCallback(const PP_CompletionCallback& callback); | 58 int32_t ValidateCallback(const PP_CompletionCallback& callback); |
| 58 | 59 |
| 59 // Sets up |callback| as the pending callback. This should only be called once | 60 // Sets up |callback| as the pending callback. This should only be called once |
| 60 // it is certain that |PP_OK_COMPLETIONPENDING| will be returned. | 61 // it is certain that |PP_OK_COMPLETIONPENDING| will be returned. |
| 61 void RegisterCallback(const PP_CompletionCallback& callback); | 62 void RegisterCallback(const PP_CompletionCallback& callback); |
| 62 | 63 |
| 63 void RunCallback(int32_t result); | 64 void RunCallback(int32_t result); |
| 64 | 65 |
| 65 // PPB_FileChooser_API implementation. | 66 // PPB_FileChooser_API implementation. |
| 66 virtual int32_t Show(const PP_CompletionCallback& callback) OVERRIDE; | 67 virtual int32_t Show(const PP_ArrayOutput& output, |
| 68 const PP_CompletionCallback& callback) OVERRIDE; |
| 69 virtual int32_t ShowWithoutUserGesture( |
| 70 PP_Bool save_as, |
| 71 PP_Var suggested_file_name, |
| 72 const PP_ArrayOutput& output, |
| 73 const PP_CompletionCallback& callback); |
| 74 virtual int32_t Show0_5(const PP_CompletionCallback& callback) OVERRIDE; |
| 67 virtual PP_Resource GetNextChosenFile() OVERRIDE; | 75 virtual PP_Resource GetNextChosenFile() OVERRIDE; |
| 68 | 76 virtual int32_t ShowWithoutUserGesture0_5( |
| 69 virtual int32_t ShowWithoutUserGesture( | 77 PP_Bool save_as, |
| 70 bool save_as, | 78 PP_Var suggested_file_name, |
| 71 const char* suggested_file_name, | |
| 72 const PP_CompletionCallback& callback) OVERRIDE; | 79 const PP_CompletionCallback& callback) OVERRIDE; |
| 73 | 80 |
| 74 // Splits a comma-separated MIME type list |accept_mime_types|, trims the | 81 // Splits a comma-separated MIME type list |accept_mime_types|, trims the |
| 75 // resultant split types, makes them lowercase, and returns them. | 82 // resultant split types, makes them lowercase, and returns them. |
| 76 // Though this should be private, this is public for testing. | 83 // Though this should be private, this is public for testing. |
| 77 WEBKIT_PLUGINS_EXPORT static std::vector<WebKit::WebString> ParseAcceptValue( | 84 WEBKIT_PLUGINS_EXPORT static std::vector<WebKit::WebString> ParseAcceptValue( |
| 78 const std::string& accept_mime_types); | 85 const std::string& accept_mime_types); |
| 79 | 86 |
| 80 private: | 87 private: |
| 81 PP_FileChooserMode_Dev mode_; | 88 PP_FileChooserMode_Dev mode_; |
| 82 std::string accept_mime_types_; | 89 std::string accept_mime_types_; |
| 83 scoped_refptr< ::ppapi::TrackedCallback> callback_; | 90 scoped_refptr< ::ppapi::TrackedCallback> callback_; |
| 84 std::vector< scoped_refptr<PPB_FileRef_Impl> > chosen_files_; | 91 |
| 92 // When using the v0.6 of the API, this will contain the output for the |
| 93 // resources when the show command is complete. When using 0.5, this |
| 94 // object will be is_null() and the chosen_files_ will be used instead. |
| 95 ::ppapi::ArrayWriter output_; |
| 96 |
| 97 // Used to store and iterate over the results when using 0.5 of the API. |
| 98 // These are valid when we get a file result and output_ is not null. |
| 99 std::vector< scoped_refptr<Resource> > chosen_files_; |
| 85 size_t next_chosen_file_index_; | 100 size_t next_chosen_file_index_; |
| 86 }; | 101 }; |
| 87 | 102 |
| 88 } // namespace ppapi | 103 } // namespace ppapi |
| 89 } // namespace webkit | 104 } // namespace webkit |
| 90 | 105 |
| 91 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_CHOOSER_IMPL_H_ | 106 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_CHOOSER_IMPL_H_ |
| OLD | NEW |