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

Side by Side Diff: extensions/renderer/module_system.cc

Issue 2819683002: [Extenisons Bindings] Don't throw unchecked errors; add console errors (Closed)
Patch Set: jbroman's 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/renderer/module_system.h" 5 #include "extensions/renderer/module_system.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 full_message += " context"; 54 full_message += " context";
55 if (context->extension()) { 55 if (context->extension()) {
56 full_message += " for "; 56 full_message += " for ";
57 full_message += context->extension()->id(); 57 full_message += context->extension()->id();
58 } 58 }
59 full_message += ") "; 59 full_message += ") ";
60 full_message += message; 60 full_message += message;
61 61
62 ExtensionsClient* client = ExtensionsClient::Get(); 62 ExtensionsClient* client = ExtensionsClient::Get();
63 if (client->ShouldSuppressFatalErrors()) { 63 if (client->ShouldSuppressFatalErrors()) {
64 console::AddMessage(context->GetRenderFrame(), 64 console::AddMessage(context, content::CONSOLE_MESSAGE_LEVEL_ERROR,
65 content::CONSOLE_MESSAGE_LEVEL_ERROR, full_message); 65 full_message);
66 client->RecordDidSuppressFatalError(); 66 client->RecordDidSuppressFatalError();
67 } else { 67 } else {
68 console::Fatal(context->GetRenderFrame(), full_message); 68 console::Fatal(context, full_message);
69 } 69 }
70 } 70 }
71 71
72 void Warn(v8::Isolate* isolate, const std::string& message) { 72 void Warn(v8::Isolate* isolate, const std::string& message) {
73 ScriptContext* script_context = 73 ScriptContext* script_context =
74 ScriptContextSet::GetContextByV8Context(isolate->GetCurrentContext()); 74 ScriptContextSet::GetContextByV8Context(isolate->GetCurrentContext());
75 console::AddMessage( 75 console::AddMessage(script_context, content::CONSOLE_MESSAGE_LEVEL_WARNING,
76 script_context ? script_context->GetRenderFrame() : nullptr, 76 message);
77 content::CONSOLE_MESSAGE_LEVEL_WARNING, message);
78 } 77 }
79 78
80 // Default exception handler which logs the exception. 79 // Default exception handler which logs the exception.
81 class DefaultExceptionHandler : public ModuleSystem::ExceptionHandler { 80 class DefaultExceptionHandler : public ModuleSystem::ExceptionHandler {
82 public: 81 public:
83 explicit DefaultExceptionHandler(ScriptContext* context) 82 explicit DefaultExceptionHandler(ScriptContext* context)
84 : ModuleSystem::ExceptionHandler(context) {} 83 : ModuleSystem::ExceptionHandler(context) {}
85 84
86 // Fatally dumps the debug info from |try_catch| to the console. 85 // Fatally dumps the debug info from |try_catch| to the console.
87 // Make sure this is never used for exceptions that originate in external 86 // Make sure this is never used for exceptions that originate in external
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 !value->IsFunction()) { 895 !value->IsFunction()) {
897 Fatal(context_, module_name + "." + method_name + " is not a function"); 896 Fatal(context_, module_name + "." + method_name + " is not a function");
898 return function; 897 return function;
899 } 898 }
900 899
901 function = v8::Local<v8::Function>::Cast(value); 900 function = v8::Local<v8::Function>::Cast(value);
902 return function; 901 return function;
903 } 902 }
904 903
905 } // namespace extensions 904 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/declarative_event_unittest.cc ('k') | extensions/renderer/native_extension_bindings_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698