Index: Source/core/page/PageConsole.cpp |
diff --git a/Source/core/page/PageConsole.cpp b/Source/core/page/PageConsole.cpp |
index 440e69dc6581f7c98172d84a7da6dce89dcb0149..dae5842304befdb1b2117f7b8fe4df4ad361d065 100644 |
--- a/Source/core/page/PageConsole.cpp |
+++ b/Source/core/page/PageConsole.cpp |
@@ -54,7 +54,16 @@ |
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) { } |
@@ -113,4 +122,33 @@ 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) { |
+ m_deprecationNotifications = adoptPtr(new BitVector(NumberOfFeatures)); |
pfeldman
2013/04/19 14:19:50
BitVector is not going to take much space.
|
+ m_deprecationNotifications->clearAll(); |
+ } |
+ |
+ if (m_deprecationNotifications->quickGet(feature)) |
+ return; |
+ |
+ m_deprecationNotifications->quickSet(feature); |
+ addMessage(DeprecationMessageSource, WarningMessageLevel, ASCIILiteral(deprecationMessages[feature])); |
+} |
+ |
} // namespace WebCore |