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) |
| 70 : m_page(page) |
| 71 , m_deprecationNotifications(NumberOfFeatures) |
| 72 { |
| 73 } |
61 | 74 |
62 PageConsole::~PageConsole() { } | 75 PageConsole::~PageConsole() { } |
63 | 76 |
64 void PageConsole::addMessage(MessageSource source, MessageLevel level, const Str
ing& message, unsigned long requestIdentifier, Document* document) | 77 void PageConsole::addMessage(MessageSource source, MessageLevel level, const Str
ing& message, unsigned long requestIdentifier, Document* document) |
65 { | 78 { |
66 String url; | 79 String url; |
67 if (document) | 80 if (document) |
68 url = document->url().string(); | 81 url = document->url().string(); |
69 unsigned line = 0; | 82 unsigned line = 0; |
70 if (document && document->parsing() && !document->isInDocumentWrite() && doc
ument->scriptableDocumentParser()) { | 83 if (document && document->parsing() && !document->isInDocumentWrite() && doc
ument->scriptableDocumentParser()) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 muteCount++; | 119 muteCount++; |
107 } | 120 } |
108 | 121 |
109 // static | 122 // static |
110 void PageConsole::unmute() | 123 void PageConsole::unmute() |
111 { | 124 { |
112 ASSERT(muteCount > 0); | 125 ASSERT(muteCount > 0); |
113 muteCount--; | 126 muteCount--; |
114 } | 127 } |
115 | 128 |
| 129 // static |
| 130 void PageConsole::reportDeprecation(Document* document, DeprecatedFeature featur
e) |
| 131 { |
| 132 if (!document) |
| 133 return; |
| 134 |
| 135 Page* page = document->page(); |
| 136 if (!page || !page->console()) |
| 137 return; |
| 138 |
| 139 page->console()->addDeprecationMessage(feature); |
| 140 } |
| 141 |
| 142 void PageConsole::addDeprecationMessage(DeprecatedFeature feature) |
| 143 { |
| 144 ASSERT(feature < NumberOfFeatures); |
| 145 |
| 146 if (m_deprecationNotifications.quickGet(feature)) |
| 147 return; |
| 148 |
| 149 m_deprecationNotifications.quickSet(feature); |
| 150 addMessage(DeprecationMessageSource, WarningMessageLevel, ASCIILiteral(depre
cationMessages[feature])); |
| 151 } |
| 152 |
116 } // namespace WebCore | 153 } // namespace WebCore |
OLD | NEW |