Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 #include <stdio.h> | 47 #include <stdio.h> |
| 48 #include <wtf/UnusedParam.h> | 48 #include <wtf/UnusedParam.h> |
| 49 #include <wtf/text/CString.h> | 49 #include <wtf/text/CString.h> |
| 50 #include <wtf/text/WTFString.h> | 50 #include <wtf/text/WTFString.h> |
| 51 | 51 |
| 52 #include "TraceEvent.h" | 52 #include "TraceEvent.h" |
| 53 | 53 |
| 54 namespace WebCore { | 54 namespace WebCore { |
| 55 | 55 |
| 56 namespace { | 56 namespace { |
| 57 int muteCount = 0; | 57 |
| 58 int muteCount = 0; | |
| 59 | |
| 60 // Ensure that this stays in sync with the DeprecatedFeature enum. | |
| 61 static const char* const deprecationMessages[] = { | |
| 62 "The 'X-WebKit-CSP' headers are deprecated; please consider using the canoni cal 'Content-Security-Policy' header instead." | |
| 63 }; | |
| 64 | |
| 65 COMPILE_ASSERT(WTF_ARRAY_LENGTH(deprecationMessages) == static_cast<int>(WebCore ::PageConsole::NumberOfFeatures), DeprecationMessages_matches_enum); | |
| 66 | |
| 58 } | 67 } |
| 59 | 68 |
| 60 PageConsole::PageConsole(Page* page) : m_page(page) { } | 69 PageConsole::PageConsole(Page* page) : m_page(page) { } |
| 61 | 70 |
| 62 PageConsole::~PageConsole() { } | 71 PageConsole::~PageConsole() { } |
| 63 | 72 |
| 64 void PageConsole::addMessage(MessageSource source, MessageLevel level, const Str ing& message, unsigned long requestIdentifier, Document* document) | 73 void PageConsole::addMessage(MessageSource source, MessageLevel level, const Str ing& message, unsigned long requestIdentifier, Document* document) |
| 65 { | 74 { |
| 66 String url; | 75 String url; |
| 67 if (document) | 76 if (document) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 muteCount++; | 115 muteCount++; |
| 107 } | 116 } |
| 108 | 117 |
| 109 // static | 118 // static |
| 110 void PageConsole::unmute() | 119 void PageConsole::unmute() |
| 111 { | 120 { |
| 112 ASSERT(muteCount > 0); | 121 ASSERT(muteCount > 0); |
| 113 muteCount--; | 122 muteCount--; |
| 114 } | 123 } |
| 115 | 124 |
| 125 // static | |
| 126 void PageConsole::reportDeprecation(Document* document, DeprecatedFeature featur e) | |
| 127 { | |
| 128 if (!document) | |
| 129 return; | |
| 130 | |
| 131 Page* page = document->page(); | |
| 132 if (!page || !page->console()) | |
| 133 return; | |
| 134 | |
| 135 page->console()->addDeprecationMessage(feature); | |
| 136 } | |
| 137 | |
| 138 void PageConsole::addDeprecationMessage(DeprecatedFeature feature) | |
| 139 { | |
| 140 ASSERT(feature < NumberOfFeatures); | |
| 141 | |
| 142 if (!m_deprecationNotifications) { | |
| 143 m_deprecationNotifications = adoptPtr(new BitVector(NumberOfFeatures)); | |
|
pfeldman
2013/04/19 14:19:50
BitVector is not going to take much space.
| |
| 144 m_deprecationNotifications->clearAll(); | |
| 145 } | |
| 146 | |
| 147 if (m_deprecationNotifications->quickGet(feature)) | |
| 148 return; | |
| 149 | |
| 150 m_deprecationNotifications->quickSet(feature); | |
| 151 addMessage(DeprecationMessageSource, WarningMessageLevel, ASCIILiteral(depre cationMessages[feature])); | |
| 152 } | |
| 153 | |
| 116 } // namespace WebCore | 154 } // namespace WebCore |
| OLD | NEW |