OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "content/renderer/pepper/pepper_file_chooser_host.h" | 5 #include "content/renderer/pepper/pepper_file_chooser_host.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "content/public/renderer/renderer_ppapi_host.h" | 9 #include "content/public/renderer/renderer_ppapi_host.h" |
10 #include "content/renderer/render_view_impl.h" | 10 #include "content/renderer/render_view_impl.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 : public WebKit::WebFileChooserCompletion { | 26 : public WebKit::WebFileChooserCompletion { |
27 public: | 27 public: |
28 CompletionHandler(const base::WeakPtr<PepperFileChooserHost>& host) | 28 CompletionHandler(const base::WeakPtr<PepperFileChooserHost>& host) |
29 : host_(host) { | 29 : host_(host) { |
30 } | 30 } |
31 | 31 |
32 virtual ~CompletionHandler() {} | 32 virtual ~CompletionHandler() {} |
33 | 33 |
34 virtual void didChooseFile( | 34 virtual void didChooseFile( |
35 const WebKit::WebVector<WebKit::WebString>& file_names) { | 35 const WebKit::WebVector<WebKit::WebString>& file_names) { |
36 if (host_) { | 36 if (host_.get()) { |
37 std::vector<PepperFileChooserHost::ChosenFileInfo> files; | 37 std::vector<PepperFileChooserHost::ChosenFileInfo> files; |
38 for (size_t i = 0; i < file_names.size(); i++) { | 38 for (size_t i = 0; i < file_names.size(); i++) { |
39 files.push_back(PepperFileChooserHost::ChosenFileInfo( | 39 files.push_back(PepperFileChooserHost::ChosenFileInfo( |
40 file_names[i].utf8(), std::string())); | 40 file_names[i].utf8(), std::string())); |
41 } | 41 } |
42 host_->StoreChosenFiles(files); | 42 host_->StoreChosenFiles(files); |
43 } | 43 } |
44 | 44 |
45 // It is the responsibility of this method to delete the instance. | 45 // It is the responsibility of this method to delete the instance. |
46 delete this; | 46 delete this; |
47 } | 47 } |
48 virtual void didChooseFile( | 48 virtual void didChooseFile( |
49 const WebKit::WebVector<SelectedFileInfo>& file_names) { | 49 const WebKit::WebVector<SelectedFileInfo>& file_names) { |
50 if (host_) { | 50 if (host_.get()) { |
51 std::vector<PepperFileChooserHost::ChosenFileInfo> files; | 51 std::vector<PepperFileChooserHost::ChosenFileInfo> files; |
52 for (size_t i = 0; i < file_names.size(); i++) { | 52 for (size_t i = 0; i < file_names.size(); i++) { |
53 files.push_back(PepperFileChooserHost::ChosenFileInfo( | 53 files.push_back(PepperFileChooserHost::ChosenFileInfo( |
54 file_names[i].path.utf8(), | 54 file_names[i].path.utf8(), |
55 file_names[i].displayName.utf8())); | 55 file_names[i].displayName.utf8())); |
56 } | 56 } |
57 host_->StoreChosenFiles(files); | 57 host_->StoreChosenFiles(files); |
58 } | 58 } |
59 | 59 |
60 // It is the responsibility of this method to delete the instance. | 60 // It is the responsibility of this method to delete the instance. |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 handler_ = NULL; | 163 handler_ = NULL; |
164 return PP_ERROR_NOACCESS; | 164 return PP_ERROR_NOACCESS; |
165 } | 165 } |
166 | 166 |
167 reply_context_ = context->MakeReplyMessageContext(); | 167 reply_context_ = context->MakeReplyMessageContext(); |
168 return PP_OK_COMPLETIONPENDING; | 168 return PP_OK_COMPLETIONPENDING; |
169 } | 169 } |
170 | 170 |
171 } // namespace content | 171 } // namespace content |
172 | 172 |
OLD | NEW |