| 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 "content/renderer/pepper_plugin_delegate_impl.h" | 5 #include "content/renderer/pepper_plugin_delegate_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 // saved pipe handle. | 643 // saved pipe handle. |
| 644 // Temporarily, just call back. | 644 // Temporarily, just call back. |
| 645 client->BrokerConnected(PlatformFileToInt(plugin_handle), result); | 645 client->BrokerConnected(PlatformFileToInt(plugin_handle), result); |
| 646 } | 646 } |
| 647 | 647 |
| 648 PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderView* render_view) | 648 PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderView* render_view) |
| 649 : render_view_(render_view), | 649 : render_view_(render_view), |
| 650 has_saved_context_menu_action_(false), | 650 has_saved_context_menu_action_(false), |
| 651 saved_context_menu_action_(0), | 651 saved_context_menu_action_(0), |
| 652 id_generator_(0), | 652 id_generator_(0), |
| 653 is_pepper_plugin_focused_(false) { | 653 focused_plugin_(0) { |
| 654 } | 654 } |
| 655 | 655 |
| 656 PepperPluginDelegateImpl::~PepperPluginDelegateImpl() { | 656 PepperPluginDelegateImpl::~PepperPluginDelegateImpl() { |
| 657 } | 657 } |
| 658 | 658 |
| 659 scoped_refptr<webkit::ppapi::PluginModule> | 659 scoped_refptr<webkit::ppapi::PluginModule> |
| 660 PepperPluginDelegateImpl::CreatePepperPluginModule( | 660 PepperPluginDelegateImpl::CreatePepperPluginModule( |
| 661 const webkit::WebPluginInfo& webplugin_info, | 661 const webkit::WebPluginInfo& webplugin_info, |
| 662 bool* pepper_plugin_was_registered) { | 662 bool* pepper_plugin_was_registered) { |
| 663 *pepper_plugin_was_registered = true; | 663 *pepper_plugin_was_registered = true; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 active_instances_.begin(); | 820 active_instances_.begin(); |
| 821 i != active_instances_.end(); ++i) { | 821 i != active_instances_.end(); ++i) { |
| 822 webkit::ppapi::PluginInstance* instance = *i; | 822 webkit::ppapi::PluginInstance* instance = *i; |
| 823 if (instance->GetBitmapForOptimizedPluginPaint( | 823 if (instance->GetBitmapForOptimizedPluginPaint( |
| 824 paint_bounds, dib, location, clip)) | 824 paint_bounds, dib, location, clip)) |
| 825 return *i; | 825 return *i; |
| 826 } | 826 } |
| 827 return NULL; | 827 return NULL; |
| 828 } | 828 } |
| 829 | 829 |
| 830 void PepperPluginDelegateImpl::PluginFocusChanged(bool focused) { | 830 void PepperPluginDelegateImpl::PluginFocusChanged( |
| 831 is_pepper_plugin_focused_ = focused; | 831 webkit::ppapi::PluginInstance* instance, |
| 832 bool focused) { |
| 833 if (focused) { |
| 834 focused_plugin_ = instance; |
| 835 } else if (focused_plugin_ == instance) { |
| 836 focused_plugin_ = 0; |
| 837 } |
| 832 if (render_view_) | 838 if (render_view_) |
| 833 render_view_->PpapiPluginFocusChanged(); | 839 render_view_->PpapiPluginFocusChanged(); |
| 834 } | 840 } |
| 835 | 841 |
| 842 void PepperPluginDelegateImpl::PluginTextInputTypeChanged( |
| 843 webkit::ppapi::PluginInstance* instance) { |
| 844 if (focused_plugin_ == instance && render_view_) |
| 845 render_view_->PpapiPluginFocusChanged(); |
| 846 } |
| 847 |
| 848 void PepperPluginDelegateImpl::OnImeSetComposition( |
| 849 const string16& text, |
| 850 const std::vector<WebKit::WebCompositionUnderline>& underlines, |
| 851 int selection_start, |
| 852 int selection_end) { |
| 853 if (!CanComposeInline()) { |
| 854 composition_text_ = text; |
| 855 } else { |
| 856 // TODO(kinaba) currently all composition events are sent directly to |
| 857 // plugins. Use DOM event mechanism after WebKit is made aware about |
| 858 // plugins supporting composition. |
| 859 |
| 860 // Empty -> nonempty: composition started. |
| 861 if (composition_text_.empty() && !text.empty()) |
| 862 focused_plugin_->HandleCompositionStart(string16()); |
| 863 // Nonempty -> empty: composition canceled. |
| 864 if (!composition_text_.empty() && text.empty()) |
| 865 focused_plugin_->HandleCompositionEnd(text); |
| 866 composition_text_ = text; |
| 867 // Nonempty: composition is ongoing. |
| 868 if (!composition_text_.empty()) |
| 869 focused_plugin_->HandleCompositionUpdate(text, underlines, |
| 870 selection_start, selection_end); |
| 871 } |
| 872 } |
| 873 |
| 874 void PepperPluginDelegateImpl::OnImeConfirmComposition(const string16& text) { |
| 875 if (!text.empty()) |
| 876 composition_text_ = text; |
| 877 if (composition_text_.empty()) |
| 878 return; |
| 879 |
| 880 if (!CanComposeInline()) { |
| 881 for (size_t i = 0; i < text.size(); ++i) { |
| 882 WebKit::WebKeyboardEvent char_event; |
| 883 char_event.type = WebKit::WebInputEvent::Char; |
| 884 char_event.timeStampSeconds = base::Time::Now().ToDoubleT(); |
| 885 char_event.modifiers = 0; |
| 886 char_event.windowsKeyCode = composition_text_[i]; |
| 887 char_event.nativeKeyCode = composition_text_[i]; |
| 888 char_event.text[0] = composition_text_[i]; |
| 889 char_event.unmodifiedText[0] = composition_text_[i]; |
| 890 if (render_view_->webwidget()) |
| 891 render_view_->webwidget()->handleInputEvent(char_event); |
| 892 } |
| 893 } |
| 894 else { |
| 895 focused_plugin_->HandleTextInput(composition_text_); |
| 896 focused_plugin_->HandleCompositionEnd(composition_text_); |
| 897 } |
| 898 composition_text_.clear(); |
| 899 } |
| 900 |
| 901 WebKit::WebRect PepperPluginDelegateImpl::GetCaretBounds() const { |
| 902 if (!focused_plugin_) |
| 903 return WebKit::WebRect(); |
| 904 return focused_plugin_->GetCaretBounds(); |
| 905 } |
| 906 |
| 907 WebKit::WebTextInputType PepperPluginDelegateImpl::GetTextInputType() const { |
| 908 if (!focused_plugin_) |
| 909 return WebKit::WebTextInputTypeNone; |
| 910 return focused_plugin_->text_input_type(); |
| 911 } |
| 912 |
| 913 bool PepperPluginDelegateImpl::CanComposeInline() const { |
| 914 if (!focused_plugin_) |
| 915 return false; |
| 916 return focused_plugin_->CanComposeInline(); |
| 917 } |
| 918 |
| 836 void PepperPluginDelegateImpl::PluginCrashed( | 919 void PepperPluginDelegateImpl::PluginCrashed( |
| 837 webkit::ppapi::PluginInstance* instance) { | 920 webkit::ppapi::PluginInstance* instance) { |
| 838 subscribed_to_policy_updates_.erase(instance); | 921 subscribed_to_policy_updates_.erase(instance); |
| 839 render_view_->PluginCrashed(instance->module()->path()); | 922 render_view_->PluginCrashed(instance->module()->path()); |
| 840 } | 923 } |
| 841 | 924 |
| 842 void PepperPluginDelegateImpl::InstanceCreated( | 925 void PepperPluginDelegateImpl::InstanceCreated( |
| 843 webkit::ppapi::PluginInstance* instance) { | 926 webkit::ppapi::PluginInstance* instance) { |
| 844 active_instances_.insert(instance); | 927 active_instances_.insert(instance); |
| 845 | 928 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 } | 1093 } |
| 1011 | 1094 |
| 1012 void PepperPluginDelegateImpl::OnSetFocus(bool has_focus) { | 1095 void PepperPluginDelegateImpl::OnSetFocus(bool has_focus) { |
| 1013 for (std::set<webkit::ppapi::PluginInstance*>::iterator i = | 1096 for (std::set<webkit::ppapi::PluginInstance*>::iterator i = |
| 1014 active_instances_.begin(); | 1097 active_instances_.begin(); |
| 1015 i != active_instances_.end(); ++i) | 1098 i != active_instances_.end(); ++i) |
| 1016 (*i)->SetContentAreaFocus(has_focus); | 1099 (*i)->SetContentAreaFocus(has_focus); |
| 1017 } | 1100 } |
| 1018 | 1101 |
| 1019 bool PepperPluginDelegateImpl::IsPluginFocused() const { | 1102 bool PepperPluginDelegateImpl::IsPluginFocused() const { |
| 1020 return is_pepper_plugin_focused_; | 1103 return focused_plugin_ != 0; |
| 1021 } | 1104 } |
| 1022 | 1105 |
| 1023 bool PepperPluginDelegateImpl::OpenFileSystem( | 1106 bool PepperPluginDelegateImpl::OpenFileSystem( |
| 1024 const GURL& url, | 1107 const GURL& url, |
| 1025 fileapi::FileSystemType type, | 1108 fileapi::FileSystemType type, |
| 1026 long long size, | 1109 long long size, |
| 1027 fileapi::FileSystemCallbackDispatcher* dispatcher) { | 1110 fileapi::FileSystemCallbackDispatcher* dispatcher) { |
| 1028 FileSystemDispatcher* file_system_dispatcher = | 1111 FileSystemDispatcher* file_system_dispatcher = |
| 1029 ChildThread::current()->file_system_dispatcher(); | 1112 ChildThread::current()->file_system_dispatcher(); |
| 1030 return file_system_dispatcher->OpenFileSystem( | 1113 return file_system_dispatcher->OpenFileSystem( |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1476 | 1559 |
| 1477 int PepperPluginDelegateImpl::GetRoutingId() const { | 1560 int PepperPluginDelegateImpl::GetRoutingId() const { |
| 1478 return render_view_->routing_id(); | 1561 return render_view_->routing_id(); |
| 1479 } | 1562 } |
| 1480 | 1563 |
| 1481 void PepperPluginDelegateImpl::PublishInitialPolicy( | 1564 void PepperPluginDelegateImpl::PublishInitialPolicy( |
| 1482 scoped_refptr<webkit::ppapi::PluginInstance> instance, | 1565 scoped_refptr<webkit::ppapi::PluginInstance> instance, |
| 1483 const std::string& policy) { | 1566 const std::string& policy) { |
| 1484 instance->HandlePolicyUpdate(policy); | 1567 instance->HandlePolicyUpdate(policy); |
| 1485 } | 1568 } |
| OLD | NEW |