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

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

Issue 111113003: Move PageConsole to using FrameHost instead of Page (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/page/PageConsole.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 12 matching lines...) Expand all
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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/frame/FrameHost.h"
34 #include "core/inspector/ConsoleAPITypes.h" 34 #include "core/inspector/ConsoleAPITypes.h"
35 #include "core/inspector/InspectorConsoleInstrumentation.h" 35 #include "core/inspector/InspectorConsoleInstrumentation.h"
36 #include "core/page/Chrome.h" 36 #include "core/page/Chrome.h"
37 #include "core/page/ChromeClient.h" 37 #include "core/page/ChromeClient.h"
38 #include "core/frame/ConsoleBase.h"
39 #include "core/page/Page.h" 38 #include "core/page/Page.h"
40 #include "wtf/text/StringBuilder.h" 39 #include "wtf/text/StringBuilder.h"
41 #include "wtf/text/WTFString.h"
42 40
43 namespace WebCore { 41 namespace WebCore {
44 42
45 namespace { 43 namespace {
46 44
47 int muteCount = 0; 45 int muteCount = 0;
48 46
49 } 47 }
50 48
51 PageConsole::PageConsole(Page* page) 49 PageConsole::PageConsole(FrameHost& frameHost)
52 : m_page(page) 50 : m_frameHost(frameHost)
53 { 51 {
54 } 52 }
55 53
56 void PageConsole::addMessage(MessageSource source, MessageLevel level, const Str ing& message) 54 void PageConsole::addMessage(MessageSource source, MessageLevel level, const Str ing& message)
57 { 55 {
58 addMessage(source, level, message, String(), 0, 0, 0, 0, 0); 56 addMessage(source, level, message, String(), 0, 0, 0, 0, 0);
59 } 57 }
60 58
61 void PageConsole::addMessage(MessageSource source, MessageLevel level, const Str ing& message, PassRefPtr<ScriptCallStack> callStack) 59 void PageConsole::addMessage(MessageSource source, MessageLevel level, const Str ing& message, PassRefPtr<ScriptCallStack> callStack)
62 { 60 {
63 addMessage(source, level, message, String(), 0, 0, callStack, 0); 61 addMessage(source, level, message, String(), 0, 0, callStack, 0);
64 } 62 }
65 63
66 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) 64 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)
67 { 65 {
68 if (muteCount && source != ConsoleAPIMessageSource) 66 if (muteCount && source != ConsoleAPIMessageSource)
69 return; 67 return;
70 68
71 ExecutionContext* context = m_page->mainFrame()->document(); 69 // FIXME: This should not need to reach for the main-frame.
70 // Inspector code should just take the current frame and know how to walk it self.
71 ExecutionContext* context = m_frameHost.page().mainFrame()->document();
72 if (!context) 72 if (!context)
73 return; 73 return;
74 74
75 String messageURL; 75 String messageURL;
76 if (callStack) { 76 if (callStack) {
77 messageURL = callStack->at(0).sourceURL(); 77 messageURL = callStack->at(0).sourceURL();
78 InspectorInstrumentation::addMessageToConsole(context, source, LogMessag eType, level, message, callStack, requestIdentifier); 78 InspectorInstrumentation::addMessageToConsole(context, source, LogMessag eType, level, message, callStack, requestIdentifier);
79 } else { 79 } else {
80 messageURL = url; 80 messageURL = url;
81 InspectorInstrumentation::addMessageToConsole(context, source, LogMessag eType, level, message, url, lineNumber, columnNumber, state, requestIdentifier); 81 InspectorInstrumentation::addMessageToConsole(context, source, LogMessag eType, level, message, url, lineNumber, columnNumber, state, requestIdentifier);
82 } 82 }
83 83
84 if (source == CSSMessageSource) 84 if (source == CSSMessageSource)
85 return; 85 return;
86 86
87 String stackTrace; 87 String stackTrace;
88 if (callStack && m_page->chrome().client().shouldReportDetailedMessageForSou rce(messageURL)) 88 if (callStack && m_frameHost.chrome().client().shouldReportDetailedMessageFo rSource(messageURL))
89 stackTrace = PageConsole::formatStackTraceString(message, callStack); 89 stackTrace = PageConsole::formatStackTraceString(message, callStack);
90 90
91 m_page->chrome().client().addMessageToConsole(source, level, message, lineNu mber, messageURL, stackTrace); 91 m_frameHost.chrome().client().addMessageToConsole(source, level, message, li neNumber, messageURL, stackTrace);
92 } 92 }
93 93
94 String PageConsole::formatStackTraceString(const String& originalMessage, PassRe fPtr<ScriptCallStack> callStack) 94 String PageConsole::formatStackTraceString(const String& originalMessage, PassRe fPtr<ScriptCallStack> callStack)
95 { 95 {
96 StringBuilder stackTrace; 96 StringBuilder stackTrace;
97 for (size_t i = 0; i < callStack->size(); ++i) { 97 for (size_t i = 0; i < callStack->size(); ++i) {
98 const ScriptCallFrame& frame = callStack->at(i); 98 const ScriptCallFrame& frame = callStack->at(i);
99 stackTrace.append("\n at " + (frame.functionName().length() ? frame.f unctionName() : "(anonymous function)")); 99 stackTrace.append("\n at " + (frame.functionName().length() ? frame.f unctionName() : "(anonymous function)"));
100 stackTrace.append(" ("); 100 stackTrace.append(" (");
101 stackTrace.append(frame.sourceURL()); 101 stackTrace.append(frame.sourceURL());
(...skipping 12 matching lines...) Expand all
114 muteCount++; 114 muteCount++;
115 } 115 }
116 116
117 void PageConsole::unmute() 117 void PageConsole::unmute()
118 { 118 {
119 ASSERT(muteCount > 0); 119 ASSERT(muteCount > 0);
120 muteCount--; 120 muteCount--;
121 } 121 }
122 122
123 } // namespace WebCore 123 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/PageConsole.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698