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

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

Issue 9564024: Re-land http://codereview.chromium.org/9403039/, r124106 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unnecessary change to ppapi_uitest.cc timer_ Created 8 years, 9 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/ppapi_webplugin_impl.h ('k') | no next file » | 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) 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 "webkit/plugins/ppapi/ppapi_webplugin_impl.h" 5 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
11 #include "ppapi/c/pp_var.h" 11 #include "ppapi/shared_impl/ppapi_globals.h"
12 #include "ppapi/shared_impl/var_tracker.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" 20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
21 #include "webkit/plugins/ppapi/message_channel.h" 22 #include "webkit/plugins/ppapi/message_channel.h"
(...skipping 22 matching lines...) Expand all
44 std::vector<std::string> arg_names; 45 std::vector<std::string> arg_names;
45 std::vector<std::string> arg_values; 46 std::vector<std::string> arg_values;
46 GURL url; 47 GURL url;
47 }; 48 };
48 49
49 WebPluginImpl::WebPluginImpl( 50 WebPluginImpl::WebPluginImpl(
50 PluginModule* plugin_module, 51 PluginModule* plugin_module,
51 const WebPluginParams& params, 52 const WebPluginParams& params,
52 const base::WeakPtr<PluginDelegate>& plugin_delegate) 53 const base::WeakPtr<PluginDelegate>& plugin_delegate)
53 : init_data_(new InitData()), 54 : init_data_(new InitData()),
54 full_frame_(params.loadManually) { 55 full_frame_(params.loadManually),
56 instance_object_(PP_MakeUndefined()) {
55 DCHECK(plugin_module); 57 DCHECK(plugin_module);
56 init_data_->module = plugin_module; 58 init_data_->module = plugin_module;
57 init_data_->delegate = plugin_delegate; 59 init_data_->delegate = plugin_delegate;
58 for (size_t i = 0; i < params.attributeNames.size(); ++i) { 60 for (size_t i = 0; i < params.attributeNames.size(); ++i) {
59 init_data_->arg_names.push_back(params.attributeNames[i].utf8()); 61 init_data_->arg_names.push_back(params.attributeNames[i].utf8());
60 init_data_->arg_values.push_back(params.attributeValues[i].utf8()); 62 init_data_->arg_values.push_back(params.attributeValues[i].utf8());
61 } 63 }
62 init_data_->url = params.url; 64 init_data_->url = params.url;
63 } 65 }
64 66
(...skipping 19 matching lines...) Expand all
84 instance_ = NULL; 86 instance_ = NULL;
85 return false; 87 return false;
86 } 88 }
87 89
88 init_data_.reset(); 90 init_data_.reset();
89 return true; 91 return true;
90 } 92 }
91 93
92 void WebPluginImpl::destroy() { 94 void WebPluginImpl::destroy() {
93 if (instance_) { 95 if (instance_) {
96 ::ppapi::PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(instance_object_);
97 instance_object_ = PP_MakeUndefined();
94 instance_->Delete(); 98 instance_->Delete();
95 instance_ = NULL; 99 instance_ = NULL;
96 } 100 }
97 101
98 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 102 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
99 } 103 }
100 104
101 NPObject* WebPluginImpl::scriptableObject() { 105 NPObject* WebPluginImpl::scriptableObject() {
102 // Call through the plugin to get its instance object. Note that we "leak" a 106 // Call through the plugin to get its instance object. The plugin should pass
103 // reference here. But we want to keep the instance object alive so long as 107 // us a reference which we release in destroy().
104 // the instance is alive, so it's okay. It will get cleaned up when all 108 if (instance_object_.type == PP_VARTYPE_UNDEFINED)
105 // NPObjectVars are "force freed" at instance shutdown. 109 instance_object_ = instance_->GetInstanceObject();
106 scoped_refptr<NPObjectVar> object(
107 NPObjectVar::FromPPVar(instance_->GetInstanceObject()));
108 // GetInstanceObject talked to the plugin which may have removed the instance 110 // GetInstanceObject talked to the plugin which may have removed the instance
109 // from the DOM, in which case instance_ would be NULL now. 111 // from the DOM, in which case instance_ would be NULL now.
110 if (!instance_) 112 if (!instance_)
111 return NULL; 113 return NULL;
112 114
115 scoped_refptr<NPObjectVar> object(NPObjectVar::FromPPVar(instance_object_));
113 // If there's an InstanceObject, tell the Instance's MessageChannel to pass 116 // If there's an InstanceObject, tell the Instance's MessageChannel to pass
114 // any non-postMessage calls to it. 117 // any non-postMessage calls to it.
115 if (object) { 118 if (object) {
116 instance_->message_channel().SetPassthroughObject(object->np_object()); 119 instance_->message_channel().SetPassthroughObject(object->np_object());
117 } 120 }
118 NPObject* message_channel_np_object(instance_->message_channel().np_object()); 121 NPObject* message_channel_np_object(instance_->message_channel().np_object());
119 // The object is expected to be retained before it is returned. 122 // The object is expected to be retained before it is returned.
120 WebKit::WebBindings::retainObject(message_channel_np_object); 123 WebKit::WebBindings::retainObject(message_channel_np_object);
121 return message_channel_np_object; 124 return message_channel_np_object;
122 } 125 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 bool WebPluginImpl::canRotateView() { 266 bool WebPluginImpl::canRotateView() {
264 return instance_->CanRotateView(); 267 return instance_->CanRotateView();
265 } 268 }
266 269
267 void WebPluginImpl::rotateView(RotationType type) { 270 void WebPluginImpl::rotateView(RotationType type) {
268 instance_->RotateView(type); 271 instance_->RotateView(type);
269 } 272 }
270 273
271 } // namespace ppapi 274 } // namespace ppapi
272 } // namespace webkit 275 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppapi_webplugin_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698