OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/glue/plugins/pepper_file_chooser.h" | 5 #include "webkit/glue/plugins/pepper_file_chooser.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "third_party/ppapi/c/pp_completion_callback.h" | 8 #include "third_party/ppapi/c/pp_completion_callback.h" |
9 #include "third_party/ppapi/c/pp_errors.h" | 9 #include "third_party/ppapi/c/pp_errors.h" |
10 #include "webkit/glue/plugins/pepper_file_ref.h" | 10 #include "webkit/glue/plugins/pepper_file_ref.h" |
11 #include "webkit/glue/plugins/pepper_plugin_instance.h" | 11 #include "webkit/glue/plugins/pepper_plugin_instance.h" |
12 #include "webkit/glue/plugins/pepper_resource_tracker.h" | 12 #include "webkit/glue/plugins/pepper_resource_tracker.h" |
13 | 13 |
14 namespace pepper { | 14 namespace pepper { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 PP_Resource Create(PP_Instance instance_id, | 18 PP_Resource Create(PP_Instance instance_id, |
19 const PP_FileChooserOptions* options) { | 19 const PP_FileChooserOptions* options) { |
20 PluginInstance* instance = PluginInstance::FromPPInstance(instance_id); | 20 PluginInstance* instance = PluginInstance::FromPPInstance(instance_id); |
21 if (!instance) | 21 if (!instance) |
22 return 0; | 22 return 0; |
23 | 23 |
24 FileChooser* chooser = new FileChooser(instance, options); | 24 FileChooser* chooser = new FileChooser(instance, options); |
25 chooser->AddRef(); // AddRef for the caller. | 25 chooser->AddRef(); // AddRef for the caller. |
26 return chooser->GetResource(); | 26 return chooser->GetResource(); |
27 } | 27 } |
28 | 28 |
29 bool IsFileChooser(PP_Resource resource) { | 29 bool IsFileChooser(PP_Resource resource) { |
30 return !!ResourceTracker::Get()->GetAsFileChooser(resource).get(); | 30 return !!Resource::GetAs<FileChooser>(resource).get(); |
31 } | 31 } |
32 | 32 |
33 int32_t Show(PP_Resource chooser_id, PP_CompletionCallback callback) { | 33 int32_t Show(PP_Resource chooser_id, PP_CompletionCallback callback) { |
34 scoped_refptr<FileChooser> chooser( | 34 scoped_refptr<FileChooser> chooser( |
35 ResourceTracker::Get()->GetAsFileChooser(chooser_id).get()); | 35 Resource::GetAs<FileChooser>(chooser_id).get()); |
36 if (!chooser.get()) | 36 if (!chooser.get()) |
37 return PP_Error_BadResource; | 37 return PP_Error_BadResource; |
38 | 38 |
39 return chooser->Show(callback); | 39 return chooser->Show(callback); |
40 } | 40 } |
41 | 41 |
42 PP_Resource GetNextChosenFile(PP_Resource chooser_id) { | 42 PP_Resource GetNextChosenFile(PP_Resource chooser_id) { |
43 scoped_refptr<FileChooser> chooser( | 43 scoped_refptr<FileChooser> chooser( |
44 ResourceTracker::Get()->GetAsFileChooser(chooser_id).get()); | 44 Resource::GetAs<FileChooser>(chooser_id).get()); |
45 if (!chooser.get()) | 45 if (!chooser.get()) |
46 return 0; | 46 return 0; |
47 | 47 |
48 scoped_refptr<FileRef> file_ref(chooser->GetNextChosenFile()); | 48 scoped_refptr<FileRef> file_ref(chooser->GetNextChosenFile()); |
49 if (!file_ref.get()) | 49 if (!file_ref.get()) |
50 return 0; | 50 return 0; |
51 file_ref->AddRef(); // AddRef for the caller. | 51 file_ref->AddRef(); // AddRef for the caller. |
52 | 52 |
53 return file_ref->GetResource(); | 53 return file_ref->GetResource(); |
54 } | 54 } |
(...skipping 26 matching lines...) Expand all Loading... |
81 NOTIMPLEMENTED(); // TODO(darin): Implement me! | 81 NOTIMPLEMENTED(); // TODO(darin): Implement me! |
82 return PP_Error_Failed; | 82 return PP_Error_Failed; |
83 } | 83 } |
84 | 84 |
85 scoped_refptr<FileRef> FileChooser::GetNextChosenFile() { | 85 scoped_refptr<FileRef> FileChooser::GetNextChosenFile() { |
86 NOTIMPLEMENTED(); // TODO(darin): Implement me! | 86 NOTIMPLEMENTED(); // TODO(darin): Implement me! |
87 return NULL; | 87 return NULL; |
88 } | 88 } |
89 | 89 |
90 } // namespace pepper | 90 } // namespace pepper |
OLD | NEW |