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

Unified Diff: Source/core/page/PageConsole.cpp

Issue 14320022: Warn developers about deprecated features only once per page-load. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: OwnPtr<BitVector> -> BitVector Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/page/PageConsole.h ('k') | Source/devtools/front_end/ConsoleModel.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/PageConsole.cpp
diff --git a/Source/core/page/PageConsole.cpp b/Source/core/page/PageConsole.cpp
index 440e69dc6581f7c98172d84a7da6dce89dcb0149..399811e8e5ff12020d821ccf0ddd85e9a9eeb9b3 100644
--- a/Source/core/page/PageConsole.cpp
+++ b/Source/core/page/PageConsole.cpp
@@ -54,10 +54,23 @@
namespace WebCore {
namespace {
- int muteCount = 0;
+
+int muteCount = 0;
+
+// Ensure that this stays in sync with the DeprecatedFeature enum.
+static const char* const deprecationMessages[] = {
+ "The 'X-WebKit-CSP' headers are deprecated; please consider using the canonical 'Content-Security-Policy' header instead."
+};
+
+COMPILE_ASSERT(WTF_ARRAY_LENGTH(deprecationMessages) == static_cast<int>(WebCore::PageConsole::NumberOfFeatures), DeprecationMessages_matches_enum);
+
}
-PageConsole::PageConsole(Page* page) : m_page(page) { }
+PageConsole::PageConsole(Page* page)
+ : m_page(page)
+ , m_deprecationNotifications(NumberOfFeatures)
+{
+}
PageConsole::~PageConsole() { }
@@ -113,4 +126,28 @@ void PageConsole::unmute()
muteCount--;
}
+// static
+void PageConsole::reportDeprecation(Document* document, DeprecatedFeature feature)
+{
+ if (!document)
+ return;
+
+ Page* page = document->page();
+ if (!page || !page->console())
+ return;
+
+ page->console()->addDeprecationMessage(feature);
+}
+
+void PageConsole::addDeprecationMessage(DeprecatedFeature feature)
+{
+ ASSERT(feature < NumberOfFeatures);
+
+ if (m_deprecationNotifications.quickGet(feature))
+ return;
+
+ m_deprecationNotifications.quickSet(feature);
+ addMessage(DeprecationMessageSource, WarningMessageLevel, ASCIILiteral(deprecationMessages[feature]));
+}
+
} // namespace WebCore
« no previous file with comments | « Source/core/page/PageConsole.h ('k') | Source/devtools/front_end/ConsoleModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698