| 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 "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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 return; | 140 return; |
| 141 | 141 |
| 142 callback_ = new TrackedCallback(this, callback); | 142 callback_ = new TrackedCallback(this, callback); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void PPB_FileChooser_Impl::RunCallback(int32_t result) { | 145 void PPB_FileChooser_Impl::RunCallback(int32_t result) { |
| 146 TrackedCallback::ClearAndRun(&callback_, result); | 146 TrackedCallback::ClearAndRun(&callback_, result); |
| 147 } | 147 } |
| 148 | 148 |
| 149 int32_t PPB_FileChooser_Impl::Show(const PP_CompletionCallback& callback) { | 149 int32_t PPB_FileChooser_Impl::Show(const PP_CompletionCallback& callback) { |
| 150 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); |
| 151 if (!plugin_instance) |
| 152 return PP_ERROR_FAILED; |
| 153 if (!plugin_instance->IsProcessingUserGesture()) |
| 154 return PP_ERROR_NO_USER_GESTURE; |
| 150 return ShowWithoutUserGesture(false, NULL, callback); | 155 return ShowWithoutUserGesture(false, NULL, callback); |
| 151 } | 156 } |
| 152 | 157 |
| 153 int32_t PPB_FileChooser_Impl::ShowWithoutUserGesture( | 158 int32_t PPB_FileChooser_Impl::ShowWithoutUserGesture( |
| 154 bool save_as, | 159 bool save_as, |
| 155 const char* suggested_file_name, | 160 const char* suggested_file_name, |
| 156 const PP_CompletionCallback& callback) { | 161 const PP_CompletionCallback& callback) { |
| 157 int32_t rv = ValidateCallback(callback); | 162 int32_t rv = ValidateCallback(callback); |
| 158 if (rv != PP_OK) | 163 if (rv != PP_OK) |
| 159 return rv; | 164 return rv; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 continue; | 213 continue; |
| 209 StringToLowerASCII(&mime_type); | 214 StringToLowerASCII(&mime_type); |
| 210 normalized_mime_type_list.push_back(WebString::fromUTF8(mime_type.data(), | 215 normalized_mime_type_list.push_back(WebString::fromUTF8(mime_type.data(), |
| 211 mime_type.size())); | 216 mime_type.size())); |
| 212 } | 217 } |
| 213 return normalized_mime_type_list; | 218 return normalized_mime_type_list; |
| 214 } | 219 } |
| 215 | 220 |
| 216 } // namespace ppapi | 221 } // namespace ppapi |
| 217 } // namespace webkit | 222 } // namespace webkit |
| OLD | NEW |