Chromium Code Reviews| Index: content/renderer/pepper_plugin_delegate_impl.cc |
| diff --git a/content/renderer/pepper_plugin_delegate_impl.cc b/content/renderer/pepper_plugin_delegate_impl.cc |
| index c21353f6d48adbaaa0367b888618f24fd7eb02ca..2578e2dc83f4fdbae4a1cd583f9aa6b1082a0db0 100644 |
| --- a/content/renderer/pepper_plugin_delegate_impl.cc |
| +++ b/content/renderer/pepper_plugin_delegate_impl.cc |
| @@ -663,7 +663,7 @@ PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderView* render_view) |
| has_saved_context_menu_action_(false), |
| saved_context_menu_action_(0), |
| id_generator_(0), |
| - is_pepper_plugin_focused_(false) { |
| + focused_plugin_(0) { |
| } |
| PepperPluginDelegateImpl::~PepperPluginDelegateImpl() { |
| @@ -841,12 +841,95 @@ PepperPluginDelegateImpl::GetBitmapForOptimizedPluginPaint( |
| return NULL; |
| } |
| -void PepperPluginDelegateImpl::PluginFocusChanged(bool focused) { |
| - is_pepper_plugin_focused_ = focused; |
| +void PepperPluginDelegateImpl::PluginFocusChanged( |
| + webkit::ppapi::PluginInstance* instance, |
| + bool focused) { |
| + if (focused) { |
| + focused_plugin_ = instance; |
| + } else if (focused_plugin_ == instance) { |
| + focused_plugin_ = 0; |
| + } |
|
James Su
2011/09/23 01:46:48
nit: no { }
|
| if (render_view_) |
| render_view_->PpapiPluginFocusChanged(); |
| } |
| +void PepperPluginDelegateImpl::PluginTextInputTypeChanged( |
| + webkit::ppapi::PluginInstance* instance) { |
| + if (focused_plugin_ == instance && render_view_) |
| + render_view_->PpapiPluginFocusChanged(); |
|
James Su
2011/09/23 01:46:48
Is it correct? Shouldn't we have a specific method
|
| +} |
| + |
| +void PepperPluginDelegateImpl::OnImeSetComposition( |
| + const string16& text, |
| + const std::vector<WebKit::WebCompositionUnderline>& underlines, |
| + int selection_start, |
| + int selection_end) { |
| + if (!CanComposeInline()) { |
| + composition_text_ = text; |
| + } else { |
| + // TODO(kinaba) currently all composition events are sent directly to |
| + // plugins. Use DOM event mechanism after WebKit is made aware about |
| + // plugins supporting composition. |
| + |
| + // Empty -> nonempty: composition started. |
| + if (composition_text_.empty() && !text.empty()) |
| + focused_plugin_->HandleCompositionStart(string16()); |
| + // Nonempty -> empty: composition canceled. |
| + if (!composition_text_.empty() && text.empty()) |
| + focused_plugin_->HandleCompositionEnd(text); |
|
James Su
2011/09/23 01:46:48
should send composition_text_ along with compositi
|
| + composition_text_ = text; |
| + // Nonempty: composition is ongoing. |
| + if (!composition_text_.empty()) |
| + focused_plugin_->HandleCompositionUpdate(text, underlines, |
| + selection_start, selection_end); |
|
James Su
2011/09/23 01:46:48
nit: use {} for multi-line if statement.
|
| + } |
| +} |
| + |
| +void PepperPluginDelegateImpl::OnImeConfirmComposition(const string16& text) { |
| + if (!text.empty()) |
| + composition_text_ = text; |
| + if (composition_text_.empty()) |
| + return; |
| + |
| + if (!CanComposeInline()) { |
|
James Su
2011/09/23 01:46:48
Is it possible that a plugin cannot handle inline
|
| + for (size_t i = 0; i < text.size(); ++i) { |
| + WebKit::WebKeyboardEvent char_event; |
| + char_event.type = WebKit::WebInputEvent::Char; |
| + char_event.timeStampSeconds = base::Time::Now().ToDoubleT(); |
| + char_event.modifiers = 0; |
| + char_event.windowsKeyCode = composition_text_[i]; |
| + char_event.nativeKeyCode = composition_text_[i]; |
| + char_event.text[0] = composition_text_[i]; |
| + char_event.unmodifiedText[0] = composition_text_[i]; |
| + if (render_view_->webwidget()) |
| + render_view_->webwidget()->handleInputEvent(char_event); |
| + } |
| + } |
|
James Su
2011/09/23 01:46:48
nit: no line break.
|
| + else { |
| + focused_plugin_->HandleTextInput(composition_text_); |
| + focused_plugin_->HandleCompositionEnd(composition_text_); |
|
James Su
2011/09/23 01:46:48
Should we send composition end first? Like what we
|
| + } |
| + composition_text_.clear(); |
| +} |
| + |
| +WebKit::WebRect PepperPluginDelegateImpl::GetCaretBounds() const { |
| + if (!focused_plugin_) |
| + return WebKit::WebRect(); |
| + return focused_plugin_->GetCaretBounds(); |
| +} |
| + |
| +WebKit::WebTextInputType PepperPluginDelegateImpl::GetTextInputType() const { |
| + if (!focused_plugin_) |
| + return WebKit::WebTextInputTypeNone; |
| + return focused_plugin_->text_input_type(); |
| +} |
| + |
| +bool PepperPluginDelegateImpl::CanComposeInline() const { |
| + if (!focused_plugin_) |
| + return false; |
| + return focused_plugin_->CanComposeInline(); |
| +} |
| + |
| void PepperPluginDelegateImpl::PluginCrashed( |
| webkit::ppapi::PluginInstance* instance) { |
| subscribed_to_policy_updates_.erase(instance); |
| @@ -1033,7 +1116,7 @@ void PepperPluginDelegateImpl::OnSetFocus(bool has_focus) { |
| } |
| bool PepperPluginDelegateImpl::IsPluginFocused() const { |
| - return is_pepper_plugin_focused_; |
| + return focused_plugin_ != 0; |
|
James Su
2011/09/23 01:46:48
!= NULL?
|
| } |
| bool PepperPluginDelegateImpl::OpenFileSystem( |