| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 return; | 73 return; |
| 74 | 74 |
| 75 // FIXME: This should not need to reach for the main-frame. | 75 // FIXME: This should not need to reach for the main-frame. |
| 76 // Inspector code should just take the current frame and know how to walk it
self. | 76 // Inspector code should just take the current frame and know how to walk it
self. |
| 77 ExecutionContext* context = frame().document(); | 77 ExecutionContext* context = frame().document(); |
| 78 if (!context) | 78 if (!context) |
| 79 return; | 79 return; |
| 80 if (!messageStorage()) | 80 if (!messageStorage()) |
| 81 return; | 81 return; |
| 82 | 82 |
| 83 String messageURL; | |
| 84 unsigned lineNumber = 0; | |
| 85 if (consoleMessage->callStack() && !consoleMessage->callStack()->isEmpty())
{ | |
| 86 lineNumber = consoleMessage->callStack()->topLineNumber(); | |
| 87 messageURL = consoleMessage->callStack()->topSourceURL(); | |
| 88 } else { | |
| 89 lineNumber = consoleMessage->lineNumber(); | |
| 90 messageURL = consoleMessage->url(); | |
| 91 } | |
| 92 | |
| 93 messageStorage()->reportMessage(m_frame->document(), consoleMessage); | 83 messageStorage()->reportMessage(m_frame->document(), consoleMessage); |
| 94 | 84 |
| 95 if (consoleMessage->source() == NetworkMessageSource) | 85 if (consoleMessage->source() == NetworkMessageSource) |
| 96 return; | 86 return; |
| 97 | 87 |
| 98 RefPtr<ScriptCallStack> reportedCallStack; | 88 String stackTrace; |
| 99 if (consoleMessage->source() != ConsoleAPIMessageSource) { | 89 if (consoleMessage->source() == ConsoleAPIMessageSource) { |
| 100 if (consoleMessage->callStack() && frame().chromeClient().shouldReportDe
tailedMessageForSource(frame(), messageURL)) | |
| 101 reportedCallStack = consoleMessage->callStack(); | |
| 102 } else { | |
| 103 if (!frame().host() || (consoleMessage->scriptArguments() && !consoleMes
sage->scriptArguments()->argumentCount())) | 90 if (!frame().host() || (consoleMessage->scriptArguments() && !consoleMes
sage->scriptArguments()->argumentCount())) |
| 104 return; | 91 return; |
| 105 | |
| 106 if (!allClientReportingMessageTypes().contains(consoleMessage->type())) | 92 if (!allClientReportingMessageTypes().contains(consoleMessage->type())) |
| 107 return; | 93 return; |
| 108 | 94 if (frame().chromeClient().shouldReportDetailedMessageForSource(frame(),
consoleMessage->url())) |
| 109 if (frame().chromeClient().shouldReportDetailedMessageForSource(frame(),
messageURL)) | 95 stackTrace = ScriptCallStack::capture()->toString(); |
| 110 reportedCallStack = ScriptCallStack::capture(); | 96 } else { |
| 97 if (consoleMessage->callStack() && frame().chromeClient().shouldReportDe
tailedMessageForSource(frame(), consoleMessage->url())) |
| 98 stackTrace = consoleMessage->callStack()->toString(); |
| 111 } | 99 } |
| 112 | 100 |
| 113 String stackTrace; | 101 frame().chromeClient().addMessageToConsole(m_frame, consoleMessage->source()
, consoleMessage->level(), consoleMessage->message(), consoleMessage->lineNumber
(), consoleMessage->url(), stackTrace); |
| 114 if (reportedCallStack) | |
| 115 stackTrace = reportedCallStack->toString(); | |
| 116 frame().chromeClient().addMessageToConsole(m_frame, consoleMessage->source()
, consoleMessage->level(), consoleMessage->message(), lineNumber, messageURL, st
ackTrace); | |
| 117 } | 102 } |
| 118 | 103 |
| 119 void FrameConsole::reportResourceResponseReceived(DocumentLoader* loader, unsign
ed long requestIdentifier, const ResourceResponse& response) | 104 void FrameConsole::reportResourceResponseReceived(DocumentLoader* loader, unsign
ed long requestIdentifier, const ResourceResponse& response) |
| 120 { | 105 { |
| 121 if (!loader) | 106 if (!loader) |
| 122 return; | 107 return; |
| 123 if (response.httpStatusCode() < 400) | 108 if (response.httpStatusCode() < 400) |
| 124 return; | 109 return; |
| 125 if (response.wasFallbackRequiredByServiceWorker()) | 110 if (response.wasFallbackRequiredByServiceWorker()) |
| 126 return; | 111 return; |
| 127 String message = "Failed to load resource: the server responded with a statu
s of " + String::number(response.httpStatusCode()) + " (" + response.httpStatusT
ext() + ')'; | 112 String message = "Failed to load resource: the server responded with a statu
s of " + String::number(response.httpStatusCode()) + " (" + response.httpStatusT
ext() + ')'; |
| 128 ConsoleMessage* consoleMessage = ConsoleMessage::create(NetworkMessageSource
, ErrorMessageLevel, message, response.url().getString(), 0); | 113 ConsoleMessage* consoleMessage = ConsoleMessage::create(NetworkMessageSource
, ErrorMessageLevel, message, response.url().getString(), 0, 0); |
| 129 consoleMessage->setRequestIdentifier(requestIdentifier); | 114 consoleMessage->setRequestIdentifier(requestIdentifier); |
| 130 addMessage(consoleMessage); | 115 addMessage(consoleMessage); |
| 131 } | 116 } |
| 132 | 117 |
| 133 void FrameConsole::mute() | 118 void FrameConsole::mute() |
| 134 { | 119 { |
| 135 muteCount++; | 120 muteCount++; |
| 136 } | 121 } |
| 137 | 122 |
| 138 void FrameConsole::unmute() | 123 void FrameConsole::unmute() |
| (...skipping 29 matching lines...) Expand all Loading... |
| 168 return; | 153 return; |
| 169 ConsoleMessageStorage* storage = messageStorage(); | 154 ConsoleMessageStorage* storage = messageStorage(); |
| 170 if (!storage) | 155 if (!storage) |
| 171 return; | 156 return; |
| 172 StringBuilder message; | 157 StringBuilder message; |
| 173 message.appendLiteral("Failed to load resource"); | 158 message.appendLiteral("Failed to load resource"); |
| 174 if (!error.localizedDescription().isEmpty()) { | 159 if (!error.localizedDescription().isEmpty()) { |
| 175 message.appendLiteral(": "); | 160 message.appendLiteral(": "); |
| 176 message.append(error.localizedDescription()); | 161 message.append(error.localizedDescription()); |
| 177 } | 162 } |
| 178 ConsoleMessage* consoleMessage = ConsoleMessage::create(NetworkMessageSource
, ErrorMessageLevel, message.toString(), error.failingURL(), 0); | 163 ConsoleMessage* consoleMessage = ConsoleMessage::create(NetworkMessageSource
, ErrorMessageLevel, message.toString(), error.failingURL(), 0, 0); |
| 179 consoleMessage->setRequestIdentifier(requestIdentifier); | 164 consoleMessage->setRequestIdentifier(requestIdentifier); |
| 180 storage->reportMessage(m_frame->document(), consoleMessage); | 165 storage->reportMessage(m_frame->document(), consoleMessage); |
| 181 } | 166 } |
| 182 | 167 |
| 183 DEFINE_TRACE(FrameConsole) | 168 DEFINE_TRACE(FrameConsole) |
| 184 { | 169 { |
| 185 visitor->trace(m_frame); | 170 visitor->trace(m_frame); |
| 186 } | 171 } |
| 187 | 172 |
| 188 } // namespace blink | 173 } // namespace blink |
| OLD | NEW |