| OLD | NEW |
| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 full_message += " context"; | 53 full_message += " context"; |
| 54 if (context->extension()) { | 54 if (context->extension()) { |
| 55 full_message += " for "; | 55 full_message += " for "; |
| 56 full_message += context->extension()->id(); | 56 full_message += context->extension()->id(); |
| 57 } | 57 } |
| 58 full_message += ") "; | 58 full_message += ") "; |
| 59 full_message += message; | 59 full_message += message; |
| 60 | 60 |
| 61 ExtensionsClient* client = ExtensionsClient::Get(); | 61 ExtensionsClient* client = ExtensionsClient::Get(); |
| 62 if (client->ShouldSuppressFatalErrors()) { | 62 if (client->ShouldSuppressFatalErrors()) { |
| 63 console::Error(context->GetRenderFrame(), full_message); | 63 console::AddMessage(context->GetRenderFrame(), |
| 64 content::CONSOLE_MESSAGE_LEVEL_ERROR, full_message); |
| 64 client->RecordDidSuppressFatalError(); | 65 client->RecordDidSuppressFatalError(); |
| 65 } else { | 66 } else { |
| 66 console::Fatal(context->GetRenderFrame(), full_message); | 67 console::Fatal(context->GetRenderFrame(), full_message); |
| 67 } | 68 } |
| 68 } | 69 } |
| 69 | 70 |
| 70 void Warn(v8::Isolate* isolate, const std::string& message) { | 71 void Warn(v8::Isolate* isolate, const std::string& message) { |
| 71 ScriptContext* script_context = | 72 ScriptContext* script_context = |
| 72 ScriptContextSet::GetContextByV8Context(isolate->GetCurrentContext()); | 73 ScriptContextSet::GetContextByV8Context(isolate->GetCurrentContext()); |
| 73 console::Warn(script_context ? script_context->GetRenderFrame() : nullptr, | 74 console::AddMessage( |
| 74 message); | 75 script_context ? script_context->GetRenderFrame() : nullptr, |
| 76 content::CONSOLE_MESSAGE_LEVEL_WARNING, message); |
| 75 } | 77 } |
| 76 | 78 |
| 77 // Default exception handler which logs the exception. | 79 // Default exception handler which logs the exception. |
| 78 class DefaultExceptionHandler : public ModuleSystem::ExceptionHandler { | 80 class DefaultExceptionHandler : public ModuleSystem::ExceptionHandler { |
| 79 public: | 81 public: |
| 80 explicit DefaultExceptionHandler(ScriptContext* context) | 82 explicit DefaultExceptionHandler(ScriptContext* context) |
| 81 : ModuleSystem::ExceptionHandler(context) {} | 83 : ModuleSystem::ExceptionHandler(context) {} |
| 82 | 84 |
| 83 // Fatally dumps the debug info from |try_catch| to the console. | 85 // Fatally dumps the debug info from |try_catch| to the console. |
| 84 // 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 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 !value->IsFunction()) { | 842 !value->IsFunction()) { |
| 841 Fatal(context_, module_name + "." + method_name + " is not a function"); | 843 Fatal(context_, module_name + "." + method_name + " is not a function"); |
| 842 return function; | 844 return function; |
| 843 } | 845 } |
| 844 | 846 |
| 845 function = v8::Local<v8::Function>::Cast(value); | 847 function = v8::Local<v8::Function>::Cast(value); |
| 846 return function; | 848 return function; |
| 847 } | 849 } |
| 848 | 850 |
| 849 } // namespace extensions | 851 } // namespace extensions |
| OLD | NEW |