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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2035263002: Extract SourceLocation for ConsoleMessages on call sites. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2037593004
Patch Set: Created 4 years, 6 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 3045 matching lines...) Expand 10 before | Expand all | Expand 10 after
3056 String refreshURL; 3056 String refreshURL;
3057 if (!parseHTTPRefresh(content, httpRefreshType == HttpRefreshFromMetaTag, de lay, refreshURL)) 3057 if (!parseHTTPRefresh(content, httpRefreshType == HttpRefreshFromMetaTag, de lay, refreshURL))
3058 return; 3058 return;
3059 if (refreshURL.isEmpty()) 3059 if (refreshURL.isEmpty())
3060 refreshURL = url().getString(); 3060 refreshURL = url().getString();
3061 else 3061 else
3062 refreshURL = completeURL(refreshURL).getString(); 3062 refreshURL = completeURL(refreshURL).getString();
3063 3063
3064 if (protocolIsJavaScript(refreshURL)) { 3064 if (protocolIsJavaScript(refreshURL)) {
3065 String message = "Refused to refresh " + m_url.elidedString() + " to a j avascript: URL"; 3065 String message = "Refused to refresh " + m_url.elidedString() + " to a j avascript: URL";
3066 addConsoleMessage(ConsoleMessage::create(SecurityMessageSource, ErrorMes sageLevel, message)); 3066 addConsoleMessage(ConsoleMessage::create(SecurityMessageSource, ErrorMes sageLevel, message, SourceLocation::capture(this)));
3067 return; 3067 return;
3068 } 3068 }
3069 3069
3070 if (httpRefreshType == HttpRefreshFromMetaTag && isSandboxed(SandboxAutomati cFeatures)) { 3070 if (httpRefreshType == HttpRefreshFromMetaTag && isSandboxed(SandboxAutomati cFeatures)) {
3071 String message = "Refused to execute the redirect specified via '<meta h ttp-equiv='refresh' content='...'>'. The document is sandboxed, and the 'allow-s cripts' keyword is not set."; 3071 String message = "Refused to execute the redirect specified via '<meta h ttp-equiv='refresh' content='...'>'. The document is sandboxed, and the 'allow-s cripts' keyword is not set.";
3072 addConsoleMessage(ConsoleMessage::create(SecurityMessageSource, ErrorMes sageLevel, message)); 3072 addConsoleMessage(ConsoleMessage::create(SecurityMessageSource, ErrorMes sageLevel, message, SourceLocation::capture(this)));
3073 return; 3073 return;
3074 } 3074 }
3075 m_frame->navigationScheduler().scheduleRedirect(delay, refreshURL); 3075 m_frame->navigationScheduler().scheduleRedirect(delay, refreshURL);
3076 } 3076 }
3077 3077
3078 bool Document::shouldMergeWithLegacyDescription(ViewportDescription::Type origin ) const 3078 bool Document::shouldMergeWithLegacyDescription(ViewportDescription::Type origin ) const
3079 { 3079 {
3080 return settings() && settings()->viewportMetaMergeContentQuirk() && m_legacy ViewportDescription.isMetaViewportType() && m_legacyViewportDescription.type == origin; 3080 return settings() && settings()->viewportMetaMergeContentQuirk() && m_legacy ViewportDescription.isMetaViewportType() && m_legacyViewportDescription.type == origin;
3081 } 3081 }
3082 3082
(...skipping 2098 matching lines...) Expand 10 before | Expand all | Expand 10 after
5181 5181
5182 void Document::addConsoleMessage(ConsoleMessage* consoleMessage) 5182 void Document::addConsoleMessage(ConsoleMessage* consoleMessage)
5183 { 5183 {
5184 if (!isContextThread()) { 5184 if (!isContextThread()) {
5185 m_taskRunner->postTask(BLINK_FROM_HERE, AddConsoleMessageTask::create(co nsoleMessage->source(), consoleMessage->level(), consoleMessage->message())); 5185 m_taskRunner->postTask(BLINK_FROM_HERE, AddConsoleMessageTask::create(co nsoleMessage->source(), consoleMessage->level(), consoleMessage->message()));
5186 return; 5186 return;
5187 } 5187 }
5188 5188
5189 if (!m_frame) 5189 if (!m_frame)
5190 return; 5190 return;
5191
5192 if (!consoleMessage->messageId() && !consoleMessage->relatedMessageId() && c onsoleMessage->location()->isUnknown()) {
5193 // TODO(dgozman): capture correct location at call places instead.
5194 unsigned lineNumber = 0;
5195 if (!isInDocumentWrite() && scriptableDocumentParser()) {
5196 ScriptableDocumentParser* parser = scriptableDocumentParser();
5197 if (parser->isParsingAtLineNumber())
5198 lineNumber = parser->lineNumber().oneBasedInt();
5199 }
5200 consoleMessage = ConsoleMessage::create(consoleMessage->source(), consol eMessage->level(), consoleMessage->message(), SourceLocation::create(url().getSt ring(), lineNumber, 0, nullptr), consoleMessage->scriptArguments());
5201 }
5202 m_frame->console().addMessage(consoleMessage); 5191 m_frame->console().addMessage(consoleMessage);
5203 } 5192 }
5204 5193
5205 // FIXME(crbug.com/305497): This should be removed after ExecutionContext-LocalD OMWindow migration. 5194 // FIXME(crbug.com/305497): This should be removed after ExecutionContext-LocalD OMWindow migration.
5206 void Document::postTask(const WebTraceLocation& location, std::unique_ptr<Execut ionContextTask> task) 5195 void Document::postTask(const WebTraceLocation& location, std::unique_ptr<Execut ionContextTask> task)
5207 { 5196 {
5208 m_taskRunner->postTask(location, std::move(task)); 5197 m_taskRunner->postTask(location, std::move(task));
5209 } 5198 }
5210 5199
5211 void Document::postInspectorTask(const WebTraceLocation& location, std::unique_p tr<ExecutionContextTask> task) 5200 void Document::postInspectorTask(const WebTraceLocation& location, std::unique_p tr<ExecutionContextTask> task)
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
5999 #ifndef NDEBUG 5988 #ifndef NDEBUG
6000 using namespace blink; 5989 using namespace blink;
6001 void showLiveDocumentInstances() 5990 void showLiveDocumentInstances()
6002 { 5991 {
6003 WeakDocumentSet& set = liveDocumentSet(); 5992 WeakDocumentSet& set = liveDocumentSet();
6004 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5993 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6005 for (Document* document : set) 5994 for (Document* document : set)
6006 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); 5995 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data());
6007 } 5996 }
6008 #endif 5997 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698