Chromium Code Reviews| Index: webkit/plugins/ppapi/ppapi_plugin_instance.cc |
| diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc |
| index 09554fab11a31d36cedbab2b37bb2629a9fe1a15..e870981ae2aa8ed5c46cdbdd14abbc2a4d95c735 100644 |
| --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc |
| +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc |
| @@ -157,11 +157,6 @@ namespace { |
| // that they don't accept texts. |
| const ui::TextInputType kPluginDefaultTextInputType = ui::TEXT_INPUT_TYPE_TEXT; |
| -// The length of text to request as a surrounding context of selection. |
| -// For now, the value is copied from the one with render_view_impl.cc. |
| -// TODO(kinaba) implement a way to dynamically sync the requirement. |
| -static const size_t kExtraCharsBeforeAndAfterSelection = 100; |
| - |
| #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, np_name) \ |
| COMPILE_ASSERT(static_cast<int>(WebCursorInfo::webkit_name) \ |
| == static_cast<int>(np_name), \ |
| @@ -610,7 +605,15 @@ void PluginInstance::SelectionChanged() { |
| // TODO(kinaba): currently the browser always calls RequestSurroundingText. |
| // It can be optimized so that it won't call it back until the information |
| // is really needed. |
| - RequestSurroundingText(kExtraCharsBeforeAndAfterSelection); |
| + |
| + // Avoid calling in nested context or else this will reenter the plugin. This |
| + // uses a weak pointer rather than exploiting the fact that this class is |
| + // refcounted because we don't actually want this operation to affedct the |
|
viettrungluu
2012/04/11 23:37:14
s/affedct/affect/
|
| + // lifetime of the instance. |
| + MessageLoop::current()->PostTask(FROM_HERE, |
| + base::Bind(&PluginInstance::RequestSurroundingText, |
| + AsWeakPtr(), |
| + static_cast<size_t>(kExtraCharsForTextInput))); |
| } |
| void PluginInstance::UpdateSurroundingText(const std::string& text, |
| @@ -899,15 +902,14 @@ string16 PluginInstance::GetLinkAtPosition(const gfx::Point& point) { |
| return link; |
| } |
| -bool PluginInstance::RequestSurroundingText( |
| +void PluginInstance::RequestSurroundingText( |
| size_t desired_number_of_characters) { |
| // Keep a reference on the stack. See NOTE above. |
| scoped_refptr<PluginInstance> ref(this); |
| if (!LoadTextInputInterface()) |
| - return false; |
| + return; |
| plugin_textinput_interface_->RequestSurroundingText( |
| pp_instance(), desired_number_of_characters); |
| - return true; |
| } |
| void PluginInstance::Zoom(double factor, bool text_only) { |