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

Side by Side Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 7621054: Don't use a scoped_refptr for StringVar::FromPPVar (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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/plugins/ppapi/npapi_glue.cc ('k') | webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc » ('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) 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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 } 597 }
598 598
599 string16 PluginInstance::GetSelectedText(bool html) { 599 string16 PluginInstance::GetSelectedText(bool html) {
600 // Keep a reference on the stack. See NOTE above. 600 // Keep a reference on the stack. See NOTE above.
601 scoped_refptr<PluginInstance> ref(this); 601 scoped_refptr<PluginInstance> ref(this);
602 if (!LoadSelectionInterface()) 602 if (!LoadSelectionInterface())
603 return string16(); 603 return string16();
604 604
605 PP_Var rv = plugin_selection_interface_->GetSelectedText(pp_instance(), 605 PP_Var rv = plugin_selection_interface_->GetSelectedText(pp_instance(),
606 PP_FromBool(html)); 606 PP_FromBool(html));
607 scoped_refptr<StringVar> string(StringVar::FromPPVar(rv)); 607 StringVar* string = StringVar::FromPPVar(rv);
608 // Release the ref the plugin transfered to us. 608 // Release the ref the plugin transfered to us.
609 ResourceTracker::Get()->GetVarTracker()->ReleaseVar(rv); 609 ResourceTracker::Get()->GetVarTracker()->ReleaseVar(rv);
610 if (!string) 610 if (!string)
611 return string16(); 611 return string16();
612 return UTF8ToUTF16(string->value()); 612 return UTF8ToUTF16(string->value());
613 } 613 }
614 614
615 string16 PluginInstance::GetLinkAtPosition(const gfx::Point& point) { 615 string16 PluginInstance::GetLinkAtPosition(const gfx::Point& point) {
616 // Keep a reference on the stack. See NOTE above. 616 // Keep a reference on the stack. See NOTE above.
617 scoped_refptr<PluginInstance> ref(this); 617 scoped_refptr<PluginInstance> ref(this);
618 if (!LoadPdfInterface()) 618 if (!LoadPdfInterface())
619 return string16(); 619 return string16();
620 620
621 PP_Point p; 621 PP_Point p;
622 p.x = point.x(); 622 p.x = point.x();
623 p.y = point.y(); 623 p.y = point.y();
624 PP_Var rv = plugin_pdf_interface_->GetLinkAtPosition(pp_instance(), p); 624 PP_Var rv = plugin_pdf_interface_->GetLinkAtPosition(pp_instance(), p);
625 scoped_refptr<StringVar> string(StringVar::FromPPVar(rv)); 625 StringVar* string = StringVar::FromPPVar(rv);
626 // Release the ref the plugin transfered to us. 626 // Release the ref the plugin transfered to us.
627 ResourceTracker::Get()->GetVarTracker()->ReleaseVar(rv); 627 ResourceTracker::Get()->GetVarTracker()->ReleaseVar(rv);
628 if (!string) 628 if (!string)
629 return string16(); 629 return string16();
630 return UTF8ToUTF16(string->value()); 630 return UTF8ToUTF16(string->value());
631 } 631 }
632 632
633 void PluginInstance::Zoom(double factor, bool text_only) { 633 void PluginInstance::Zoom(double factor, bool text_only) {
634 // Keep a reference on the stack. See NOTE above. 634 // Keep a reference on the stack. See NOTE above.
635 scoped_refptr<PluginInstance> ref(this); 635 scoped_refptr<PluginInstance> ref(this);
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 } 1427 }
1428 1428
1429 PP_Var PluginInstance::ExecuteScript(PP_Instance instance, 1429 PP_Var PluginInstance::ExecuteScript(PP_Instance instance,
1430 PP_Var script, 1430 PP_Var script,
1431 PP_Var* exception) { 1431 PP_Var* exception) {
1432 TryCatch try_catch(module()->pp_module(), exception); 1432 TryCatch try_catch(module()->pp_module(), exception);
1433 if (try_catch.has_exception()) 1433 if (try_catch.has_exception())
1434 return PP_MakeUndefined(); 1434 return PP_MakeUndefined();
1435 1435
1436 // Convert the script into an inconvenient NPString object. 1436 // Convert the script into an inconvenient NPString object.
1437 scoped_refptr<StringVar> script_string(StringVar::FromPPVar(script)); 1437 StringVar* script_string = StringVar::FromPPVar(script);
1438 if (!script_string) { 1438 if (!script_string) {
1439 try_catch.SetException("Script param to ExecuteScript must be a string."); 1439 try_catch.SetException("Script param to ExecuteScript must be a string.");
1440 return PP_MakeUndefined(); 1440 return PP_MakeUndefined();
1441 } 1441 }
1442 NPString np_script; 1442 NPString np_script;
1443 np_script.UTF8Characters = script_string->value().c_str(); 1443 np_script.UTF8Characters = script_string->value().c_str();
1444 np_script.UTF8Length = script_string->value().length(); 1444 np_script.UTF8Length = script_string->value().length();
1445 1445
1446 // Get the current frame to pass to the evaluate function. 1446 // Get the current frame to pass to the evaluate function.
1447 WebFrame* frame = container_->element().document().frame(); 1447 WebFrame* frame = container_->element().document().frame();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 } 1542 }
1543 1543
1544 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { 1544 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) {
1545 cursor_.reset(cursor); 1545 cursor_.reset(cursor);
1546 if (fullscreen_container_) 1546 if (fullscreen_container_)
1547 fullscreen_container_->DidChangeCursor(*cursor); 1547 fullscreen_container_->DidChangeCursor(*cursor);
1548 } 1548 }
1549 1549
1550 } // namespace ppapi 1550 } // namespace ppapi
1551 } // namespace webkit 1551 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/npapi_glue.cc ('k') | webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698