Commit 62e9021d authored by Maja Kabus's avatar Maja Kabus Committed by Commit Bot

Removed redundant functions and headers from TrustedXXX files

Removed TrustedHTML::escape(), TrustedHTML::unsafelyCreate(),
TrustedScriptURL::unsafelyCreate(), TrustedURL::create(),
TrustedURL::unsafelyCreate().

Current version of Trusted Types API is based on policies and no longer
uses the functions mentioned above.

Bug: 739170
Change-Id: I2bfc430bab3fa9a68ab9f3a0e5d76070841cec51
Reviewed-on: https://chromium-review.googlesource.com/1206474
Commit-Queue: Maja Kabus <kabusm@google.com>
Reviewed-by: default avatarMike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#588860}
parent 2e8c7f72
......@@ -4,33 +4,10 @@
#include "third_party/blink/renderer/core/trustedtypes/trusted_html.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
namespace blink {
TrustedHTML::TrustedHTML(const String& html) : html_(html) {}
TrustedHTML* TrustedHTML::escape(ScriptState* script_state,
const String& html) {
// TODO(mkwst): This could be hugely optimized by scanning the string for any
// of the interesting characters to see whether we need to do any replacement
// at all, and by replacing all the characters in a single pass.
String escapedHTML(html);
escapedHTML.Replace("&", "&amp;")
.Replace("<", "&lt;")
.Replace(">", "&gt;")
.Replace("\"", "&quot;")
.Replace("'", "&#39;");
return TrustedHTML::unsafelyCreate(script_state, escapedHTML);
}
TrustedHTML* TrustedHTML::unsafelyCreate(ScriptState* script_state,
const String& html) {
return TrustedHTML::Create(html);
}
String TrustedHTML::toString() const {
return html_;
}
......
......@@ -7,13 +7,10 @@
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
class ScriptState;
class CORE_EXPORT TrustedHTML final : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
......@@ -24,8 +21,6 @@ class CORE_EXPORT TrustedHTML final : public ScriptWrappable {
// TrustedHTML.idl
String toString() const;
static TrustedHTML* escape(ScriptState*, const String& html);
static TrustedHTML* unsafelyCreate(ScriptState*, const String& html);
private:
TrustedHTML(const String& html);
......
......@@ -2,16 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://github.com/wicg/trusted-types
typedef (DOMString or TrustedHTML) HTMLString;
[
Exposed=(Window,Worker),
RuntimeEnabled=TrustedDOMTypes
] interface TrustedHTML {
[CallWith=ScriptState] static TrustedHTML escape(DOMString html);
[CallWith=ScriptState] static TrustedHTML unsafelyCreate(DOMString html);
stringifier;
};
......@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "third_party/blink/renderer/core/trustedtypes/trusted_script.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
namespace blink {
......
......@@ -7,7 +7,6 @@
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// https://github.com/wicg/trusted-types
typedef (DOMString or TrustedScript) ScriptString;
......
......@@ -4,19 +4,12 @@
#include "third_party/blink/renderer/core/trustedtypes/trusted_script_url.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
TrustedScriptURL::TrustedScriptURL(const KURL& url) : url_(url) {}
TrustedScriptURL* TrustedScriptURL::unsafelyCreate(ScriptState* script_state,
const String& url) {
return TrustedScriptURL::Create(
ExecutionContext::From(script_state)->CompleteURL(url));
}
String TrustedScriptURL::toString() const {
return url_.GetString();
}
......
......@@ -7,13 +7,15 @@
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
namespace WTF {
class String;
class ScriptState;
} // namespace WTF
namespace blink {
class CORE_EXPORT TrustedScriptURL final : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
......@@ -25,7 +27,6 @@ class CORE_EXPORT TrustedScriptURL final : public ScriptWrappable {
// TrustedScriptURL.idl
String toString() const;
static TrustedScriptURL* unsafelyCreate(ScriptState*, const String& url);
private:
TrustedScriptURL(const KURL&);
......
......@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://github.com/wicg/trusted-types
typedef (DOMString or TrustedScriptURL) ScriptURLString;
[
Exposed=(Window,Worker),
RuntimeEnabled=TrustedDOMTypes
] interface TrustedScriptURL {
[CallWith=ScriptState] static TrustedScriptURL unsafelyCreate(DOMString url);
stringifier;
};
......@@ -4,29 +4,12 @@
#include "third_party/blink/renderer/core/trustedtypes/trusted_url.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
TrustedURL::TrustedURL(const KURL& url) : url_(url) {}
TrustedURL* TrustedURL::create(ScriptState* script_state, const String& url) {
KURL result(ExecutionContext::From(script_state)->CompleteURL(url));
if (!result.IsValid() || !result.ProtocolIsInHTTPFamily())
result = KURL("about:invalid");
return TrustedURL::Create(result);
}
TrustedURL* TrustedURL::unsafelyCreate(ScriptState* script_state,
const String& url) {
return TrustedURL::Create(
ExecutionContext::From(script_state)->CompleteURL(url));
}
String TrustedURL::toString() const {
return url_.GetString();
}
......
......@@ -7,13 +7,15 @@
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
namespace WTF {
class String;
class ScriptState;
} // namespace WTF
namespace blink {
class CORE_EXPORT TrustedURL final : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
......@@ -23,8 +25,6 @@ class CORE_EXPORT TrustedURL final : public ScriptWrappable {
// TrustedURL.idl
String toString() const;
static TrustedURL* create(ScriptState*, const String& url);
static TrustedURL* unsafelyCreate(ScriptState*, const String& url);
private:
TrustedURL(const KURL&);
......
......@@ -2,14 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://github.com/wicg/trusted-types
typedef (USVString or TrustedURL) URLString;
[
Exposed=(Window,Worker),
RuntimeEnabled=TrustedDOMTypes
] interface TrustedURL {
[CallWith=ScriptState] static TrustedURL create(USVString url);
[CallWith=ScriptState] static TrustedURL unsafelyCreate(USVString url);
stringifier;
};
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