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::AddMessage(context->GetRenderFrame(), | 63 console::AddMessage(context, content::CONSOLE_MESSAGE_LEVEL_ERROR, |
64 content::CONSOLE_MESSAGE_LEVEL_ERROR, full_message); | 64 full_message); |
65 client->RecordDidSuppressFatalError(); | 65 client->RecordDidSuppressFatalError(); |
66 } else { | 66 } else { |
67 console::Fatal(context->GetRenderFrame(), full_message); | 67 console::Fatal(context, full_message); |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 void Warn(v8::Isolate* isolate, const std::string& message) { | 71 void Warn(v8::Isolate* isolate, const std::string& message) { |
72 ScriptContext* script_context = | 72 ScriptContext* script_context = |
73 ScriptContextSet::GetContextByV8Context(isolate->GetCurrentContext()); | 73 ScriptContextSet::GetContextByV8Context(isolate->GetCurrentContext()); |
74 console::AddMessage( | 74 console::AddMessage(script_context, content::CONSOLE_MESSAGE_LEVEL_WARNING, |
75 script_context ? script_context->GetRenderFrame() : nullptr, | 75 message); |
76 content::CONSOLE_MESSAGE_LEVEL_WARNING, message); | |
77 } | 76 } |
78 | 77 |
79 // Default exception handler which logs the exception. | 78 // Default exception handler which logs the exception. |
80 class DefaultExceptionHandler : public ModuleSystem::ExceptionHandler { | 79 class DefaultExceptionHandler : public ModuleSystem::ExceptionHandler { |
81 public: | 80 public: |
82 explicit DefaultExceptionHandler(ScriptContext* context) | 81 explicit DefaultExceptionHandler(ScriptContext* context) |
83 : ModuleSystem::ExceptionHandler(context) {} | 82 : ModuleSystem::ExceptionHandler(context) {} |
84 | 83 |
85 // Fatally dumps the debug info from |try_catch| to the console. | 84 // Fatally dumps the debug info from |try_catch| to the console. |
86 // Make sure this is never used for exceptions that originate in external | 85 // Make sure this is never used for exceptions that originate in external |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 !value->IsFunction()) { | 880 !value->IsFunction()) { |
882 Fatal(context_, module_name + "." + method_name + " is not a function"); | 881 Fatal(context_, module_name + "." + method_name + " is not a function"); |
883 return function; | 882 return function; |
884 } | 883 } |
885 | 884 |
886 function = v8::Local<v8::Function>::Cast(value); | 885 function = v8::Local<v8::Function>::Cast(value); |
887 return function; | 886 return function; |
888 } | 887 } |
889 | 888 |
890 } // namespace extensions | 889 } // namespace extensions |
OLD | NEW |