chromium/third_party/blink/renderer/core/html/parser/text_resource_decoder.cc

/*
    Copyright (C) 1999 Lars Knoll ([email protected])
    Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All
    rights reserved.
    Copyright (C) 2005, 2006, 2007 Alexey Proskuryakov ([email protected])

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
*/

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "third_party/blink/renderer/core/html/parser/text_resource_decoder.h"

#include "base/numerics/safe_conversions.h"
#include "base/trace_event/trace_event.h"
#include "third_party/blink/renderer/core/dom/dom_implementation.h"
#include "third_party/blink/renderer/core/html/parser/html_meta_charset_parser.h"
#include "third_party/blink/renderer/platform/text/text_encoding_detector.h"
#include "third_party/blink/renderer/platform/wtf/text/string_view.h"
#include "third_party/blink/renderer/platform/wtf/text/text_codec.h"
#include "third_party/blink/renderer/platform/wtf/text/text_encoding_registry.h"

namespace blink {

const int kMinimumLengthOfXMLDeclaration =;

static inline bool BytesEqual(const char* p,
                              char b0,
                              char b1,
                              char b2,
                              char b3,
                              char b4) {}

static inline bool BytesEqual(const char* p,
                              char b0,
                              char b1,
                              char b2,
                              char b3,
                              char b4,
                              char b5) {}

static inline bool BytesEqual(const char* p,
                              char b0,
                              char b1,
                              char b2,
                              char b3,
                              char b4,
                              char b5,
                              char b6,
                              char b7,
                              char b8,
                              char b9) {}

// You might think we should put these find functions elsewhere, perhaps with
// the similar functions that operate on UChar, but arguably only the decoder
// has a reason to process strings of char rather than UChar.

static int Find(const char* subject, int subject_length, const char* target) {}

static WTF::TextEncoding FindTextEncoding(const char* encoding_name,
                                          wtf_size_t length) {}

const WTF::TextEncoding& TextResourceDecoder::DefaultEncoding(
    TextResourceDecoderOptions::ContentType content_type,
    const WTF::TextEncoding& specified_default_encoding) {}

TextResourceDecoder::TextResourceDecoder(
    const TextResourceDecoderOptions& options)
    :{}

TextResourceDecoder::~TextResourceDecoder() = default;

void TextResourceDecoder::AddToBuffer(const char* data,
                                      wtf_size_t data_length) {}

void TextResourceDecoder::AddToBufferIfEmpty(const char* data,
                                             wtf_size_t data_length) {}

void TextResourceDecoder::SetEncoding(const WTF::TextEncoding& encoding,
                                      EncodingSource source) {}

// Returns the position of the encoding string.
static int FindXMLEncoding(const char* str, int len, int& encoding_length) {}

wtf_size_t TextResourceDecoder::CheckForBOM(const char* data, wtf_size_t len) {}

bool TextResourceDecoder::CheckForCSSCharset(const char* data, wtf_size_t len) {}

bool TextResourceDecoder::CheckForXMLCharset(const char* data, wtf_size_t len) {}

void TextResourceDecoder::CheckForMetaCharset(const char* data,
                                              wtf_size_t length) {}

// We use the encoding detector in two cases:
//   1. Encoding detector is turned ON and no other encoding source is
//      available (that is, it's DefaultEncoding).
//   2. Encoding detector is turned ON and the encoding is set to
//      the encoding of the parent frame, which is also auto-detected.
//   Note that condition #2 is NOT satisfied unless parent-child frame
//   relationship is compliant to the same-origin policy. If they're from
//   different domains, |source_| would not be set to EncodingFromParentFrame
//   in the first place.
void TextResourceDecoder::AutoDetectEncodingIfAllowed(const char* data,
                                                      wtf_size_t len) {}

String TextResourceDecoder::Decode(const char* data, size_t data_len) {}

String TextResourceDecoder::Flush() {}

WebEncodingData TextResourceDecoder::GetEncodingData() const {}

}  // namespace blink