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/callback.h" | 10 #include "base/callback.h" |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 // That message handler will then call client->BrokerConnected() with the | 552 // That message handler will then call client->BrokerConnected() with the |
553 // saved pipe handle. | 553 // saved pipe handle. |
554 // Temporarily, just call back. | 554 // Temporarily, just call back. |
555 client->BrokerConnected(PlatformFileToInt(plugin_handle), result); | 555 client->BrokerConnected(PlatformFileToInt(plugin_handle), result); |
556 } | 556 } |
557 | 557 |
558 PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderView* render_view) | 558 PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderView* render_view) |
559 : render_view_(render_view), | 559 : render_view_(render_view), |
560 has_saved_context_menu_action_(false), | 560 has_saved_context_menu_action_(false), |
561 saved_context_menu_action_(0), | 561 saved_context_menu_action_(0), |
562 id_generator_(0) { | 562 id_generator_(0), |
| 563 is_pepper_plugin_focused_(false) { |
563 } | 564 } |
564 | 565 |
565 PepperPluginDelegateImpl::~PepperPluginDelegateImpl() { | 566 PepperPluginDelegateImpl::~PepperPluginDelegateImpl() { |
566 } | 567 } |
567 | 568 |
568 scoped_refptr<webkit::ppapi::PluginModule> | 569 scoped_refptr<webkit::ppapi::PluginModule> |
569 PepperPluginDelegateImpl::CreatePepperPlugin( | 570 PepperPluginDelegateImpl::CreatePepperPlugin( |
570 const FilePath& path, | 571 const FilePath& path, |
571 bool* pepper_plugin_was_registered) { | 572 bool* pepper_plugin_was_registered) { |
572 *pepper_plugin_was_registered = true; | 573 *pepper_plugin_was_registered = true; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 active_instances_.begin(); | 728 active_instances_.begin(); |
728 i != active_instances_.end(); ++i) { | 729 i != active_instances_.end(); ++i) { |
729 webkit::ppapi::PluginInstance* instance = *i; | 730 webkit::ppapi::PluginInstance* instance = *i; |
730 if (instance->GetBitmapForOptimizedPluginPaint( | 731 if (instance->GetBitmapForOptimizedPluginPaint( |
731 paint_bounds, dib, location, clip)) | 732 paint_bounds, dib, location, clip)) |
732 return *i; | 733 return *i; |
733 } | 734 } |
734 return NULL; | 735 return NULL; |
735 } | 736 } |
736 | 737 |
| 738 void PepperPluginDelegateImpl::PluginFocusChanged(bool focused) { |
| 739 is_pepper_plugin_focused_ = focused; |
| 740 if (render_view_) |
| 741 render_view_->PpapiPluginFocusChanged(); |
| 742 } |
| 743 |
737 void PepperPluginDelegateImpl::PluginCrashed( | 744 void PepperPluginDelegateImpl::PluginCrashed( |
738 webkit::ppapi::PluginInstance* instance) { | 745 webkit::ppapi::PluginInstance* instance) { |
739 render_view_->PluginCrashed(instance->module()->path()); | 746 render_view_->PluginCrashed(instance->module()->path()); |
740 } | 747 } |
741 | 748 |
742 void PepperPluginDelegateImpl::InstanceCreated( | 749 void PepperPluginDelegateImpl::InstanceCreated( |
743 webkit::ppapi::PluginInstance* instance) { | 750 webkit::ppapi::PluginInstance* instance) { |
744 active_instances_.insert(instance); | 751 active_instances_.insert(instance); |
745 | 752 |
746 // Set the initial focus. | 753 // Set the initial focus. |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 delete callback; | 905 delete callback; |
899 } | 906 } |
900 | 907 |
901 void PepperPluginDelegateImpl::OnSetFocus(bool has_focus) { | 908 void PepperPluginDelegateImpl::OnSetFocus(bool has_focus) { |
902 for (std::set<webkit::ppapi::PluginInstance*>::iterator i = | 909 for (std::set<webkit::ppapi::PluginInstance*>::iterator i = |
903 active_instances_.begin(); | 910 active_instances_.begin(); |
904 i != active_instances_.end(); ++i) | 911 i != active_instances_.end(); ++i) |
905 (*i)->SetContentAreaFocus(has_focus); | 912 (*i)->SetContentAreaFocus(has_focus); |
906 } | 913 } |
907 | 914 |
| 915 bool PepperPluginDelegateImpl::IsPluginFocused() const { |
| 916 return is_pepper_plugin_focused_; |
| 917 } |
| 918 |
908 bool PepperPluginDelegateImpl::OpenFileSystem( | 919 bool PepperPluginDelegateImpl::OpenFileSystem( |
909 const GURL& url, | 920 const GURL& url, |
910 fileapi::FileSystemType type, | 921 fileapi::FileSystemType type, |
911 long long size, | 922 long long size, |
912 fileapi::FileSystemCallbackDispatcher* dispatcher) { | 923 fileapi::FileSystemCallbackDispatcher* dispatcher) { |
913 FileSystemDispatcher* file_system_dispatcher = | 924 FileSystemDispatcher* file_system_dispatcher = |
914 ChildThread::current()->file_system_dispatcher(); | 925 ChildThread::current()->file_system_dispatcher(); |
915 return file_system_dispatcher->OpenFileSystem( | 926 return file_system_dispatcher->OpenFileSystem( |
916 url.GetWithEmptyPath(), type, size, true /* create */, dispatcher); | 927 url.GetWithEmptyPath(), type, size, true /* create */, dispatcher); |
917 } | 928 } |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1312 DLOG(WARNING) << "Browser allocation request message failed"; | 1323 DLOG(WARNING) << "Browser allocation request message failed"; |
1313 return NULL; | 1324 return NULL; |
1314 } | 1325 } |
1315 if (!base::SharedMemory::IsHandleValid(handle)) { | 1326 if (!base::SharedMemory::IsHandleValid(handle)) { |
1316 DLOG(WARNING) << "Browser failed to allocate shared memory"; | 1327 DLOG(WARNING) << "Browser failed to allocate shared memory"; |
1317 return NULL; | 1328 return NULL; |
1318 } | 1329 } |
1319 shm.reset(new base::SharedMemory(handle, false)); | 1330 shm.reset(new base::SharedMemory(handle, false)); |
1320 return shm.release(); | 1331 return shm.release(); |
1321 } | 1332 } |
OLD | NEW |