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

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

Issue 14146021: Move deprecation messages to UseCounter::measureDeprecatedFeature. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. 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/UseCounter.h ('k') | Source/modules/quota/DOMWindowQuota.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/UseCounter.cpp
diff --git a/Source/core/page/UseCounter.cpp b/Source/core/page/UseCounter.cpp
index e8df01293cabbda7ab20446f185a235b363b27a5..faf302588a6cb4a3a995a2af0a8a22a2bfef5aaa 100644
--- a/Source/core/page/UseCounter.cpp
+++ b/Source/core/page/UseCounter.cpp
@@ -26,10 +26,13 @@
#include "config.h"
#include "core/page/UseCounter.h"
-#include "Document.h"
+#include "core/dom/Document.h"
+#include "core/dom/ScriptExecutionContext.h"
#include "core/page/DOMWindow.h"
#include "core/page/Page.h"
+#include "core/page/PageConsole.h"
#include "core/platform/HistogramSupport.h"
+#include "wtf/text/WTFString.h"
namespace WebCore {
@@ -75,7 +78,8 @@ void UseCounter::observe(Document* document, Feature feature)
if (!page)
return;
- page->useCounter()->didObserve(feature);
+ ASSERT(page->useCounter()->deprecationMessage(feature)->isEmpty());
+ page->useCounter()->recordObservation(feature);
}
void UseCounter::observe(DOMWindow* domWindow, Feature feature)
@@ -84,4 +88,67 @@ void UseCounter::observe(DOMWindow* domWindow, Feature feature)
observe(domWindow->document(), feature);
}
+void UseCounter::measureDeprecatedFeature(ScriptExecutionContext* context, Feature feature)
+{
+ if (!context || !context->isDocument())
+ return;
+ UseCounter::measureDeprecatedFeature(toDocument(context), feature);
+}
+
+void UseCounter::measureDeprecatedFeature(DOMWindow* window, Feature feature)
+{
+ if (!window)
+ return;
+ UseCounter::measureDeprecatedFeature(window->document(), feature);
+}
+
+void UseCounter::measureDeprecatedFeature(Document* document, Feature feature)
+{
+ if (!document)
+ return;
+
+ Page* page = document->page();
+ if (!page)
+ return;
+
+ if (page->useCounter()->recordObservation(feature)) {
+ ASSERT(!page->useCounter()->deprecationMessage(feature)->isEmpty());
+ page->console()->addMessage(DeprecationMessageSource, WarningMessageLevel, page->useCounter()->deprecationMessage(feature));
+ }
+}
+
+String UseCounter::deprecationMessage(Feature feature)
+{
+ switch (feature) {
+ // Content Security Policy
+ case PrefixedContentSecurityPolicy:
+ case PrefixedContentSecurityPolicyReportOnly:
+ return "The 'X-WebKit-CSP' headers are deprecated; please consider using the canonical 'Content-Security-Policy' header instead.";
+
+ // HTMLMediaElement
+ case PrefixedMediaAddKey:
+ return "'HTMLMediaElement.webkitAddKey()' is deprecated. Please use 'MediaKeySession.update()' instead.";
+ case PrefixedMediaGenerateKeyRequest:
+ return "'HTMLMediaElement.webkitGenerateKeyRequest()' is deprecated. Please use 'MediaKeys.createSession()' instead.";
+
+ // Quota
+ case StorageInfo:
+ return "'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead.";
+
+ // Performance
+ case PrefixedPerformanceTimeline:
+ return "'window.performance.webkitGet*' methods have been deprecated. Please use the unprefixed 'performance.get*' methods instead.";
+ case PrefixedUserTiming:
+ return "'window.performance.webkit*' methods have been deprecated. Please use the unprefixed 'window.performance.*' methods instead.";
+
+ // Web Audio
+ case WebAudioLooping:
+ return "AudioBufferSourceNode 'looping' attribute is deprecated. Use 'loop' instead.";
+
+ // Features that aren't deprecated don't have a deprecation message.
+ default:
+ return String();
+ }
+}
+
} // namespace WebCore
« no previous file with comments | « Source/core/page/UseCounter.h ('k') | Source/modules/quota/DOMWindowQuota.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698