| OLD | NEW |
| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 std::string event_name = StringFromNPVariant(args[0]); | 181 std::string event_name = StringFromNPVariant(args[0]); |
| 182 if (event_name.empty()) | 182 if (event_name.empty()) |
| 183 return false; | 183 return false; |
| 184 | 184 |
| 185 v8::Local<v8::Value> value = | 185 v8::Local<v8::Value> value = |
| 186 v8::Local<v8::Value>::New(WebBindings::toV8Value(&args[1])); | 186 v8::Local<v8::Value>::New(WebBindings::toV8Value(&args[1])); |
| 187 if (value.IsEmpty() || !value->IsFunction()) | 187 if (value.IsEmpty() || !value->IsFunction()) |
| 188 return false; | 188 return false; |
| 189 | 189 |
| 190 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); | 190 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); |
| 191 return bindings->instance()->AddEventListener(event_name, function); | 191 result->type = NPVariantType_Bool; |
| 192 result->value.boolValue = |
| 193 bindings->instance()->AddEventListener(event_name, function); |
| 194 return true; |
| 192 } | 195 } |
| 193 | 196 |
| 194 if (IdentifierIsBackMethod(name) && !arg_count) { | 197 if (IdentifierIsBackMethod(name) && !arg_count) { |
| 195 bindings->instance()->Back(); | 198 bindings->instance()->Back(); |
| 196 return true; | 199 return true; |
| 197 } | 200 } |
| 198 | 201 |
| 199 if (IdentifierIsForwardMethod(name) && !arg_count) { | 202 if (IdentifierIsForwardMethod(name) && !arg_count) { |
| 200 bindings->instance()->Forward(); | 203 bindings->instance()->Forward(); |
| 201 return true; | 204 return true; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 223 if (event_name.empty()) | 226 if (event_name.empty()) |
| 224 return false; | 227 return false; |
| 225 | 228 |
| 226 v8::Local<v8::Value> value = | 229 v8::Local<v8::Value> value = |
| 227 v8::Local<v8::Value>::New(WebBindings::toV8Value(&args[1])); | 230 v8::Local<v8::Value>::New(WebBindings::toV8Value(&args[1])); |
| 228 | 231 |
| 229 if (value.IsEmpty() || !value->IsFunction()) | 232 if (value.IsEmpty() || !value->IsFunction()) |
| 230 return false; | 233 return false; |
| 231 | 234 |
| 232 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); | 235 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); |
| 233 return bindings->instance()->RemoveEventListener(event_name, function); | 236 result->type = NPVariantType_Bool; |
| 237 result->value.boolValue = |
| 238 bindings->instance()->RemoveEventListener(event_name, function); |
| 239 return true; |
| 234 } | 240 } |
| 235 | 241 |
| 236 if (IdentifierIsStop(name) && !arg_count) { | 242 if (IdentifierIsStop(name) && !arg_count) { |
| 237 bindings->instance()->Stop(); | 243 bindings->instance()->Stop(); |
| 238 return true; | 244 return true; |
| 239 } | 245 } |
| 240 | 246 |
| 241 return false; | 247 return false; |
| 242 } | 248 } |
| 243 | 249 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 WebBindings::createObject(NULL, &browser_plugin_message_class); | 360 WebBindings::createObject(NULL, &browser_plugin_message_class); |
| 355 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj); | 361 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj); |
| 356 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); | 362 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); |
| 357 } | 363 } |
| 358 | 364 |
| 359 BrowserPluginBindings::~BrowserPluginBindings() { | 365 BrowserPluginBindings::~BrowserPluginBindings() { |
| 360 WebBindings::releaseObject(np_object_); | 366 WebBindings::releaseObject(np_object_); |
| 361 } | 367 } |
| 362 | 368 |
| 363 } // namespace content | 369 } // namespace content |
| OLD | NEW |