Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / renderer / pepper / pepper_file_chooser_host.h
blob4ae861a16607bc75f37c1edc771e28f00a5f5603
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 CONTENT_RENDERER_PEPPER_PEPPER_FILE_CHOOSER_HOST_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_FILE_CHOOSER_HOST_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/memory/weak_ptr.h"
13 #include "content/common/content_export.h"
14 #include "ppapi/host/host_message_context.h"
15 #include "ppapi/host/resource_host.h"
16 #include "ppapi/proxy/resource_message_params.h"
18 namespace ppapi {
19 struct FileRefCreateInfo;
22 namespace content {
24 class RendererPpapiHost;
25 class RenderViewImpl;
27 class CONTENT_EXPORT PepperFileChooserHost
28 : public ppapi::host::ResourceHost,
29 public base::SupportsWeakPtr<PepperFileChooserHost> {
30 public:
31 // Structure to store the information about chosen files.
32 struct ChosenFileInfo {
33 ChosenFileInfo(const std::string& path, const std::string& display_name);
34 std::string path;
35 std::string display_name; // May be empty.
38 PepperFileChooserHost(RendererPpapiHost* host,
39 PP_Instance instance,
40 PP_Resource resource);
41 ~PepperFileChooserHost() override;
43 int32_t OnResourceMessageReceived(
44 const IPC::Message& msg,
45 ppapi::host::HostMessageContext* context) override;
47 void StoreChosenFiles(const std::vector<ChosenFileInfo>& files);
49 private:
50 class CompletionHandler;
52 int32_t OnShow(ppapi::host::HostMessageContext* context,
53 bool save_as,
54 bool open_multiple,
55 const std::string& suggested_file_name,
56 const std::vector<std::string>& accept_mime_types);
58 void DidCreateResourceHosts(const std::vector<base::FilePath>& file_paths,
59 const std::vector<std::string>& display_names,
60 const std::vector<int>& browser_ids);
62 // Non-owning pointer.
63 RendererPpapiHost* renderer_ppapi_host_;
65 ppapi::host::ReplyMessageContext reply_context_;
66 CompletionHandler* handler_;
68 base::WeakPtrFactory<PepperFileChooserHost> weak_factory_;
70 DISALLOW_COPY_AND_ASSIGN(PepperFileChooserHost);
73 } // namespace content
75 #endif // CONTENT_RENDERER_PEPPER_PEPPER_FILE_CHOOSER_HOST_H_