chromium/components/error_page/common/localized_error.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

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

#include "components/error_page/common/localized_error.h"

#include <stddef.h>

#include <memory>
#include <string>
#include <string_view>
#include <utility>

#include "base/check_op.h"
#include "base/command_line.h"
#include "base/i18n/rtl.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/field_trial.h"
#include "base/notreached.h"
#include "base/strings/escape.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/error_page/common/alt_game_images.h"
#include "components/error_page/common/error.h"
#include "components/error_page/common/error_page_switches.h"
#include "components/error_page/common/net_error_info.h"
#include "components/offline_pages/core/offline_page_feature.h"
#include "components/strings/grit/components_branded_strings.h"
#include "components/strings/grit/components_strings.h"
#include "components/url_formatter/url_formatter.h"
#include "net/base/net_errors.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
#include "url/origin.h"

#if BUILDFLAG(IS_WIN)
#include "base/win/windows_version.h"
#endif

namespace error_page {

namespace {

// Hardcode these constants to avoid dependences on //chrome and //content.
const char kChromeUIScheme[] =;
const char kChromeUIDinoHost[] =;

static const char kRedirectLoopLearnMoreUrl[] =;

enum NAV_SUGGESTIONS {};

enum SHOW_BUTTONS {};

struct LocalizedErrorMap {};

// clang-format off
const LocalizedErrorMap net_error_options[] =;
// clang-format on

// Special error page to be used in the case of navigating back to a page
// generated by a POST.  LocalizedError::HasStrings expects this net error code
// to also appear in the array above.
const LocalizedErrorMap repost_error =;

// Special error page to be used for hostname resolution errors that resulted
// from secure DNS network failures.  LocalizedError::HasStrings expects this
// net error code to also appear in the array above.
const LocalizedErrorMap secure_dns_network_error =;

const LocalizedErrorMap http_error_options[] =;

const LocalizedErrorMap generic_4xx_5xx_error =;

const LocalizedErrorMap dns_probe_error_options[] =;

const LocalizedErrorMap link_preview_error_options[] =;

const LocalizedErrorMap* FindErrorMapInArray(const LocalizedErrorMap* maps,
                                                   size_t num_maps,
                                                   int error_code) {}

const LocalizedErrorMap* LookupErrorMap(const std::string& error_domain,
                                        int error_code,
                                        bool is_secure_dns_network_error,
                                        bool is_post) {}

// Returns a dictionary containing the strings for the settings menu under the
// app menu, and the advanced settings button.
base::Value::Dict GetStandardMenuItemsText() {}

// Gets the icon class for a given |error_domain| and |error_code|.
const char* GetIconClassForError(const std::string& error_domain,
                                 int error_code) {}

base::Value::Dict SingleEntryDictionary(std::string_view path, int message_id) {}

// Adds a linked suggestion dictionary entry to the suggestions list.
void AddLinkedSuggestionToList(const int error_code,
                               const std::string& locale,
                               base::Value::List& suggestions_summary_list,
                               bool standalone_suggestion) {}

// Check if a suggestion is in the bitmap of suggestions.
bool IsSuggested(int suggestions, int suggestion) {}

// Check suggestion is the only item in the suggestions bitmap.
bool IsOnlySuggestion(int suggestions, int suggestion) {}

// Creates a list of suggestions that a user may try to resolve a particular
// network error. Appears above the fold underneath heading and intro paragraph.
void GetSuggestionsSummaryList(int error_code,
                               base::Value::Dict& error_strings,
                               int suggestions,
                               const std::string& locale,
                               base::Value::List& suggestions_summary_list,
                               bool can_show_network_diagnostics_dialog,
                               const GURL& failed_url,
                               const base::Value::Dict* error_page_params) {}

// Creates a dictionary with "header" and "body" entries and adds it to `list`.
void AddSuggestionDetailDictionaryToList(base::Value::List& list,
                                         int header_message_id,
                                         int body_message_id,
                                         bool append_standard_menu_items) {}

// Certain suggestions have supporting details which get displayed under
// the "Details" button.
void AddSuggestionsDetails(int error_code,
                           int suggestions,
                           base::Value::List& suggestions_details) {}

std::string HttpErrorCodeToString(int error) {}

}  // namespace

LocalizedError::PageState::PageState() = default;
LocalizedError::PageState::~PageState() = default;
LocalizedError::PageState::PageState(PageState&& other) = default;
LocalizedError::PageState& LocalizedError::PageState::operator=(
    PageState&& other) = default;

LocalizedError::PageState LocalizedError::GetPageState(
    int error_code,
    const std::string& error_domain,
    const GURL& failed_url,
    bool is_post,
    bool is_secure_dns_network_error,
    bool stale_copy_in_cache,
    bool can_show_network_diagnostics_dialog,
    bool is_incognito,
    bool offline_content_feature_enabled,
    bool auto_fetch_feature_enabled,
    bool is_kiosk_mode,
    const std::string& locale,
    bool is_blocked_by_extension,
    const base::Value::Dict* error_page_params) {}

LocalizedError::PageState LocalizedError::GetPageStateForOverriddenErrorPage(
    base::Value::Dict string_dict,
    int error_code,
    const std::string& error_domain,
    const GURL& failed_url,
    const std::string& locale) {}

std::u16string LocalizedError::GetErrorDetails(const std::string& error_domain,
                                               int error_code,
                                               bool is_secure_dns_network_error,
                                               bool is_post) {}

bool LocalizedError::HasStrings(const std::string& error_domain,
                                int error_code) {}

// Returns true if the error is due to a disconnected network.
bool LocalizedError::IsOfflineError(const std::string& error_domain,
                                    int error_code) {}

}  // namespace error_page