Android NTP: Most visited tile clicks should have PageTransition.AUTO_BOOKMARK
[chromium-blink-merge.git] / ppapi / proxy / file_chooser_resource.h
blob0347fb07339008fa8ec2328dd788d1f0ec64d352
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PPAPI_PROXY_FILE_CHOOSER_RESOURCE_H_
6 #define PPAPI_PROXY_FILE_CHOOSER_RESOURCE_H_
8 #include <queue>
9 #include <string>
10 #include <vector>
12 #include "ppapi/proxy/plugin_resource.h"
13 #include "ppapi/proxy/ppapi_proxy_export.h"
14 #include "ppapi/shared_impl/array_writer.h"
15 #include "ppapi/shared_impl/tracked_callback.h"
16 #include "ppapi/thunk/ppb_file_chooser_api.h"
18 namespace ppapi {
20 struct FileRefCreateInfo;
22 namespace proxy {
24 class PPAPI_PROXY_EXPORT FileChooserResource
25 : public PluginResource,
26 public NON_EXPORTED_BASE(thunk::PPB_FileChooser_API) {
27 public:
28 FileChooserResource(Connection connection,
29 PP_Instance instance,
30 PP_FileChooserMode_Dev mode,
31 const std::string& accept_types);
32 ~FileChooserResource() override;
34 // Resource overrides.
35 thunk::PPB_FileChooser_API* AsPPB_FileChooser_API() override;
37 // PPB_FileChooser_API.
38 int32_t Show(const PP_ArrayOutput& output,
39 scoped_refptr<TrackedCallback> callback) override;
40 int32_t ShowWithoutUserGesture(
41 PP_Bool save_as,
42 PP_Var suggested_file_name,
43 const PP_ArrayOutput& output,
44 scoped_refptr<TrackedCallback> callback) override;
45 int32_t Show0_5(scoped_refptr<TrackedCallback> callback) override;
46 PP_Resource GetNextChosenFile() override;
47 int32_t ShowWithoutUserGesture0_5(
48 PP_Bool save_as,
49 PP_Var suggested_file_name,
50 scoped_refptr<TrackedCallback> callback) override;
52 // Parses the accept string into the given vector.
53 static void PopulateAcceptTypes(const std::string& input,
54 std::vector<std::string>* output);
56 private:
57 void OnPluginMsgShowReply(
58 const ResourceMessageReplyParams& params,
59 const std::vector<FileRefCreateInfo>& chosen_files);
61 int32_t ShowInternal(PP_Bool save_as,
62 const PP_Var& suggested_file_name,
63 scoped_refptr<TrackedCallback> callback);
65 PP_FileChooserMode_Dev mode_;
66 std::vector<std::string> accept_types_;
68 // When using v0.6 of the API, contains the array output info.
69 ArrayWriter output_;
71 // When using v0.5 of the API, contains all files returned by the current
72 // show callback that haven't yet been given to the plugin. The plugin will
73 // repeatedly call us to get the next file, and we'll vend those out of this
74 // queue, removing them when ownership has transferred to the plugin.
75 std::queue<PP_Resource> file_queue_;
77 scoped_refptr<TrackedCallback> callback_;
79 DISALLOW_COPY_AND_ASSIGN(FileChooserResource);
82 } // namespace proxy
83 } // namespace ppapi
85 #endif // PPAPI_PROXY_FILE_CHOOSER_RESOURCE_H_