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

Unified Diff: extensions/renderer/api_last_error.cc

Issue 2762623003: [Extensions Bindings] Add lastError utilities to APIBindingJSUtil (Closed)
Patch Set: Rebase Created 3 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 | « extensions/renderer/api_last_error.h ('k') | extensions/renderer/api_request_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/api_last_error.cc
diff --git a/extensions/renderer/api_last_error.cc b/extensions/renderer/api_last_error.cc
index 12111d23d1398e4119f452a46b57b618413c12dc..4073d276c09a526981cceb2d58fc5737e0e3319d 100644
--- a/extensions/renderer/api_last_error.cc
+++ b/extensions/renderer/api_last_error.cc
@@ -146,4 +146,26 @@ void APILastError::ClearError(v8::Local<v8::Context> context,
parent->Delete(context, key).ToChecked();
}
+bool APILastError::HasError(v8::Local<v8::Context> context) {
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope handle_scope(isolate);
+
+ // See comment in SetError().
+ v8::TryCatch try_catch(isolate);
+ try_catch.SetVerbose(true);
+
+ v8::Local<v8::Object> parent = get_parent_.Run(context);
+ if (parent.IsEmpty())
+ return false;
+ v8::Local<v8::Value> error;
+ if (!parent->Get(context, gin::StringToSymbol(isolate, kLastErrorProperty))
+ .ToLocal(&error)) {
+ return false;
+ }
+
+ LastErrorObject* last_error = nullptr;
+ return gin::Converter<LastErrorObject*>::FromV8(context->GetIsolate(), error,
+ &last_error);
+}
+
} // namespace extensions
« no previous file with comments | « extensions/renderer/api_last_error.h ('k') | extensions/renderer/api_request_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698