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

Side by Side Diff: Source/core/page/PageConsole.cpp

Issue 20191003: Route JS Error Info From Blink to Chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@gclient
Patch Set: Adam's requests Created 7 years, 5 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 /* 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 14 matching lines...) Expand all
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "config.h" 29 #include "config.h"
30 #include "core/page/PageConsole.h" 30 #include "core/page/PageConsole.h"
31 31
32 #include "core/dom/Document.h" 32 #include "core/dom/Document.h"
33 #include "core/dom/ScriptableDocumentParser.h" 33 #include "core/dom/ScriptableDocumentParser.h"
34 #include "core/inspector/ConsoleAPITypes.h" 34 #include "core/inspector/ConsoleAPITypes.h"
35 #include "core/inspector/InspectorAgent.h"
35 #include "core/inspector/InspectorConsoleInstrumentation.h" 36 #include "core/inspector/InspectorConsoleInstrumentation.h"
36 #include "core/inspector/ScriptCallStack.h" 37 #include "core/inspector/ScriptCallStack.h"
37 #include "core/page/Chrome.h" 38 #include "core/page/Chrome.h"
38 #include "core/page/ChromeClient.h" 39 #include "core/page/ChromeClient.h"
39 #include "core/page/ConsoleTypes.h" 40 #include "core/page/ConsoleTypes.h"
40 #include "core/page/Page.h" 41 #include "core/page/Page.h"
41 #include "wtf/text/WTFString.h" 42 #include "wtf/text/WTFString.h"
42 43
43 namespace WebCore { 44 namespace WebCore {
44 45
45 namespace { 46 namespace {
46 47
47 int muteCount = 0; 48 int muteCount = 0;
48 49
50 PassOwnPtr<ConsoleMessage> createConsoleMessage(Page* page, MessageSource source , MessageLevel level, const String& message, const String& url, unsigned lineNum ber, unsigned columnNumber, PassRefPtr<ScriptCallStack> callStack, ScriptState* state, unsigned long requestIdentifier)
51 {
52 String executionContextURL = page->mainFrame()->document()->url().string();
53 bool reportDetailedMessage = (state && page->chrome().client()->shouldReport DetailedMessageForContext(state->context()))
54 || page->chrome().client()->shouldReportDetailedMessageForURL(url)
55 || page->chrome().client()->shouldReportDetailedMessageForURL(executionC ontextURL);
56
57 if (callStack)
58 return adoptPtr(new ConsoleMessage(reportDetailedMessage, source, LogMes sageType, level, message, executionContextURL, callStack, requestIdentifier));
59
60 return adoptPtr(new ConsoleMessage(reportDetailedMessage, source, LogMessage Type, level, message, executionContextURL, url, lineNumber, columnNumber, state, requestIdentifier));
49 } 61 }
50 62
63 } // anonymous namespace
64
51 PageConsole::PageConsole(Page* page) 65 PageConsole::PageConsole(Page* page)
52 : m_page(page) 66 : m_page(page)
53 { 67 {
54 } 68 }
55 69
56 PageConsole::~PageConsole() { } 70 PageConsole::~PageConsole() { }
57 71
58 void PageConsole::addMessage(MessageSource source, MessageLevel level, const Str ing& message, unsigned long requestIdentifier, Document* document) 72 void PageConsole::addMessage(MessageSource source, MessageLevel level, const Str ing& message, unsigned long requestIdentifier, Document* document)
59 { 73 {
60 String url; 74 String url;
(...skipping 15 matching lines...) Expand all
76 90
77 void PageConsole::addMessage(MessageSource source, MessageLevel level, const Str ing& message, const String& url, unsigned lineNumber, unsigned columnNumber, Pas sRefPtr<ScriptCallStack> callStack, ScriptState* state, unsigned long requestIde ntifier) 91 void PageConsole::addMessage(MessageSource source, MessageLevel level, const Str ing& message, const String& url, unsigned lineNumber, unsigned columnNumber, Pas sRefPtr<ScriptCallStack> callStack, ScriptState* state, unsigned long requestIde ntifier)
78 { 92 {
79 if (muteCount && source != ConsoleAPIMessageSource) 93 if (muteCount && source != ConsoleAPIMessageSource)
80 return; 94 return;
81 95
82 Page* page = this->page(); 96 Page* page = this->page();
83 if (!page) 97 if (!page)
84 return; 98 return;
85 99
100 OwnPtr<ConsoleMessage> consoleMessage = createConsoleMessage(page, source, l evel, message, url, lineNumber, columnNumber, callStack, state, requestIdentifie r);
101
102 if (source != CSSMessageSource)
103 page->chrome().client()->addMessageToConsole(source, level, message, lin eNumber, url, consoleMessage->generateJSONWithoutArguments()->toJSONString());
104
86 if (callStack) 105 if (callStack)
87 InspectorInstrumentation::addMessageToConsole(page, source, LogMessageTy pe, level, message, callStack, requestIdentifier); 106 InspectorInstrumentation::addMessageToConsole(page, consoleMessage.relea se(), InspectorAgent::DontCheckFrontend);
88 else 107 else
89 InspectorInstrumentation::addMessageToConsole(page, source, LogMessageTy pe, level, message, url, lineNumber, columnNumber, state, requestIdentifier); 108 InspectorInstrumentation::addMessageToConsole(page, consoleMessage.relea se(), InspectorAgent::CheckFrontend);
90
91 if (source == CSSMessageSource)
92 return;
93
94 page->chrome().client()->addMessageToConsole(source, level, message, lineNum ber, url);
95 } 109 }
96 110
97 // static 111 // static
98 void PageConsole::mute() 112 void PageConsole::mute()
99 { 113 {
100 muteCount++; 114 muteCount++;
101 } 115 }
102 116
103 // static 117 // static
104 void PageConsole::unmute() 118 void PageConsole::unmute()
105 { 119 {
106 ASSERT(muteCount > 0); 120 ASSERT(muteCount > 0);
107 muteCount--; 121 muteCount--;
108 } 122 }
109 123
110 } // namespace WebCore 124 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698