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

Side by Side Diff: webkit/glue/plugins/pepper_plugin_instance.cc

Issue 3323005: Unrevert 58354, reland PPAPI with the instance test disabled. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « webkit/glue/plugins/pepper_plugin_instance.h ('k') | webkit/glue/plugins/pepper_var.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "webkit/glue/plugins/pepper_plugin_instance.h" 5 #include "webkit/glue/plugins/pepper_plugin_instance.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/histogram.h" 8 #include "base/histogram.h"
9 #if defined(OS_MACOSX) 9 #if defined(OS_MACOSX)
10 #include "base/mac_util.h" 10 #include "base/mac_util.h"
(...skipping 15 matching lines...) Expand all
26 #include "third_party/ppapi/c/dev/ppp_find_dev.h" 26 #include "third_party/ppapi/c/dev/ppp_find_dev.h"
27 #include "third_party/ppapi/c/dev/ppp_zoom_dev.h" 27 #include "third_party/ppapi/c/dev/ppp_zoom_dev.h"
28 #include "third_party/ppapi/c/pp_event.h" 28 #include "third_party/ppapi/c/pp_event.h"
29 #include "third_party/ppapi/c/pp_instance.h" 29 #include "third_party/ppapi/c/pp_instance.h"
30 #include "third_party/ppapi/c/pp_rect.h" 30 #include "third_party/ppapi/c/pp_rect.h"
31 #include "third_party/ppapi/c/pp_resource.h" 31 #include "third_party/ppapi/c/pp_resource.h"
32 #include "third_party/ppapi/c/pp_var.h" 32 #include "third_party/ppapi/c/pp_var.h"
33 #include "third_party/ppapi/c/ppb_core.h" 33 #include "third_party/ppapi/c/ppb_core.h"
34 #include "third_party/ppapi/c/ppb_instance.h" 34 #include "third_party/ppapi/c/ppb_instance.h"
35 #include "third_party/ppapi/c/ppp_instance.h" 35 #include "third_party/ppapi/c/ppp_instance.h"
36 #include "third_party/WebKit/WebKit/chromium/public/WebBindings.h"
36 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" 37 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h"
37 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" 38 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h"
38 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" 39 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h"
39 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" 40 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
40 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" 41 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h"
41 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" 42 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h"
42 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" 43 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h"
43 #include "webkit/glue/plugins/pepper_buffer.h" 44 #include "webkit/glue/plugins/pepper_buffer.h"
44 #include "webkit/glue/plugins/pepper_graphics_2d.h" 45 #include "webkit/glue/plugins/pepper_graphics_2d.h"
45 #include "webkit/glue/plugins/pepper_event_conversion.h" 46 #include "webkit/glue/plugins/pepper_event_conversion.h"
46 #include "webkit/glue/plugins/pepper_image_data.h" 47 #include "webkit/glue/plugins/pepper_image_data.h"
47 #include "webkit/glue/plugins/pepper_plugin_delegate.h" 48 #include "webkit/glue/plugins/pepper_plugin_delegate.h"
48 #include "webkit/glue/plugins/pepper_plugin_module.h" 49 #include "webkit/glue/plugins/pepper_plugin_module.h"
49 #include "webkit/glue/plugins/pepper_string.h" 50 #include "webkit/glue/plugins/pepper_string.h"
50 #include "webkit/glue/plugins/pepper_url_loader.h" 51 #include "webkit/glue/plugins/pepper_url_loader.h"
51 #include "webkit/glue/plugins/pepper_var.h" 52 #include "webkit/glue/plugins/pepper_var.h"
52 53
54 using WebKit::WebBindings;
53 using WebKit::WebCanvas; 55 using WebKit::WebCanvas;
54 using WebKit::WebCursorInfo; 56 using WebKit::WebCursorInfo;
55 using WebKit::WebFrame; 57 using WebKit::WebFrame;
56 using WebKit::WebInputEvent; 58 using WebKit::WebInputEvent;
57 using WebKit::WebPluginContainer; 59 using WebKit::WebPluginContainer;
58 60
59 namespace pepper { 61 namespace pepper {
60 62
61 #if defined(OS_WIN) 63 #if defined(OS_WIN)
62 // Exported by pdf.dll 64 // Exported by pdf.dll
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 return instance->BindGraphics(device_id); 155 return instance->BindGraphics(device_id);
154 } 156 }
155 157
156 bool IsFullFrame(PP_Instance instance_id) { 158 bool IsFullFrame(PP_Instance instance_id) {
157 PluginInstance* instance = PluginInstance::FromPPInstance(instance_id); 159 PluginInstance* instance = PluginInstance::FromPPInstance(instance_id);
158 if (!instance) 160 if (!instance)
159 return false; 161 return false;
160 return instance->full_frame(); 162 return instance->full_frame();
161 } 163 }
162 164
165 PP_Var ExecuteScript(PP_Instance instance_id,
166 PP_Var script,
167 PP_Var* exception) {
168 PluginInstance* instance = PluginInstance::FromPPInstance(instance_id);
169 if (!instance)
170 return PP_MakeVoid();
171 return instance->ExecuteScript(script, exception);
172 }
173
163 const PPB_Instance ppb_instance = { 174 const PPB_Instance ppb_instance = {
164 &GetWindowObject, 175 &GetWindowObject,
165 &GetOwnerElementObject, 176 &GetOwnerElementObject,
166 &BindGraphics, 177 &BindGraphics,
167 &IsFullFrame, 178 &IsFullFrame,
179 &ExecuteScript,
168 }; 180 };
169 181
170 void NumberOfFindResultsChanged(PP_Instance instance_id, 182 void NumberOfFindResultsChanged(PP_Instance instance_id,
171 int32_t total, 183 int32_t total,
172 bool final_result) { 184 bool final_result) {
173 PluginInstance* instance = PluginInstance::FromPPInstance(instance_id); 185 PluginInstance* instance = PluginInstance::FromPPInstance(instance_id);
174 if (!instance) 186 if (!instance)
175 return; 187 return;
176 188
177 DCHECK_NE(instance->find_identifier(), -1); 189 DCHECK_NE(instance->find_identifier(), -1);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 } 331 }
320 332
321 return true; 333 return true;
322 } 334 }
323 335
324 bool PluginInstance::SetCursor(PP_CursorType_Dev type) { 336 bool PluginInstance::SetCursor(PP_CursorType_Dev type) {
325 cursor_.reset(new WebCursorInfo(static_cast<WebCursorInfo::Type>(type))); 337 cursor_.reset(new WebCursorInfo(static_cast<WebCursorInfo::Type>(type)));
326 return true; 338 return true;
327 } 339 }
328 340
341 PP_Var PluginInstance::ExecuteScript(PP_Var script, PP_Var* exception) {
342 TryCatch try_catch(exception);
343 if (try_catch.HasException())
344 return PP_MakeVoid();
345
346 // Convert the script into an inconvenient NPString object.
347 String* script_string = GetString(script);
348 if (!script_string) {
349 try_catch.SetException("Script param to ExecuteScript must be a string.");
350 return PP_MakeVoid();
351 }
352 NPString np_script;
353 np_script.UTF8Characters = script_string->value().c_str();
354 np_script.UTF8Length = script_string->value().length();
355
356 // Get the current frame to pass to the evaluate function.
357 WebFrame* frame = container_->element().document().frame();
358 if (!frame) {
359 try_catch.SetException("No frame to execute script in.");
360 return PP_MakeVoid();
361 }
362
363 NPVariant result;
364 bool ok = WebBindings::evaluate(NULL, frame->windowObject(), &np_script,
365 &result);
366 if (!ok) {
367 // TODO(brettw) bug 54011: The TryCatch isn't working properly and
368 // doesn't actually catch this exception.
369 try_catch.SetException("Exception caught");
370 WebBindings::releaseVariantValue(&result);
371 return PP_MakeVoid();
372 }
373
374 PP_Var ret = NPVariantToPPVar(&result);
375 WebBindings::releaseVariantValue(&result);
376 return ret;
377 }
378
329 void PluginInstance::Delete() { 379 void PluginInstance::Delete() {
330 instance_interface_->Delete(GetPPInstance()); 380 instance_interface_->Delete(GetPPInstance());
331 381
332 container_ = NULL; 382 container_ = NULL;
333 } 383 }
334 384
335 bool PluginInstance::Initialize(WebPluginContainer* container, 385 bool PluginInstance::Initialize(WebPluginContainer* container,
336 const std::vector<std::string>& arg_names, 386 const std::vector<std::string>& arg_names,
337 const std::vector<std::string>& arg_values, 387 const std::vector<std::string>& arg_values,
338 bool full_frame) { 388 bool full_frame) {
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 bounds.size.width = dest_rect.width(); 859 bounds.size.width = dest_rect.width();
810 bounds.size.height = dest_rect.height(); 860 bounds.size.height = dest_rect.height();
811 861
812 CGContextDrawImage(canvas, bounds, image); 862 CGContextDrawImage(canvas, bounds, image);
813 CGContextRestoreGState(canvas); 863 CGContextRestoreGState(canvas);
814 } 864 }
815 #endif // defined(OS_MACOSX) 865 #endif // defined(OS_MACOSX)
816 866
817 867
818 } // namespace pepper 868 } // namespace pepper
OLDNEW
« no previous file with comments | « webkit/glue/plugins/pepper_plugin_instance.h ('k') | webkit/glue/plugins/pepper_var.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698