OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/frame/Deprecation.h" | 5 #include "core/frame/Deprecation.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/dom/ExecutionContext.h" | 8 #include "core/dom/ExecutionContext.h" |
9 #include "core/frame/FrameConsole.h" | 9 #include "core/frame/FrameConsole.h" |
10 #include "core/frame/FrameHost.h" | 10 #include "core/frame/FrameHost.h" |
11 #include "core/frame/LocalFrame.h" | 11 #include "core/frame/LocalFrame.h" |
12 #include "core/inspector/ConsoleMessage.h" | 12 #include "core/inspector/ConsoleMessage.h" |
13 #include "core/workers/WorkerGlobalScope.h" | 13 #include "core/workers/WorkerGlobalScope.h" |
14 | 14 |
| 15 namespace { |
| 16 |
| 17 const char* milestoneString(int milestone) |
| 18 { |
| 19 // These are the Estimated Stable Dates: |
| 20 // https://www.chromium.org/developers/calendar |
| 21 |
| 22 switch (milestone) { |
| 23 case 50: |
| 24 return "M50, around April 2016"; |
| 25 case 51: |
| 26 return "M51, around May 2016"; |
| 27 case 52: |
| 28 return "M52, around July 2016"; |
| 29 case 53: |
| 30 return "M53, around September 2016"; |
| 31 case 54: |
| 32 return "M54, around October 2016"; |
| 33 } |
| 34 |
| 35 ASSERT_NOT_REACHED(); |
| 36 return nullptr; |
| 37 } |
| 38 |
| 39 String replacedBy(const char* feature, const char* replacement) |
| 40 { |
| 41 return String::format("%s is deprecated. Please use %s instead.", feature, r
eplacement); |
| 42 } |
| 43 |
| 44 String willBeRemoved(const char* feature, int milestone, const char* details) |
| 45 { |
| 46 return String::format("%s is deprecated and will be removed in %s. See https
://www.chromestatus.com/features/%s for more details.", feature, milestoneString
(milestone), details); |
| 47 } |
| 48 |
| 49 String replacedWillBeRemoved(const char* feature, const char* replacement, int m
ilestone, const char* details) |
| 50 { |
| 51 return String::format("%s is deprecated and will be removed in %s. Please us
e %s instead. See https://www.chromestatus.com/features/%s for more details.", f
eature, milestoneString(milestone), replacement, details); |
| 52 } |
| 53 |
| 54 } // anonymous namespace |
| 55 |
15 namespace blink { | 56 namespace blink { |
16 | 57 |
17 Deprecation::Deprecation() | 58 Deprecation::Deprecation() |
18 { | 59 { |
19 m_cssPropertyDeprecationBits.ensureSize(lastUnresolvedCSSProperty + 1); | 60 m_cssPropertyDeprecationBits.ensureSize(lastUnresolvedCSSProperty + 1); |
20 } | 61 } |
21 | 62 |
22 Deprecation::~Deprecation() | 63 Deprecation::~Deprecation() |
23 { | 64 { |
24 } | 65 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 Deprecation::countDeprecation(document.frame(), feature); | 137 Deprecation::countDeprecation(document.frame(), feature); |
97 } | 138 } |
98 | 139 |
99 void Deprecation::countDeprecationIfNotPrivateScript(v8::Isolate* isolate, Execu
tionContext* context, UseCounter::Feature feature) | 140 void Deprecation::countDeprecationIfNotPrivateScript(v8::Isolate* isolate, Execu
tionContext* context, UseCounter::Feature feature) |
100 { | 141 { |
101 if (DOMWrapperWorld::current(isolate).isPrivateScriptIsolatedWorld()) | 142 if (DOMWrapperWorld::current(isolate).isPrivateScriptIsolatedWorld()) |
102 return; | 143 return; |
103 Deprecation::countDeprecation(context, feature); | 144 Deprecation::countDeprecation(context, feature); |
104 } | 145 } |
105 | 146 |
106 static const char* milestoneString(int milestone) | |
107 { | |
108 // These are the Estimated Stable Dates: | |
109 // https://www.chromium.org/developers/calendar | |
110 | |
111 switch (milestone) { | |
112 case 50: | |
113 return "M50, around April 2016"; | |
114 case 51: | |
115 return "M51, around May 2016"; | |
116 case 52: | |
117 return "M52, around July 2016"; | |
118 case 53: | |
119 return "M53, around September 2016"; | |
120 case 54: | |
121 return "M54, around October 2016"; | |
122 } | |
123 | |
124 ASSERT_NOT_REACHED(); | |
125 return nullptr; | |
126 } | |
127 | |
128 static String replacedBy(const char* feature, const char* replacement) | |
129 { | |
130 return String::format("%s is deprecated. Please use %s instead.", feature, r
eplacement); | |
131 } | |
132 | |
133 String Deprecation::willBeRemoved(const char* feature, int milestone, const char
* details) | |
134 { | |
135 return String::format("%s is deprecated and will be removed in %s. See https
://www.chromestatus.com/features/%s for more details.", feature, milestoneString
(milestone), details); | |
136 } | |
137 | |
138 static String replacedWillBeRemoved(const char* feature, const char* replacement
, int milestone, const char* details) | |
139 { | |
140 return String::format("%s is deprecated and will be removed in %s. Please us
e %s instead. See https://www.chromestatus.com/features/%s for more details.", f
eature, milestoneString(milestone), replacement, details); | |
141 } | |
142 | |
143 String Deprecation::deprecationMessage(UseCounter::Feature feature) | 147 String Deprecation::deprecationMessage(UseCounter::Feature feature) |
144 { | 148 { |
145 switch (feature) { | 149 switch (feature) { |
146 // Quota | 150 // Quota |
147 case UseCounter::PrefixedStorageInfo: | 151 case UseCounter::PrefixedStorageInfo: |
148 return replacedBy("'window.webkitStorageInfo'", "'navigator.webkitTempor
aryStorage' or 'navigator.webkitPersistentStorage'"); | 152 return replacedBy("'window.webkitStorageInfo'", "'navigator.webkitTempor
aryStorage' or 'navigator.webkitPersistentStorage'"); |
149 | 153 |
150 case UseCounter::ConsoleMarkTimeline: | 154 case UseCounter::ConsoleMarkTimeline: |
151 return replacedBy("'console.markTimeline'", "'console.timeStamp'"); | 155 return replacedBy("'console.markTimeline'", "'console.timeStamp'"); |
152 | 156 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 case UseCounter::HTMLKeygenElement: | 344 case UseCounter::HTMLKeygenElement: |
341 return willBeRemoved("The <keygen> element", 54, "5716060992962560"); | 345 return willBeRemoved("The <keygen> element", 54, "5716060992962560"); |
342 | 346 |
343 // Features that aren't deprecated don't have a deprecation message. | 347 // Features that aren't deprecated don't have a deprecation message. |
344 default: | 348 default: |
345 return String(); | 349 return String(); |
346 } | 350 } |
347 } | 351 } |
348 | 352 |
349 } // namespace blink | 353 } // namespace blink |
OLD | NEW |