| 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 #include "webkit/plugins/ppapi/ppb_file_chooser_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_file_chooser_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 PPB_FileChooser_Impl::~PPB_FileChooser_Impl() { | 73 PPB_FileChooser_Impl::~PPB_FileChooser_Impl() { |
| 74 } | 74 } |
| 75 | 75 |
| 76 // static | 76 // static |
| 77 PP_Resource PPB_FileChooser_Impl::Create( | 77 PP_Resource PPB_FileChooser_Impl::Create( |
| 78 PluginInstance* instance, | 78 PluginInstance* instance, |
| 79 const PP_FileChooserOptions_Dev* options) { | 79 const PP_FileChooserOptions_Dev* options) { |
| 80 if ((options->mode != PP_FILECHOOSERMODE_OPEN) && | 80 if ((options->mode != PP_FILECHOOSERMODE_OPEN) && |
| 81 (options->mode != PP_FILECHOOSERMODE_OPENMULTIPLE)) | 81 (options->mode != PP_FILECHOOSERMODE_OPENMULTIPLE)) |
| 82 return 0; | 82 return 0; |
| 83 | 83 return (new PPB_FileChooser_Impl(instance, options))->GetReference(); |
| 84 PPB_FileChooser_Impl* chooser = new PPB_FileChooser_Impl(instance, options); | |
| 85 return chooser->GetReference(); | |
| 86 } | 84 } |
| 87 | 85 |
| 88 PPB_FileChooser_Impl* PPB_FileChooser_Impl::AsPPB_FileChooser_Impl() { | 86 PPB_FileChooser_Impl* PPB_FileChooser_Impl::AsPPB_FileChooser_Impl() { |
| 89 return this; | 87 return this; |
| 90 } | 88 } |
| 91 | 89 |
| 92 PPB_FileChooser_API* PPB_FileChooser_Impl::AsPPB_FileChooser_API() { | 90 PPB_FileChooser_API* PPB_FileChooser_Impl::AsPPB_FileChooser_API() { |
| 93 return this; | 91 return this; |
| 94 } | 92 } |
| 95 | 93 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 122 return PP_ERROR_INPROGRESS; | 120 return PP_ERROR_INPROGRESS; |
| 123 | 121 |
| 124 return PP_OK; | 122 return PP_OK; |
| 125 } | 123 } |
| 126 | 124 |
| 127 void PPB_FileChooser_Impl::RegisterCallback( | 125 void PPB_FileChooser_Impl::RegisterCallback( |
| 128 const PP_CompletionCallback& callback) { | 126 const PP_CompletionCallback& callback) { |
| 129 DCHECK(callback.func); | 127 DCHECK(callback.func); |
| 130 DCHECK(!callback_.get() || callback_->completed()); | 128 DCHECK(!callback_.get() || callback_->completed()); |
| 131 | 129 |
| 132 PP_Resource resource_id = GetReferenceNoAddRef(); | |
| 133 CHECK(resource_id); | |
| 134 callback_ = new TrackedCompletionCallback( | 130 callback_ = new TrackedCompletionCallback( |
| 135 instance()->module()->GetCallbackTracker(), resource_id, callback); | 131 instance()->module()->GetCallbackTracker(), pp_resource(), callback); |
| 136 } | 132 } |
| 137 | 133 |
| 138 void PPB_FileChooser_Impl::RunCallback(int32_t result) { | 134 void PPB_FileChooser_Impl::RunCallback(int32_t result) { |
| 139 scoped_refptr<TrackedCompletionCallback> callback; | 135 scoped_refptr<TrackedCompletionCallback> callback; |
| 140 callback.swap(callback_); | 136 callback.swap(callback_); |
| 141 callback->Run(result); // Will complete abortively if necessary. | 137 callback->Run(result); // Will complete abortively if necessary. |
| 142 } | 138 } |
| 143 | 139 |
| 144 int32_t PPB_FileChooser_Impl::Show(PP_CompletionCallback callback) { | 140 int32_t PPB_FileChooser_Impl::Show(PP_CompletionCallback callback) { |
| 145 int32_t rv = ValidateCallback(callback); | 141 int32_t rv = ValidateCallback(callback); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 164 | 160 |
| 165 PP_Resource PPB_FileChooser_Impl::GetNextChosenFile() { | 161 PP_Resource PPB_FileChooser_Impl::GetNextChosenFile() { |
| 166 if (next_chosen_file_index_ >= chosen_files_.size()) | 162 if (next_chosen_file_index_ >= chosen_files_.size()) |
| 167 return 0; | 163 return 0; |
| 168 | 164 |
| 169 return chosen_files_[next_chosen_file_index_++]->GetReference(); | 165 return chosen_files_[next_chosen_file_index_++]->GetReference(); |
| 170 } | 166 } |
| 171 | 167 |
| 172 } // namespace ppapi | 168 } // namespace ppapi |
| 173 } // namespace webkit | 169 } // namespace webkit |
| OLD | NEW |