Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: content/renderer/pepper/pepper_plugin_instance_impl.cc

Issue 1873783003: Convert //content/renderer from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/renderer/pepper/pepper_plugin_instance_impl.h" 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bit_cast.h" 10 #include "base/bit_cast.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 return false; 296 return false;
297 297
298 WebElement plugin_element = instance->container()->element(); 298 WebElement plugin_element = instance->container()->element();
299 *security_origin = plugin_element.document().getSecurityOrigin(); 299 *security_origin = plugin_element.document().getSecurityOrigin();
300 return true; 300 return true;
301 } 301 }
302 302
303 // Convert the given vector to an array of C-strings. The strings in the 303 // Convert the given vector to an array of C-strings. The strings in the
304 // returned vector are only guaranteed valid so long as the vector of strings 304 // returned vector are only guaranteed valid so long as the vector of strings
305 // is not modified. 305 // is not modified.
306 scoped_ptr<const char* []> StringVectorToArgArray( 306 std::unique_ptr<const char* []> StringVectorToArgArray(
307 const std::vector<std::string>& vector) { 307 const std::vector<std::string>& vector) {
308 scoped_ptr<const char * []> array(new const char* [vector.size()]); 308 std::unique_ptr<const char* []> array(new const char*[vector.size()]);
309 for (size_t i = 0; i < vector.size(); ++i) 309 for (size_t i = 0; i < vector.size(); ++i)
310 array[i] = vector[i].c_str(); 310 array[i] = vector[i].c_str();
311 return array; 311 return array;
312 } 312 }
313 313
314 // Returns true if this is a "system reserved" key which should not be sent to 314 // Returns true if this is a "system reserved" key which should not be sent to
315 // a plugin. Some poorly behaving plugins (like Flash) incorrectly report that 315 // a plugin. Some poorly behaving plugins (like Flash) incorrectly report that
316 // they handle all keys sent to them. This can prevent keystrokes from working 316 // they handle all keys sent to them. This can prevent keystrokes from working
317 // for things like screen brightness and volume control. 317 // for things like screen brightness and volume control.
318 bool IsReservedSystemInputEvent(const blink::WebInputEvent& event) { 318 bool IsReservedSystemInputEvent(const blink::WebInputEvent& event) {
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 814
815 if (render_frame_) 815 if (render_frame_)
816 render_frame_->PluginCrashed(module_->path(), module_->GetPeerProcessId()); 816 render_frame_->PluginCrashed(module_->path(), module_->GetPeerProcessId());
817 UnSetAndDeleteLockTargetAdapter(); 817 UnSetAndDeleteLockTargetAdapter();
818 } 818 }
819 819
820 bool PepperPluginInstanceImpl::Initialize( 820 bool PepperPluginInstanceImpl::Initialize(
821 const std::vector<std::string>& arg_names, 821 const std::vector<std::string>& arg_names,
822 const std::vector<std::string>& arg_values, 822 const std::vector<std::string>& arg_values,
823 bool full_frame, 823 bool full_frame,
824 scoped_ptr<PluginInstanceThrottlerImpl> throttler) { 824 std::unique_ptr<PluginInstanceThrottlerImpl> throttler) {
825 DCHECK(!throttler_); 825 DCHECK(!throttler_);
826 826
827 if (!render_frame_) 827 if (!render_frame_)
828 return false; 828 return false;
829 829
830 if (throttler) { 830 if (throttler) {
831 throttler_ = std::move(throttler); 831 throttler_ = std::move(throttler);
832 throttler_->AddObserver(this); 832 throttler_->AddObserver(this);
833 } 833 }
834 834
835 message_channel_ = MessageChannel::Create(this, &message_channel_object_); 835 message_channel_ = MessageChannel::Create(this, &message_channel_object_);
836 836
837 full_frame_ = full_frame; 837 full_frame_ = full_frame;
838 838
839 UpdateTouchEventRequest(); 839 UpdateTouchEventRequest();
840 container_->setWantsWheelEvents(IsAcceptingWheelEvents()); 840 container_->setWantsWheelEvents(IsAcceptingWheelEvents());
841 841
842 SetGPUHistogram(ppapi::Preferences(PpapiPreferencesBuilder::Build( 842 SetGPUHistogram(ppapi::Preferences(PpapiPreferencesBuilder::Build(
843 render_frame_->render_view()->webkit_preferences())), 843 render_frame_->render_view()->webkit_preferences())),
844 arg_names, 844 arg_names,
845 arg_values); 845 arg_values);
846 846
847 argn_ = arg_names; 847 argn_ = arg_names;
848 argv_ = arg_values; 848 argv_ = arg_values;
849 scoped_ptr<const char * []> argn_array(StringVectorToArgArray(argn_)); 849 std::unique_ptr<const char* []> argn_array(StringVectorToArgArray(argn_));
850 scoped_ptr<const char * []> argv_array(StringVectorToArgArray(argv_)); 850 std::unique_ptr<const char* []> argv_array(StringVectorToArgArray(argv_));
851 auto weak_this = weak_factory_.GetWeakPtr(); 851 auto weak_this = weak_factory_.GetWeakPtr();
852 bool success = PP_ToBool(instance_interface_->DidCreate( 852 bool success = PP_ToBool(instance_interface_->DidCreate(
853 pp_instance(), argn_.size(), argn_array.get(), argv_array.get())); 853 pp_instance(), argn_.size(), argn_array.get(), argv_array.get()));
854 if (!weak_this) { 854 if (!weak_this) {
855 // The plugin may do synchronous scripting during "DidCreate", so |this| 855 // The plugin may do synchronous scripting during "DidCreate", so |this|
856 // may be deleted. In that case, return failure and don't touch any 856 // may be deleted. In that case, return failure and don't touch any
857 // member variables. 857 // member variables.
858 return false; 858 return false;
859 } 859 }
860 // If this is a plugin that hosts external plugins, we should delay messages 860 // If this is a plugin that hosts external plugins, we should delay messages
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 // TODO(teravest): Remove set_document_loader() from instance and clean up 901 // TODO(teravest): Remove set_document_loader() from instance and clean up
902 // this relationship. 902 // this relationship.
903 set_document_loader(loader_host); 903 set_document_loader(loader_host);
904 loader_host->didReceiveResponse(NULL, response); 904 loader_host->didReceiveResponse(NULL, response);
905 905
906 // This host will be pending until the resource object attaches to it. 906 // This host will be pending until the resource object attaches to it.
907 // 907 //
908 // PpapiHost now owns the pointer to loader_host, so we don't have to worry 908 // PpapiHost now owns the pointer to loader_host, so we don't have to worry
909 // about managing it. 909 // about managing it.
910 int pending_host_id = host_impl->GetPpapiHost()->AddPendingResourceHost( 910 int pending_host_id = host_impl->GetPpapiHost()->AddPendingResourceHost(
911 scoped_ptr<ppapi::host::ResourceHost>(loader_host)); 911 std::unique_ptr<ppapi::host::ResourceHost>(loader_host));
912 DCHECK(pending_host_id); 912 DCHECK(pending_host_id);
913 913
914 DataFromWebURLResponse( 914 DataFromWebURLResponse(
915 host_impl, 915 host_impl,
916 pp_instance(), 916 pp_instance(),
917 response, 917 response,
918 base::Bind(&PepperPluginInstanceImpl::DidDataFromWebURLResponse, 918 base::Bind(&PepperPluginInstanceImpl::DidDataFromWebURLResponse,
919 weak_factory_.GetWeakPtr(), 919 weak_factory_.GetWeakPtr(),
920 response, 920 response,
921 pending_host_id)); 921 pending_host_id));
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 bool rv = false; 1130 bool rv = false;
1131 if (LoadInputEventInterface()) { 1131 if (LoadInputEventInterface()) {
1132 PP_InputEvent_Class event_class = ClassifyInputEvent(event.type); 1132 PP_InputEvent_Class event_class = ClassifyInputEvent(event.type);
1133 if (!event_class) 1133 if (!event_class)
1134 return false; 1134 return false;
1135 1135
1136 if ((filtered_input_event_mask_ & event_class) || 1136 if ((filtered_input_event_mask_ & event_class) ||
1137 (input_event_mask_ & event_class)) { 1137 (input_event_mask_ & event_class)) {
1138 // Actually send the event. 1138 // Actually send the event.
1139 std::vector<ppapi::InputEventData> events; 1139 std::vector<ppapi::InputEventData> events;
1140 scoped_ptr<const WebInputEvent> event_in_dip( 1140 std::unique_ptr<const WebInputEvent> event_in_dip(
1141 ui::ScaleWebInputEvent(event, viewport_to_dip_scale_)); 1141 ui::ScaleWebInputEvent(event, viewport_to_dip_scale_));
1142 if (event_in_dip) 1142 if (event_in_dip)
1143 CreateInputEventData(*event_in_dip.get(), &events); 1143 CreateInputEventData(*event_in_dip.get(), &events);
1144 else 1144 else
1145 CreateInputEventData(event, &events); 1145 CreateInputEventData(event, &events);
1146 1146
1147 // Allow the user gesture to be pending after the plugin handles the 1147 // Allow the user gesture to be pending after the plugin handles the
1148 // event. This allows out-of-process plugins to respond to the user 1148 // event. This allows out-of-process plugins to respond to the user
1149 // gesture after processing has finished here. 1149 // gesture after processing has finished here.
1150 if (WebUserGestureIndicator::isProcessingUserGesture()) { 1150 if (WebUserGestureIndicator::isProcessingUserGesture()) {
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
2067 } 2067 }
2068 } 2068 }
2069 2069
2070 layer_bound_to_fullscreen_ = !!fullscreen_container_; 2070 layer_bound_to_fullscreen_ = !!fullscreen_container_;
2071 layer_is_hardware_ = want_3d_layer; 2071 layer_is_hardware_ = want_3d_layer;
2072 UpdateLayerTransform(); 2072 UpdateLayerTransform();
2073 } 2073 }
2074 2074
2075 bool PepperPluginInstanceImpl::PrepareTextureMailbox( 2075 bool PepperPluginInstanceImpl::PrepareTextureMailbox(
2076 cc::TextureMailbox* mailbox, 2076 cc::TextureMailbox* mailbox,
2077 scoped_ptr<cc::SingleReleaseCallback>* release_callback, 2077 std::unique_ptr<cc::SingleReleaseCallback>* release_callback,
2078 bool use_shared_memory) { 2078 bool use_shared_memory) {
2079 if (!bound_graphics_2d_platform_) 2079 if (!bound_graphics_2d_platform_)
2080 return false; 2080 return false;
2081 return bound_graphics_2d_platform_->PrepareTextureMailbox(mailbox, 2081 return bound_graphics_2d_platform_->PrepareTextureMailbox(mailbox,
2082 release_callback); 2082 release_callback);
2083 } 2083 }
2084 2084
2085 void PepperPluginInstanceImpl::OnDestruct() { render_frame_ = NULL; } 2085 void PepperPluginInstanceImpl::OnDestruct() { render_frame_ = NULL; }
2086 2086
2087 void PepperPluginInstanceImpl::OnThrottleStateChange() { 2087 void PepperPluginInstanceImpl::OnThrottleStateChange() {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2144 WebView* web_view = container()->element().document().frame()->view(); 2144 WebView* web_view = container()->element().document().frame()->view();
2145 if (!web_view) { 2145 if (!web_view) {
2146 NOTREACHED(); 2146 NOTREACHED();
2147 return; 2147 return;
2148 } 2148 }
2149 2149
2150 bool handled = SimulateIMEEvent(input_event); 2150 bool handled = SimulateIMEEvent(input_event);
2151 if (handled) 2151 if (handled)
2152 return; 2152 return;
2153 2153
2154 std::vector<scoped_ptr<WebInputEvent>> events = CreateSimulatedWebInputEvents( 2154 std::vector<std::unique_ptr<WebInputEvent>> events =
2155 input_event, view_data_.rect.point.x + view_data_.rect.size.width / 2, 2155 CreateSimulatedWebInputEvents(
2156 view_data_.rect.point.y + view_data_.rect.size.height / 2); 2156 input_event, view_data_.rect.point.x + view_data_.rect.size.width / 2,
2157 for (std::vector<scoped_ptr<WebInputEvent>>::iterator it = events.begin(); 2157 view_data_.rect.point.y + view_data_.rect.size.height / 2);
2158 for (std::vector<std::unique_ptr<WebInputEvent>>::iterator it =
2159 events.begin();
2158 it != events.end(); ++it) { 2160 it != events.end(); ++it) {
2159 web_view->handleInputEvent(*it->get()); 2161 web_view->handleInputEvent(*it->get());
2160 } 2162 }
2161 } 2163 }
2162 2164
2163 bool PepperPluginInstanceImpl::SimulateIMEEvent( 2165 bool PepperPluginInstanceImpl::SimulateIMEEvent(
2164 const InputEventData& input_event) { 2166 const InputEventData& input_event) {
2165 switch (input_event.event_type) { 2167 switch (input_event.event_type) {
2166 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_START: 2168 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_START:
2167 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE: 2169 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE:
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
2697 EnterResourceNoLock<PPB_ImageData_API> enter(image, true); 2699 EnterResourceNoLock<PPB_ImageData_API> enter(image, true);
2698 if (enter.failed()) 2700 if (enter.failed())
2699 return PP_FALSE; 2701 return PP_FALSE;
2700 PPB_ImageData_Impl* image_data = 2702 PPB_ImageData_Impl* image_data =
2701 static_cast<PPB_ImageData_Impl*>(enter.object()); 2703 static_cast<PPB_ImageData_Impl*>(enter.object());
2702 2704
2703 ImageDataAutoMapper auto_mapper(image_data); 2705 ImageDataAutoMapper auto_mapper(image_data);
2704 if (!auto_mapper.is_valid()) 2706 if (!auto_mapper.is_valid())
2705 return PP_FALSE; 2707 return PP_FALSE;
2706 2708
2707 scoped_ptr<WebCursorInfo> custom_cursor( 2709 std::unique_ptr<WebCursorInfo> custom_cursor(
2708 new WebCursorInfo(WebCursorInfo::TypeCustom)); 2710 new WebCursorInfo(WebCursorInfo::TypeCustom));
2709 custom_cursor->hotSpot.x = hot_spot->x; 2711 custom_cursor->hotSpot.x = hot_spot->x;
2710 custom_cursor->hotSpot.y = hot_spot->y; 2712 custom_cursor->hotSpot.y = hot_spot->y;
2711 2713
2712 const SkBitmap* bitmap = image_data->GetMappedBitmap(); 2714 const SkBitmap* bitmap = image_data->GetMappedBitmap();
2713 // Make a deep copy, so that the cursor remains valid even after the original 2715 // Make a deep copy, so that the cursor remains valid even after the original
2714 // image data gets freed. 2716 // image data gets freed.
2715 if (!bitmap->copyTo(&custom_cursor->customImage.getSkBitmap())) { 2717 if (!bitmap->copyTo(&custom_cursor->customImage.getSkBitmap())) {
2716 return PP_FALSE; 2718 return PP_FALSE;
2717 } 2719 }
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2913 plugin_find_interface_ = NULL; 2915 plugin_find_interface_ = NULL;
2914 plugin_input_event_interface_ = NULL; 2916 plugin_input_event_interface_ = NULL;
2915 checked_for_plugin_input_event_interface_ = false; 2917 checked_for_plugin_input_event_interface_ = false;
2916 plugin_mouse_lock_interface_ = NULL; 2918 plugin_mouse_lock_interface_ = NULL;
2917 plugin_pdf_interface_ = NULL; 2919 plugin_pdf_interface_ = NULL;
2918 checked_for_plugin_pdf_interface_ = false; 2920 checked_for_plugin_pdf_interface_ = false;
2919 plugin_private_interface_ = NULL; 2921 plugin_private_interface_ = NULL;
2920 plugin_textinput_interface_ = NULL; 2922 plugin_textinput_interface_ = NULL;
2921 2923
2922 // Re-send the DidCreate event via the proxy. 2924 // Re-send the DidCreate event via the proxy.
2923 scoped_ptr<const char * []> argn_array(StringVectorToArgArray(argn_)); 2925 std::unique_ptr<const char* []> argn_array(StringVectorToArgArray(argn_));
2924 scoped_ptr<const char * []> argv_array(StringVectorToArgArray(argv_)); 2926 std::unique_ptr<const char* []> argv_array(StringVectorToArgArray(argv_));
2925 if (!instance_interface_->DidCreate( 2927 if (!instance_interface_->DidCreate(
2926 pp_instance(), argn_.size(), argn_array.get(), argv_array.get())) 2928 pp_instance(), argn_.size(), argn_array.get(), argv_array.get()))
2927 return PP_EXTERNAL_PLUGIN_ERROR_INSTANCE; 2929 return PP_EXTERNAL_PLUGIN_ERROR_INSTANCE;
2928 if (message_channel_) 2930 if (message_channel_)
2929 message_channel_->Start(); 2931 message_channel_->Start();
2930 2932
2931 // Clear sent_initial_did_change_view_ and cancel any pending DidChangeView 2933 // Clear sent_initial_did_change_view_ and cancel any pending DidChangeView
2932 // event. This way, SendDidChangeView will send the "current" view 2934 // event. This way, SendDidChangeView will send the "current" view
2933 // immediately (before other events like HandleDocumentLoad). 2935 // immediately (before other events like HandleDocumentLoad).
2934 sent_initial_did_change_view_ = false; 2936 sent_initial_did_change_view_ = false;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
3153 container_->loadFrameRequest(web_request, target_str); 3155 container_->loadFrameRequest(web_request, target_str);
3154 return PP_OK; 3156 return PP_OK;
3155 } 3157 }
3156 3158
3157 int PepperPluginInstanceImpl::MakePendingFileRefRendererHost( 3159 int PepperPluginInstanceImpl::MakePendingFileRefRendererHost(
3158 const base::FilePath& path) { 3160 const base::FilePath& path) {
3159 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); 3161 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host();
3160 PepperFileRefRendererHost* file_ref_host( 3162 PepperFileRefRendererHost* file_ref_host(
3161 new PepperFileRefRendererHost(host_impl, pp_instance(), 0, path)); 3163 new PepperFileRefRendererHost(host_impl, pp_instance(), 0, path));
3162 return host_impl->GetPpapiHost()->AddPendingResourceHost( 3164 return host_impl->GetPpapiHost()->AddPendingResourceHost(
3163 scoped_ptr<ppapi::host::ResourceHost>(file_ref_host)); 3165 std::unique_ptr<ppapi::host::ResourceHost>(file_ref_host));
3164 } 3166 }
3165 3167
3166 void PepperPluginInstanceImpl::SetEmbedProperty(PP_Var key, PP_Var value) { 3168 void PepperPluginInstanceImpl::SetEmbedProperty(PP_Var key, PP_Var value) {
3167 if (message_channel_) 3169 if (message_channel_)
3168 message_channel_->SetReadOnlyProperty(key, value); 3170 message_channel_->SetReadOnlyProperty(key, value);
3169 } 3171 }
3170 3172
3171 bool PepperPluginInstanceImpl::CanAccessMainFrame() const { 3173 bool PepperPluginInstanceImpl::CanAccessMainFrame() const {
3172 if (!container_) 3174 if (!container_)
3173 return false; 3175 return false;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
3322 } 3324 }
3323 3325
3324 void PepperPluginInstanceImpl::ConvertDIPToViewport(gfx::Rect* rect) const { 3326 void PepperPluginInstanceImpl::ConvertDIPToViewport(gfx::Rect* rect) const {
3325 rect->set_x(rect->x() / viewport_to_dip_scale_); 3327 rect->set_x(rect->x() / viewport_to_dip_scale_);
3326 rect->set_y(rect->y() / viewport_to_dip_scale_); 3328 rect->set_y(rect->y() / viewport_to_dip_scale_);
3327 rect->set_width(rect->width() / viewport_to_dip_scale_); 3329 rect->set_width(rect->width() / viewport_to_dip_scale_);
3328 rect->set_height(rect->height() / viewport_to_dip_scale_); 3330 rect->set_height(rect->height() / viewport_to_dip_scale_);
3329 } 3331 }
3330 3332
3331 } // namespace content 3333 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_plugin_instance_impl.h ('k') | content/renderer/pepper/pepper_url_loader_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698