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

Side by Side Diff: content/renderer/browser_plugin/browser_plugin_bindings.cc

Issue 10829225: Browser Plugin: Add HTML5-like postMessage support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Verified to work with nasko@'s disabled frame tree updates Created 8 years, 2 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
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/browser_plugin/browser_plugin_bindings.h" 5 #include "content/renderer/browser_plugin/browser_plugin_bindings.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 19 matching lines...) Expand all
30 using WebKit::WebDOMEvent; 30 using WebKit::WebDOMEvent;
31 using WebKit::WebDOMMessageEvent; 31 using WebKit::WebDOMMessageEvent;
32 using WebKit::WebPluginContainer; 32 using WebKit::WebPluginContainer;
33 using WebKit::WebSerializedScriptValue; 33 using WebKit::WebSerializedScriptValue;
34 using WebKit::WebString; 34 using WebKit::WebString;
35 35
36 namespace content { 36 namespace content {
37 37
38 namespace { 38 namespace {
39 39
40 const char kAddEventListener[] = "addEventListener"; 40 const char kAddEventListener[] = "addCustomEventListener";
41 const char kContentWindow[] = "contentWindow";
41 const char kBackMethod[] = "back"; 42 const char kBackMethod[] = "back";
42 const char kForwardMethod[] = "forward"; 43 const char kForwardMethod[] = "forward";
43 const char kGetProcessId[] = "getProcessId"; 44 const char kGetProcessId[] = "getProcessId";
44 const char kGoMethod[] = "go"; 45 const char kGoMethod[] = "go";
45 const char kPartitionAttribute[] = "partition"; 46 const char kPartitionAttribute[] = "partition";
46 const char kReloadMethod[] = "reload"; 47 const char kReloadMethod[] = "reload";
47 const char kRemoveEventListener[] = "removeEventListener"; 48 const char kRemoveEventListener[] = "removeCustomEventListener";
48 const char kSrcAttribute[] = "src"; 49 const char kSrcAttribute[] = "src";
49 const char kStopMethod[] = "stop"; 50 const char kStopMethod[] = "stop";
50 51
51 BrowserPluginBindings* GetBindings(NPObject* object) { 52 BrowserPluginBindings* GetBindings(NPObject* object) {
52 return static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(object)-> 53 return static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(object)->
53 message_channel; 54 message_channel;
54 } 55 }
55 56
56 bool IdentifierIsReload(NPIdentifier identifier) { 57 bool IdentifierIsReload(NPIdentifier identifier) {
57 return WebBindings::getStringIdentifier(kReloadMethod) == identifier; 58 return WebBindings::getStringIdentifier(kReloadMethod) == identifier;
58 } 59 }
59 60
60 bool IdentifierIsStop(NPIdentifier identifier) { 61 bool IdentifierIsStop(NPIdentifier identifier) {
61 return WebBindings::getStringIdentifier(kStopMethod) == identifier; 62 return WebBindings::getStringIdentifier(kStopMethod) == identifier;
62 } 63 }
63 64
64 bool IdentifierIsAddEventListener(NPIdentifier identifier) { 65 bool IdentifierIsAddEventListener(NPIdentifier identifier) {
65 return WebBindings::getStringIdentifier(kAddEventListener) == identifier; 66 return WebBindings::getStringIdentifier(kAddEventListener) == identifier;
66 } 67 }
67 68
69 bool IdentifierIsContentWindow(NPIdentifier identifier) {
70 return WebBindings::getStringIdentifier(kContentWindow) == identifier;
71 }
72
68 bool IdentifierIsBackMethod(NPIdentifier identifier) { 73 bool IdentifierIsBackMethod(NPIdentifier identifier) {
69 return WebBindings::getStringIdentifier(kBackMethod) == identifier; 74 return WebBindings::getStringIdentifier(kBackMethod) == identifier;
70 } 75 }
71 76
72 bool IdentifierIsForwardMethod(NPIdentifier identifier) { 77 bool IdentifierIsForwardMethod(NPIdentifier identifier) {
73 return WebBindings::getStringIdentifier(kForwardMethod) == identifier; 78 return WebBindings::getStringIdentifier(kForwardMethod) == identifier;
74 } 79 }
75 80
76 bool IdentifierIsGoMethod(NPIdentifier identifier) { 81 bool IdentifierIsGoMethod(NPIdentifier identifier) {
77 return WebBindings::getStringIdentifier(kGoMethod) == identifier; 82 return WebBindings::getStringIdentifier(kGoMethod) == identifier;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 bool BrowserPluginBindingsInvokeDefault(NPObject* np_obj, 249 bool BrowserPluginBindingsInvokeDefault(NPObject* np_obj,
245 const NPVariant* args, 250 const NPVariant* args,
246 uint32 arg_count, 251 uint32 arg_count,
247 NPVariant* result) { 252 NPVariant* result) {
248 NOTIMPLEMENTED(); 253 NOTIMPLEMENTED();
249 return false; 254 return false;
250 } 255 }
251 256
252 bool BrowserPluginBindingsHasProperty(NPObject* np_obj, NPIdentifier name) { 257 bool BrowserPluginBindingsHasProperty(NPObject* np_obj, NPIdentifier name) {
253 return IdentifierIsSrcAttribute(name) || 258 return IdentifierIsSrcAttribute(name) ||
259 IdentifierIsContentWindow(name) ||
254 IdentifierIsPartitionAttribute(name); 260 IdentifierIsPartitionAttribute(name);
255 } 261 }
256 262
257 bool BrowserPluginBindingsGetProperty(NPObject* np_obj, NPIdentifier name, 263 bool BrowserPluginBindingsGetProperty(NPObject* np_obj, NPIdentifier name,
258 NPVariant* result) { 264 NPVariant* result) {
259 if (!np_obj) 265 if (!np_obj)
260 return false; 266 return false;
261 267
262 if (!result) 268 if (!result)
263 return false; 269 return false;
264 270
265 // All attributes from here on rely on the bindings, so retrieve it once and 271 // All attributes from here on rely on the bindings, so retrieve it once and
266 // return on failure. 272 // return on failure.
267 BrowserPluginBindings* bindings = GetBindings(np_obj); 273 BrowserPluginBindings* bindings = GetBindings(np_obj);
268 if (!bindings) 274 if (!bindings)
269 return false; 275 return false;
270 276
271 if (IdentifierIsSrcAttribute(name)) { 277 if (IdentifierIsSrcAttribute(name)) {
272 std::string src = bindings->instance()->GetSrcAttribute(); 278 std::string src = bindings->instance()->GetSrcAttribute();
273 return StringToNPVariant(src, result); 279 return StringToNPVariant(src, result);
274 } 280 }
275 281
282 if (IdentifierIsContentWindow(name)) {
283 NPObject* obj = bindings->instance()->GetContentWindow();
284 result->type = NPVariantType_Object;
285 result->value.objectValue = WebBindings::retainObject(obj);
286 return true;
287 }
288
276 if (IdentifierIsPartitionAttribute(name)) { 289 if (IdentifierIsPartitionAttribute(name)) {
277 std::string partition_id = bindings->instance()->GetPartitionAttribute(); 290 std::string partition_id = bindings->instance()->GetPartitionAttribute();
278 return StringToNPVariant(partition_id, result); 291 return StringToNPVariant(partition_id, result);
279 } 292 }
280 293
281 return false; 294 return false;
282 } 295 }
283 296
284 bool BrowserPluginBindingsSetProperty(NPObject* np_obj, NPIdentifier name, 297 bool BrowserPluginBindingsSetProperty(NPObject* np_obj, NPIdentifier name,
285 const NPVariant* variant) { 298 const NPVariant* variant) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 WebBindings::createObject(NULL, &browser_plugin_message_class); 367 WebBindings::createObject(NULL, &browser_plugin_message_class);
355 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj); 368 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj);
356 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); 369 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr();
357 } 370 }
358 371
359 BrowserPluginBindings::~BrowserPluginBindings() { 372 BrowserPluginBindings::~BrowserPluginBindings() {
360 WebBindings::releaseObject(np_object_); 373 WebBindings::releaseObject(np_object_);
361 } 374 }
362 375
363 } // namespace content 376 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698