| 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/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 namespace extensions { | 25 namespace extensions { |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 const char* kModuleSystem = "module_system"; | 29 const char* kModuleSystem = "module_system"; |
| 30 const char* kModuleName = "module_name"; | 30 const char* kModuleName = "module_name"; |
| 31 const char* kModuleField = "module_field"; | 31 const char* kModuleField = "module_field"; |
| 32 const char* kModulesField = "modules"; | 32 const char* kModulesField = "modules"; |
| 33 | 33 |
| 34 // Logs a fatal error for the calling context, with some added metadata about | 34 // Logs an error for the calling context in preparation for potentially |
| 35 // the context: | 35 // crashing the renderer, with some added metadata about the context: |
| 36 // - Its type (blessed, unblessed, etc). | 36 // - Its type (blessed, unblessed, etc). |
| 37 // - Whether it's valid. | 37 // - Whether it's valid. |
| 38 // - The extension ID, if one exists. | 38 // - The extension ID, if one exists. |
| 39 // | 39 // Crashing won't happen in stable/beta releases, but is encouraged to happen |
| 40 // This will only actual be fatal in in dev/canary, since in too many cases | 40 // in the less stable released to catch errors early. |
| 41 // we're at the mercy of the extension or web page's environment. They can mess | |
| 42 // up our JS in unexpected ways. Hopefully dev/canary channel will pick up such | |
| 43 // problems, but given the wider variety on stable/beta it's impossible to know. | |
| 44 void Fatal(ScriptContext* context, const std::string& message) { | 41 void Fatal(ScriptContext* context, const std::string& message) { |
| 45 // Prepend some context metadata. | 42 // Prepend some context metadata. |
| 46 std::string full_message = "("; | 43 std::string full_message = "("; |
| 47 if (!context->is_valid()) | 44 if (!context->is_valid()) |
| 48 full_message += "Invalid "; | 45 full_message += "Invalid "; |
| 49 full_message += context->GetContextTypeDescription(); | 46 full_message += context->GetContextTypeDescription(); |
| 50 full_message += " context"; | 47 full_message += " context"; |
| 51 if (context->extension()) { | 48 if (context->extension()) { |
| 52 full_message += " for "; | 49 full_message += " for "; |
| 53 full_message += context->extension()->id(); | 50 full_message += context->extension()->id(); |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 | 684 |
| 688 void ModuleSystem::ClobberExistingNativeHandler(const std::string& name) { | 685 void ModuleSystem::ClobberExistingNativeHandler(const std::string& name) { |
| 689 NativeHandlerMap::iterator existing_handler = native_handler_map_.find(name); | 686 NativeHandlerMap::iterator existing_handler = native_handler_map_.find(name); |
| 690 if (existing_handler != native_handler_map_.end()) { | 687 if (existing_handler != native_handler_map_.end()) { |
| 691 clobbered_native_handlers_.push_back(existing_handler->second); | 688 clobbered_native_handlers_.push_back(existing_handler->second); |
| 692 native_handler_map_.erase(existing_handler); | 689 native_handler_map_.erase(existing_handler); |
| 693 } | 690 } |
| 694 } | 691 } |
| 695 | 692 |
| 696 } // namespace extensions | 693 } // namespace extensions |
| OLD | NEW |