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

Unified Diff: chrome/renderer/extensions/chrome_v8_context.cc

Issue 8772018: Merge 112521 - Be more careful when calling methods on chromeHidden. If chromeHidden didn't have ... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/912/src/
Patch Set: Created 9 years, 1 month 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/chrome_v8_context.cc
===================================================================
--- chrome/renderer/extensions/chrome_v8_context.cc (revision 112544)
+++ chrome/renderer/extensions/chrome_v8_context.cc (working copy)
@@ -44,6 +44,7 @@
v8::Handle<v8::Value>* argv,
v8::Handle<v8::Value>* result) const {
v8::Context::Scope context_scope(v8_context_);
+ v8::TryCatch try_catch;
// Look up the function name, which may be a sub-property like
// "Port.dispatchOnMessage" in the hidden global variable.
@@ -52,15 +53,16 @@
std::vector<std::string> components;
base::SplitStringDontTrim(function_name, '.', &components);
for (size_t i = 0; i < components.size(); ++i) {
- if (!value.IsEmpty()) {
+ if (!value.IsEmpty() && value->IsObject()) {
value = v8::Local<v8::Object>::Cast(value)->Get(
v8::String::New(components[i].c_str()));
+ if (try_catch.HasCaught()) {
+ NOTREACHED() << *v8::String::AsciiValue(try_catch.Exception());
+ return false;
+ }
}
}
- // TODO(aa): CHECK that this succeeds. Can't do this now because not all
- // callers know if the method they are calling exists. Should be able to fix
- // this when all the bindings are converted to the new framework.
if (value.IsEmpty() || !value->IsFunction()) {
VLOG(1) << "Could not execute chrome hidden method: " << function_name;
return false;
@@ -68,6 +70,10 @@
v8::Handle<v8::Value> result_temp =
v8::Local<v8::Function>::Cast(value)->Call(v8::Object::New(), argc, argv);
+ if (try_catch.HasCaught()) {
+ NOTREACHED() << *v8::String::AsciiValue(try_catch.Exception());
+ return false;
+ }
if (result)
*result = result_temp;
return true;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698