#ifdef UNSAFE_BUFFERS_BUILD
#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 {
const char kChromeUIScheme[] = …;
const char kChromeUIDinoHost[] = …;
static const char kRedirectLoopLearnMoreUrl[] = …;
enum NAV_SUGGESTIONS { … };
enum SHOW_BUTTONS { … };
struct LocalizedErrorMap { … };
const LocalizedErrorMap net_error_options[] = …;
const LocalizedErrorMap repost_error = …;
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) { … }
base::Value::Dict GetStandardMenuItemsText() { … }
const char* GetIconClassForError(const std::string& error_domain,
int error_code) { … }
base::Value::Dict SingleEntryDictionary(std::string_view path, int message_id) { … }
void AddLinkedSuggestionToList(const int error_code,
const std::string& locale,
base::Value::List& suggestions_summary_list,
bool standalone_suggestion) { … }
bool IsSuggested(int suggestions, int suggestion) { … }
bool IsOnlySuggestion(int suggestions, int suggestion) { … }
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) { … }
void AddSuggestionDetailDictionaryToList(base::Value::List& list,
int header_message_id,
int body_message_id,
bool append_standard_menu_items) { … }
void AddSuggestionsDetails(int error_code,
int suggestions,
base::Value::List& suggestions_details) { … }
std::string HttpErrorCodeToString(int error) { … }
}
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) { … }
bool LocalizedError::IsOfflineError(const std::string& error_domain,
int error_code) { … }
}