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

Unified Diff: ppapi/example/example.cc

Issue 9655019: Fix a crash related to PPAPI scripting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ppapi/example/example.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/example/example.cc
diff --git a/ppapi/example/example.cc b/ppapi/example/example.cc
index 17ac0370886d7963d4eedbd0f0d84acdcb6a3610..0832deedcbcd2801d8433f2c6a35e46948c9aed0 100644
--- a/ppapi/example/example.cc
+++ b/ppapi/example/example.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -59,8 +59,15 @@ class MyScriptableObject : public pp::deprecated::ScriptableObject {
}
virtual bool HasProperty(const pp::Var& name, pp::Var* exception) {
- if (name.is_string() && name.AsString() == "blah")
- return true;
+ if (name.is_string()) {
+ if (name.AsString() == "blah") {
+ return true;
+ } else if (name.AsString() == "removePluginWhenHasPropertyCalled") {
+ pp::Var script("var plugin = document.getElementById('plugin');"
+ "plugin.parentElement.removeChild(plugin);");
+ instance_->ExecuteScript(script);
+ }
+ }
return false;
}
@@ -473,7 +480,8 @@ int gettimeofday(struct timeval *tv, struct timezone*) {
};
void FlushCallback(void* data, int32_t result) {
- static_cast<MyInstance*>(data)->OnFlush();
+ if (result == PP_OK)
+ static_cast<MyInstance*>(data)->OnFlush();
}
class MyModule : public pp::Module {
« no previous file with comments | « no previous file | ppapi/example/example.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698