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

Unified Diff: extensions/renderer/native_extension_bindings_system.cc

Issue 2819683002: [Extenisons Bindings] Don't throw unchecked errors; add console errors (Closed)
Patch Set: . Created 3 years, 8 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
Index: extensions/renderer/native_extension_bindings_system.cc
diff --git a/extensions/renderer/native_extension_bindings_system.cc b/extensions/renderer/native_extension_bindings_system.cc
index 9924a14e59e5d381e66c604b9b5ec04c55417973..87ee7f8ce8fe7423ef39a788a62aed026e38948c 100644
--- a/extensions/renderer/native_extension_bindings_system.cc
+++ b/extensions/renderer/native_extension_bindings_system.cc
@@ -6,6 +6,7 @@
#include "base/command_line.h"
#include "base/memory/ptr_util.h"
+#include "content/public/common/console_message_level.h"
#include "content/public/common/content_switches.h"
#include "extensions/common/constants.h"
#include "extensions/common/event_filtering_info.h"
@@ -164,6 +165,14 @@ v8::Global<v8::Value> CallJsFunctionSync(v8::Local<v8::Function> function,
return result;
}
+void AddConsoleError(v8::Local<v8::Context> context, const std::string& error) {
+ ScriptContext* script_context =
+ ScriptContextSet::GetContextByV8Context(context);
+ CHECK(script_context);
+ script_context->AddMessageToConsole(content::CONSOLE_MESSAGE_LEVEL_ERROR,
+ error);
+}
+
// Returns the API schema indicated by |api_name|.
const base::DictionaryValue& GetAPISchema(const std::string& api_name) {
const base::DictionaryValue* schema =
@@ -335,7 +344,7 @@ NativeExtensionBindingsSystem::NativeExtensionBindingsSystem(
base::Unretained(this)),
base::Bind(&NativeExtensionBindingsSystem::OnEventListenerChanged,
base::Unretained(this)),
- APILastError(base::Bind(&GetRuntime))),
+ APILastError(base::Bind(&GetRuntime), base::Bind(&AddConsoleError))),
weak_factory_(this) {
api_system_.RegisterCustomType("storage.StorageArea",
base::Bind(&StorageArea::CreateStorageArea));

Powered by Google App Engine
This is Rietveld 408576698