Commit 0065c114 authored by Sophie Chang's avatar Sophie Chang Committed by Commit Bot

Add usecounters for window.history.pushState and window.history.replaceState and expose to UKM

Bug: 898982
Change-Id: I37d2006abe68282d9d068f7a19d7d501bd4ee5bd
Reviewed-on: https://chromium-review.googlesource.com/c/1299919
Commit-Queue: Sophie Chang <sophiechang@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605108}
parent 1be9c268
...@@ -60,6 +60,7 @@ bool IsAllowedUkmFeature(blink::mojom::WebFeature feature) { ...@@ -60,6 +60,7 @@ bool IsAllowedUkmFeature(blink::mojom::WebFeature feature) {
WebFeature::kDocumentDomainEnabledCrossOriginAccess, WebFeature::kDocumentDomainEnabledCrossOriginAccess,
WebFeature::kSuppressHistoryEntryWithoutUserGesture, WebFeature::kSuppressHistoryEntryWithoutUserGesture,
WebFeature::kCursorImageGT32x32, WebFeature::kCursorImageLE32x32, WebFeature::kCursorImageGT32x32, WebFeature::kCursorImageLE32x32,
WebFeature::kHistoryPushState, WebFeature::kHistoryReplaceState,
})); }));
return opt_in_features->count(feature); return opt_in_features->count(feature);
} }
...@@ -2066,6 +2066,8 @@ enum WebFeature { ...@@ -2066,6 +2066,8 @@ enum WebFeature {
kCSSValueAppearanceNoImplementationSkipBorder = 2614, kCSSValueAppearanceNoImplementationSkipBorder = 2614,
kInstantiateModuleScript = 2615, kInstantiateModuleScript = 2615,
kDynamicImportModuleScript = 2616, kDynamicImportModuleScript = 2616,
kHistoryPushState = 2617,
kHistoryReplaceState = 2618,
// Add new features immediately above this line. Don't change assigned // Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots. // numbers of any item, and don't reuse removed slots.
// Also, run update_use_counter_feature_enum.py in // Also, run update_use_counter_feature_enum.py in
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_client.h" #include "third_party/blink/renderer/core/frame/local_frame_client.h"
#include "third_party/blink/renderer/core/frame/settings.h" #include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/frame/use_counter.h"
#include "third_party/blink/renderer/core/inspector/console_message.h" #include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/loader/document_loader.h" #include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/loader/frame_loader.h" #include "third_party/blink/renderer/core/loader/frame_loader.h"
...@@ -212,6 +213,16 @@ void History::pushState(scoped_refptr<SerializedScriptValue> data, ...@@ -212,6 +213,16 @@ void History::pushState(scoped_refptr<SerializedScriptValue> data,
ExceptionState& exception_state) { ExceptionState& exception_state) {
StateObjectAdded(std::move(data), title, url, ScrollRestorationInternal(), StateObjectAdded(std::move(data), title, url, ScrollRestorationInternal(),
WebFrameLoadType::kStandard, exception_state); WebFrameLoadType::kStandard, exception_state);
UseCounter::Count(GetFrame(), WebFeature::kHistoryPushState);
}
void History::replaceState(scoped_refptr<SerializedScriptValue> data,
const String& title,
const String& url,
ExceptionState& exception_state) {
StateObjectAdded(std::move(data), title, url, ScrollRestorationInternal(),
WebFrameLoadType::kReplaceCurrentItem, exception_state);
UseCounter::Count(GetFrame(), WebFeature::kHistoryReplaceState);
} }
KURL History::UrlForState(const String& url_string) { KURL History::UrlForState(const String& url_string) {
......
...@@ -68,10 +68,7 @@ class CORE_EXPORT History final : public ScriptWrappable, ...@@ -68,10 +68,7 @@ class CORE_EXPORT History final : public ScriptWrappable,
void replaceState(scoped_refptr<SerializedScriptValue> data, void replaceState(scoped_refptr<SerializedScriptValue> data,
const String& title, const String& title,
const String& url, const String& url,
ExceptionState& exception_state) { ExceptionState& exception_state);
StateObjectAdded(std::move(data), title, url, ScrollRestorationInternal(),
WebFrameLoadType::kReplaceCurrentItem, exception_state);
}
void setScrollRestoration(const String& value, ExceptionState&); void setScrollRestoration(const String& value, ExceptionState&);
String scrollRestoration(ExceptionState&); String scrollRestoration(ExceptionState&);
......
...@@ -20639,6 +20639,8 @@ Called by update_net_error_codes.py.--> ...@@ -20639,6 +20639,8 @@ Called by update_net_error_codes.py.-->
<int value="2614" label="CSSValueAppearanceNoImplementationSkipBorder"/> <int value="2614" label="CSSValueAppearanceNoImplementationSkipBorder"/>
<int value="2615" label="InstantiateModuleScript"/> <int value="2615" label="InstantiateModuleScript"/>
<int value="2616" label="DynamicImportModuleScript"/> <int value="2616" label="DynamicImportModuleScript"/>
<int value="2617" label="HistoryPushState"/>
<int value="2618" label="HistoryReplaceState"/>
</enum> </enum>
<enum name="FeaturePolicyFeature"> <enum name="FeaturePolicyFeature">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment