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 |