mirror of
https://github.com/Alex313031/thorium.git
synced 2025-01-10 03:47:44 -03:00
logging branding and debug args
This commit is contained in:
parent
e218e60eca
commit
e727bcbe51
7 changed files with 2304 additions and 13 deletions
|
@ -16,12 +16,12 @@ enable_stripping = false
|
|||
dcheck_always_on = true
|
||||
exclude_unwind_tables = false
|
||||
# enable_debugallocation = false
|
||||
enable_iterator_debugging = true
|
||||
enable_iterator_debugging = false
|
||||
disable_fieldtrial_testing_config = true
|
||||
enable_reporting = false
|
||||
enable_resource_allowlist_generation = false
|
||||
enable_profiling = true
|
||||
is_component_build = false
|
||||
enable_profiling = false
|
||||
is_component_build = true
|
||||
symbol_level = 2
|
||||
use_debug_fission = true
|
||||
enable_nacl = false
|
||||
|
@ -32,7 +32,7 @@ treat_warnings_as_errors = false
|
|||
# llvm_force_head_revision = true
|
||||
use_lld = true
|
||||
use_icf = true
|
||||
is_cfi = true
|
||||
is_cfi = false
|
||||
v8_symbol_level = 2
|
||||
v8_enable_fast_torque = true
|
||||
use_v8_context_snapshot = true
|
||||
|
|
|
@ -14,12 +14,12 @@ enable_stripping = false
|
|||
dcheck_always_on = true
|
||||
exclude_unwind_tables = false
|
||||
# enable_debugallocation = false
|
||||
enable_iterator_debugging = true
|
||||
enable_iterator_debugging = false
|
||||
disable_fieldtrial_testing_config = true
|
||||
enable_reporting = false
|
||||
enable_resource_allowlist_generation = true
|
||||
enable_profiling = true
|
||||
is_component_build = false
|
||||
enable_profiling = false
|
||||
is_component_build = true
|
||||
symbol_level = 2
|
||||
use_debug_fission = true
|
||||
use_large_pdbs = true
|
||||
|
|
1776
src/chrome/app/chrome_main_delegate.cc
Normal file
1776
src/chrome/app/chrome_main_delegate.cc
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2023 The Chromium Authors and Alex313031
|
||||
// Copyright 2023 The Chromium Authors and Alex313031
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
|
@ -13,9 +13,9 @@
|
|||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
|
||||
#define PRODUCT_STRING "Thorium"
|
||||
#define PRODUCT_STRING "Google Chrome"
|
||||
#elif BUILDFLAG(GOOGLE_CHROME_FOR_TESTING_BRANDING)
|
||||
#define PRODUCT_STRING "Thorium for Testing"
|
||||
#define PRODUCT_STRING "Google Chrome for Testing"
|
||||
#elif BUILDFLAG(CHROMIUM_BRANDING)
|
||||
#define PRODUCT_STRING "Thorium"
|
||||
#else
|
||||
|
@ -25,7 +25,18 @@
|
|||
|
||||
namespace chrome {
|
||||
|
||||
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
|
||||
#define PRODUCT_STRING "Google Chrome"
|
||||
#elif BUILDFLAG(GOOGLE_CHROME_FOR_TESTING_BRANDING)
|
||||
#define PRODUCT_STRING "Google Chrome for Testing"
|
||||
#elif BUILDFLAG(CHROMIUM_BRANDING)
|
||||
#define PRODUCT_STRING "Thorium"
|
||||
#else
|
||||
#error Unknown branding
|
||||
#endif
|
||||
|
||||
const char kChromeVersion[] = CHROME_VERSION_STRING;
|
||||
const char kBrandName[] = PRODUCT_STRING;
|
||||
|
||||
// The following should not be used for UI strings; they are meant
|
||||
// for system strings only. UI changes should be made in the GRD.
|
||||
|
|
108
src/chrome/common/chrome_constants.h
Normal file
108
src/chrome/common/chrome_constants.h
Normal file
|
@ -0,0 +1,108 @@
|
|||
// Copyright 2023 The Chromium Authors and Alex313031
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// A handful of resource-like constants related to the Chrome application.
|
||||
|
||||
#ifndef CHROME_COMMON_CHROME_CONSTANTS_H_
|
||||
#define CHROME_COMMON_CHROME_CONSTANTS_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "build/build_config.h"
|
||||
|
||||
namespace chrome {
|
||||
|
||||
extern const char kChromeVersion[];
|
||||
extern const char kBrandName[];
|
||||
extern const base::FilePath::CharType kBrowserProcessExecutableName[];
|
||||
extern const base::FilePath::CharType kHelperProcessExecutableName[];
|
||||
extern const base::FilePath::CharType kBrowserProcessExecutablePath[];
|
||||
extern const base::FilePath::CharType kHelperProcessExecutablePath[];
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
// NOTE: if you change the value of kFrameworkName, please don't forget to
|
||||
// update components/test/run_all_unittests.cc as well.
|
||||
// TODO(tfarina): Remove the comment above, when you fix components to use plist
|
||||
// on Mac.
|
||||
extern const base::FilePath::CharType kFrameworkName[];
|
||||
extern const base::FilePath::CharType kFrameworkExecutableName[];
|
||||
// Suffix added to the helper app name to display alert notifications. Must be
|
||||
// kept in sync with the value in alert_helper_params (//chrome/BUILD.gn).
|
||||
extern const char kMacHelperSuffixAlerts[];
|
||||
#endif // BUILDFLAG(IS_MAC)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
extern const base::FilePath::CharType kBrowserResourcesDll[];
|
||||
extern const base::FilePath::CharType kElfDll[];
|
||||
extern const base::FilePath::CharType kStatusTrayWindowClass[];
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
extern const char kInitialProfile[];
|
||||
extern const char kMultiProfileDirPrefix[];
|
||||
extern const base::FilePath::CharType kGuestProfileDir[];
|
||||
extern const base::FilePath::CharType kSystemProfileDir[];
|
||||
|
||||
// filenames
|
||||
extern const base::FilePath::CharType kCacheDirname[];
|
||||
extern const base::FilePath::CharType kCookieFilename[];
|
||||
extern const base::FilePath::CharType kCRLSetFilename[];
|
||||
extern const base::FilePath::CharType kCustomDictionaryFileName[];
|
||||
extern const base::FilePath::CharType kDownloadServiceStorageDirname[];
|
||||
extern const base::FilePath::CharType kExtensionActivityLogFilename[];
|
||||
extern const base::FilePath::CharType kExtensionsCookieFilename[];
|
||||
extern const base::FilePath::CharType kFeatureEngagementTrackerStorageDirname[];
|
||||
extern const base::FilePath::CharType kFirstRunSentinel[];
|
||||
extern const base::FilePath::CharType kGCMStoreDirname[];
|
||||
extern const base::FilePath::CharType kLocalStateFilename[];
|
||||
extern const base::FilePath::CharType kMediaCacheDirname[];
|
||||
extern const base::FilePath::CharType kNetworkPersistentStateFilename[];
|
||||
extern const base::FilePath::CharType kNetworkDataDirname[];
|
||||
extern const base::FilePath::CharType kNotificationSchedulerStorageDirname[];
|
||||
extern const base::FilePath::CharType kOfflinePageArchivesDirname[];
|
||||
extern const base::FilePath::CharType kOfflinePageMetadataDirname[];
|
||||
extern const base::FilePath::CharType kOfflinePagePrefetchStoreDirname[];
|
||||
extern const base::FilePath::CharType kOfflinePageRequestQueueDirname[];
|
||||
extern const base::FilePath::CharType kPreferencesFilename[];
|
||||
extern const base::FilePath::CharType kPreviewsOptOutDBFilename[];
|
||||
extern const base::FilePath::CharType kQueryTileStorageDirname[];
|
||||
extern const base::FilePath::CharType kReadmeFilename[];
|
||||
extern const base::FilePath::CharType kReportingAndNelStoreFilename[];
|
||||
extern const base::FilePath::CharType kSCTAuditingPendingReportsFileName[];
|
||||
extern const base::FilePath::CharType kSecurePreferencesFilename[];
|
||||
extern const base::FilePath::CharType kSegmentationPlatformStorageDirName[];
|
||||
extern const base::FilePath::CharType kServiceStateFileName[];
|
||||
extern const base::FilePath::CharType kSingletonCookieFilename[];
|
||||
extern const base::FilePath::CharType kSingletonLockFilename[];
|
||||
extern const base::FilePath::CharType kSingletonSocketFilename[];
|
||||
extern const base::FilePath::CharType kSupervisedUserSettingsFilename[];
|
||||
extern const base::FilePath::CharType kThemePackFilename[];
|
||||
extern const base::FilePath::CharType kTransportSecurityPersisterFilename[];
|
||||
extern const base::FilePath::CharType kTrustTokenFilename[];
|
||||
extern const base::FilePath::CharType kVideoTutorialsStorageDirname[];
|
||||
extern const base::FilePath::CharType kWebAppDirname[];
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
extern const base::FilePath::CharType kJumpListIconDirname[];
|
||||
#endif
|
||||
|
||||
// directory names
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
extern const wchar_t kUserDataDirname[];
|
||||
#endif
|
||||
|
||||
// Fraction of the soft process limit that can be consumed by extensions, before
|
||||
// additional extension processes are ignored. By allowing this many extension
|
||||
// processes to count toward the limit, Chrome takes steps to limit the process
|
||||
// count (e.g., using same-site process sharing) when there are many tabs and
|
||||
// extensions. By ignoring extensions beyond this fraction, Chrome ensures that
|
||||
// a very large number of extensions cannot immediately force the user into a
|
||||
// one-process-per-site mode for all tabs (with poor responsiveness), while
|
||||
// still securely isolating each extension in its own process.
|
||||
extern const float kMaxShareOfExtensionProcesses;
|
||||
|
||||
// Used to identify the application to the system AV function in Windows.
|
||||
extern const char kApplicationClientIDStringForAVScanning[];
|
||||
|
||||
} // namespace chrome
|
||||
|
||||
#endif // CHROME_COMMON_CHROME_CONSTANTS_H_
|
File diff suppressed because one or more lines are too long
385
src/components/neterror/resources/neterror.js
Normal file
385
src/components/neterror/resources/neterror.js
Normal file
|
@ -0,0 +1,385 @@
|
|||
// Copyright 2023 The Chromium Authors and Alex313031
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* downloadButtonClick: function(),
|
||||
* reloadButtonClick: function(string),
|
||||
* detailsButtonClick: function(),
|
||||
* diagnoseErrorsButtonClick: function(),
|
||||
* portalSigninsButtonClick: function(),
|
||||
* trackEasterEgg: function(),
|
||||
* updateEasterEggHighScore: function(number),
|
||||
* resetEasterEggHighScore: function(),
|
||||
* launchOfflineItem: function(string, string),
|
||||
* savePageForLater: function(),
|
||||
* cancelSavePage: function(),
|
||||
* listVisibilityChange: function(boolean),
|
||||
* }}
|
||||
*/
|
||||
// eslint-disable-next-line no-var
|
||||
var errorPageController;
|
||||
|
||||
const HIDDEN_CLASS = 'hidden';
|
||||
|
||||
// Decodes a UTF16 string that is encoded as base64.
|
||||
function decodeUTF16Base64ToString(encoded_text) {
|
||||
const data = atob(encoded_text);
|
||||
let result = '';
|
||||
for (let i = 0; i < data.length; i += 2) {
|
||||
result +=
|
||||
String.fromCharCode(data.charCodeAt(i) * 256 + data.charCodeAt(i + 1));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function toggleHelpBox() {
|
||||
const helpBoxOuter = document.getElementById('details');
|
||||
helpBoxOuter.classList.toggle(HIDDEN_CLASS);
|
||||
const detailsButton = document.getElementById('details-button');
|
||||
if (helpBoxOuter.classList.contains(HIDDEN_CLASS)) {
|
||||
/** @suppress {missingProperties} */
|
||||
detailsButton.innerText = detailsButton.detailsText;
|
||||
} else {
|
||||
/** @suppress {missingProperties} */
|
||||
detailsButton.innerText = detailsButton.hideDetailsText;
|
||||
}
|
||||
|
||||
// Details appears over the main content on small screens.
|
||||
if (mobileNav) {
|
||||
document.getElementById('main-content').classList.toggle(HIDDEN_CLASS);
|
||||
const runnerContainer = document.querySelector('.runner-container');
|
||||
if (runnerContainer) {
|
||||
runnerContainer.classList.toggle(HIDDEN_CLASS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function diagnoseErrors() {
|
||||
if (window.errorPageController) {
|
||||
errorPageController.diagnoseErrorsButtonClick();
|
||||
}
|
||||
}
|
||||
|
||||
function portalSignin() {
|
||||
if (window.errorPageController) {
|
||||
errorPageController.portalSigninButtonClick();
|
||||
}
|
||||
}
|
||||
|
||||
// Subframes use a different layout but the same html file. This is to make it
|
||||
// easier to support platforms that load the error page via different
|
||||
// mechanisms (Currently just iOS). We also use the subframe style for portals
|
||||
// as they are embedded like subframes and can't be interacted with by the user.
|
||||
let isSubFrame = false;
|
||||
if (window.top.location !== window.location || window.portalHost) {
|
||||
document.documentElement.setAttribute('subframe', '');
|
||||
isSubFrame = true;
|
||||
}
|
||||
|
||||
// Re-renders the error page using |strings| as the dictionary of values.
|
||||
// Used by NetErrorTabHelper to update DNS error pages with probe results.
|
||||
function updateForDnsProbe(strings) {
|
||||
const context = new JsEvalContext(strings);
|
||||
jstProcess(context, document.getElementById('t'));
|
||||
onDocumentLoadOrUpdate();
|
||||
}
|
||||
|
||||
// Adds an icon class to the list and removes classes previously set.
|
||||
function updateIconClass(newClass) {
|
||||
const frameSelector = isSubFrame ? '#sub-frame-error' : '#main-frame-error';
|
||||
const iconEl = document.querySelector(frameSelector + ' .icon');
|
||||
|
||||
if (iconEl.classList.contains(newClass)) {
|
||||
return;
|
||||
}
|
||||
|
||||
iconEl.className = 'icon ' + newClass;
|
||||
}
|
||||
|
||||
// Implements button clicks. This function is needed during the transition
|
||||
// between implementing these in trunk chromium and implementing them in iOS.
|
||||
function reloadButtonClick(url) {
|
||||
if (window.errorPageController) {
|
||||
// <if expr="is_ios">
|
||||
errorPageController.reloadButtonClick(url);
|
||||
// </if>
|
||||
|
||||
// <if expr="not is_ios">
|
||||
errorPageController.reloadButtonClick();
|
||||
// </if>
|
||||
} else {
|
||||
window.location = url;
|
||||
}
|
||||
}
|
||||
|
||||
function downloadButtonClick() {
|
||||
if (window.errorPageController) {
|
||||
errorPageController.downloadButtonClick();
|
||||
const downloadButton = document.getElementById('download-button');
|
||||
downloadButton.disabled = true;
|
||||
/** @suppress {missingProperties} */
|
||||
downloadButton.textContent = downloadButton.disabledText;
|
||||
|
||||
document.getElementById('download-link-wrapper')
|
||||
.classList.add(HIDDEN_CLASS);
|
||||
document.getElementById('download-link-clicked-wrapper')
|
||||
.classList.remove(HIDDEN_CLASS);
|
||||
}
|
||||
}
|
||||
|
||||
function detailsButtonClick() {
|
||||
if (window.errorPageController) {
|
||||
errorPageController.detailsButtonClick();
|
||||
}
|
||||
}
|
||||
|
||||
let primaryControlOnLeft = true;
|
||||
// clang-format off
|
||||
// <if expr="is_macosx or is_ios or is_linux or is_chromeos or is_android">
|
||||
// clang-format on
|
||||
primaryControlOnLeft = false;
|
||||
// </if>
|
||||
|
||||
function setAutoFetchState(scheduled, can_schedule) {
|
||||
document.getElementById('cancel-save-page-button')
|
||||
.classList.toggle(HIDDEN_CLASS, !scheduled);
|
||||
document.getElementById('save-page-for-later-button')
|
||||
.classList.toggle(HIDDEN_CLASS, scheduled || !can_schedule);
|
||||
}
|
||||
|
||||
function savePageLaterClick() {
|
||||
errorPageController.savePageForLater();
|
||||
// savePageForLater will eventually trigger a call to setAutoFetchState() when
|
||||
// it completes.
|
||||
}
|
||||
|
||||
function cancelSavePageClick() {
|
||||
errorPageController.cancelSavePage();
|
||||
// setAutoFetchState is not called in response to cancelSavePage(), so do it
|
||||
// now.
|
||||
setAutoFetchState(false, true);
|
||||
}
|
||||
|
||||
function toggleErrorInformationPopup() {
|
||||
document.getElementById('error-information-popup-container')
|
||||
.classList.toggle(HIDDEN_CLASS);
|
||||
}
|
||||
|
||||
function launchOfflineItem(itemID, name_space) {
|
||||
errorPageController.launchOfflineItem(itemID, name_space);
|
||||
}
|
||||
|
||||
function launchDownloadsPage() {
|
||||
errorPageController.launchDownloadsPage();
|
||||
}
|
||||
|
||||
function getIconForSuggestedItem(item) {
|
||||
// Note: |item.content_type| contains the enum values from
|
||||
// chrome::mojom::AvailableContentType.
|
||||
switch (item.content_type) {
|
||||
case 1: // kVideo
|
||||
return 'image-video';
|
||||
case 2: // kAudio
|
||||
return 'image-music-note';
|
||||
case 0: // kPrefetchedPage
|
||||
case 3: // kOtherPage
|
||||
return 'image-earth';
|
||||
}
|
||||
return 'image-file';
|
||||
}
|
||||
|
||||
function getSuggestedContentDiv(item, index) {
|
||||
// Note: See AvailableContentToValue in available_offline_content_helper.cc
|
||||
// for the data contained in an |item|.
|
||||
// TODO(carlosk): Present |snippet_base64| when that content becomes
|
||||
// available.
|
||||
let thumbnail = '';
|
||||
const extraContainerClasses = [];
|
||||
// html_inline.py will try to replace src attributes with data URIs using a
|
||||
// simple regex. The following is obfuscated slightly to avoid that.
|
||||
const source = 'src';
|
||||
if (item.thumbnail_data_uri) {
|
||||
extraContainerClasses.push('suggestion-with-image');
|
||||
thumbnail = `<img ${source}="${item.thumbnail_data_uri}">`;
|
||||
} else {
|
||||
extraContainerClasses.push('suggestion-with-icon');
|
||||
const iconClass = getIconForSuggestedItem(item);
|
||||
thumbnail = `<div><img class="${iconClass}"></div>`;
|
||||
}
|
||||
|
||||
let favicon = '<img ${source}="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAA3XAAAN1wFCKJt4AAABxklEQVRYw81XoW7DMBB9mYKKM2LJKjEJTmn4cPFG23/oB+QfGjpePB7a4BCDZZaMiks3cp28yE7s1G13UqUmju13d+/e2QkiGFOyBJB7ft5pLprLQ4o49gpg4/ltDeAXQBLB+2/6ewbQUSQWU/M0FwkAPCGedZqLFYHwtpgAcqbkMYALUTkACnsROilmBGbZwwGkN15/+2gAraVSzvcEcBw8r4agUkNQjgAqzcXBU4DWAHaO4QOAyqYVYykoAGQeG+cASvq5yu6kuWhvRcISwD5WjhKLprckqUPP9wEN508laC7qEB1YMiX3TMnlYPMyYNPGpwRdKcjI0xNTsqd3oZ53mouaKVlMNacxDuyuza/mYjIK/6oXbM2Tyt17AeUsIw7kV6z5FuJIYim3wiKhIbbyFSEXBzrS7C6U+XPmJSOSuwPw4ln/DYAPzUU1WwkdIDaesjuqdqMkJOItXWICoDZk2myrhQ0cNauF5/59CuDZ0dV6OusP31XG2NYCIvfpqsZdwu/ywZT8ZEq+O8Y2V+uAsWAGYG25x1Vz8xxahmc6NrUAvszeYIuAx9gkCXOj1BrNRWc5TNYGBxAw5izxS8kmDgB3sx9qpKWGIYm9DgAAAABJRU5ErkJggg==">';
|
||||
if (item.favicon_data_uri) {
|
||||
favicon = `<img ${source}="${item.favicon_data_uri}">`;
|
||||
} else {
|
||||
extraContainerClasses.push('no-favicon');
|
||||
}
|
||||
|
||||
if (!item.attribution_base64) {
|
||||
extraContainerClasses.push('no-attribution');
|
||||
}
|
||||
|
||||
return `
|
||||
<div class="offline-content-suggestion ${extraContainerClasses.join(' ')}"
|
||||
onclick="launchOfflineItem('${item.ID}', '${item.name_space}')">
|
||||
<div class="offline-content-suggestion-texts">
|
||||
<div id="offline-content-suggestion-title-${index}"
|
||||
class="offline-content-suggestion-title">
|
||||
</div>
|
||||
<div class="offline-content-suggestion-attribution-freshness">
|
||||
<div id="offline-content-suggestion-favicon-${index}"
|
||||
class="offline-content-suggestion-favicon">
|
||||
${favicon}
|
||||
</div>
|
||||
<div id="offline-content-suggestion-attribution-${index}"
|
||||
class="offline-content-suggestion-attribution">
|
||||
</div>
|
||||
<div class="offline-content-suggestion-freshness">
|
||||
${item.date_modified}
|
||||
</div>
|
||||
<div class="offline-content-suggestion-pin-spacer"></div>
|
||||
<div class="offline-content-suggestion-pin"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="offline-content-suggestion-thumbnail">
|
||||
${thumbnail}
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* ID: string,
|
||||
* name_space: string,
|
||||
* title_base64: string,
|
||||
* snippet_base64: string,
|
||||
* date_modified: string,
|
||||
* attribution_base64: string,
|
||||
* thumbnail_data_uri: string,
|
||||
* favicon_data_uri: string,
|
||||
* content_type: number,
|
||||
* }}
|
||||
*/
|
||||
let AvailableOfflineContent;
|
||||
|
||||
// Populates a list of suggested offline content.
|
||||
// Note: For security reasons all content downloaded from the web is considered
|
||||
// unsafe and must be securely handled to be presented on the dino page. Images
|
||||
// have already been safely re-encoded but textual content -- like title and
|
||||
// attribution -- must be properly handled here.
|
||||
// @param {boolean} isShown
|
||||
// @param {Array<AvailableOfflineContent>} suggestions
|
||||
function offlineContentAvailable(isShown, suggestions) {
|
||||
if (!suggestions || !loadTimeData.valueExists('offlineContentList')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const suggestionsHTML = [];
|
||||
for (let index = 0; index < suggestions.length; index++) {
|
||||
suggestionsHTML.push(getSuggestedContentDiv(suggestions[index], index));
|
||||
}
|
||||
|
||||
document.getElementById('offline-content-suggestions').innerHTML =
|
||||
suggestionsHTML.join('\n');
|
||||
|
||||
// Sets textual web content using |textContent| to make sure it's handled as
|
||||
// plain text.
|
||||
for (let index = 0; index < suggestions.length; index++) {
|
||||
document.getElementById(`offline-content-suggestion-title-${index}`)
|
||||
.textContent =
|
||||
decodeUTF16Base64ToString(suggestions[index].title_base64);
|
||||
document.getElementById(`offline-content-suggestion-attribution-${index}`)
|
||||
.textContent =
|
||||
decodeUTF16Base64ToString(suggestions[index].attribution_base64);
|
||||
}
|
||||
|
||||
const contentListElement = document.getElementById('offline-content-list');
|
||||
if (document.dir === 'rtl') {
|
||||
contentListElement.classList.add('is-rtl');
|
||||
}
|
||||
contentListElement.hidden = false;
|
||||
// The list is configured as hidden by default. Show it if needed.
|
||||
if (isShown) {
|
||||
toggleOfflineContentListVisibility(false);
|
||||
}
|
||||
}
|
||||
|
||||
function toggleOfflineContentListVisibility(updatePref) {
|
||||
if (!loadTimeData.valueExists('offlineContentList')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const contentListElement = document.getElementById('offline-content-list');
|
||||
const isVisible = !contentListElement.classList.toggle('list-hidden');
|
||||
|
||||
if (updatePref && window.errorPageController) {
|
||||
errorPageController.listVisibilityChanged(isVisible);
|
||||
}
|
||||
}
|
||||
|
||||
// Called on document load, and from updateForDnsProbe().
|
||||
function onDocumentLoadOrUpdate() {
|
||||
const downloadButtonVisible = loadTimeData.valueExists('downloadButton') &&
|
||||
loadTimeData.getValue('downloadButton').msg;
|
||||
const detailsButton = document.getElementById('details-button');
|
||||
|
||||
// If offline content suggestions will be visible, the usual buttons will not
|
||||
// be presented.
|
||||
const offlineContentVisible =
|
||||
loadTimeData.valueExists('suggestedOfflineContentPresentation');
|
||||
if (offlineContentVisible) {
|
||||
document.querySelector('.nav-wrapper').classList.add(HIDDEN_CLASS);
|
||||
detailsButton.classList.add(HIDDEN_CLASS);
|
||||
|
||||
document.getElementById('download-link').hidden = !downloadButtonVisible;
|
||||
document.getElementById('download-links-wrapper')
|
||||
.classList.remove(HIDDEN_CLASS);
|
||||
document.getElementById('error-information-popup-container')
|
||||
.classList.add('use-popup-container', HIDDEN_CLASS);
|
||||
document.getElementById('error-information-button')
|
||||
.classList.remove(HIDDEN_CLASS);
|
||||
}
|
||||
|
||||
const attemptAutoFetch = loadTimeData.valueExists('attemptAutoFetch') &&
|
||||
loadTimeData.getValue('attemptAutoFetch');
|
||||
|
||||
const reloadButtonVisible = loadTimeData.valueExists('reloadButton') &&
|
||||
loadTimeData.getValue('reloadButton').msg;
|
||||
|
||||
const reloadButton = document.getElementById('reload-button');
|
||||
const downloadButton = document.getElementById('download-button');
|
||||
if (reloadButton.style.display === 'none' &&
|
||||
downloadButton.style.display === 'none') {
|
||||
detailsButton.classList.add('singular');
|
||||
}
|
||||
|
||||
// Show or hide control buttons.
|
||||
const controlButtonDiv = document.getElementById('control-buttons');
|
||||
controlButtonDiv.hidden =
|
||||
offlineContentVisible || !(reloadButtonVisible || downloadButtonVisible);
|
||||
|
||||
const iconClass = loadTimeData.valueExists('iconClass') &&
|
||||
loadTimeData.getValue('iconClass');
|
||||
|
||||
updateIconClass(iconClass);
|
||||
|
||||
if (!isSubFrame && iconClass === 'icon-offline') {
|
||||
document.documentElement.classList.add('offline');
|
||||
new Runner('.interstitial-wrapper');
|
||||
}
|
||||
}
|
||||
|
||||
function onDocumentLoad() {
|
||||
// Sets up the proper button layout for the current platform.
|
||||
const buttonsDiv = document.getElementById('buttons');
|
||||
if (primaryControlOnLeft) {
|
||||
buttonsDiv.classList.add('suggested-left');
|
||||
} else {
|
||||
buttonsDiv.classList.add('suggested-right');
|
||||
}
|
||||
|
||||
onDocumentLoadOrUpdate();
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', onDocumentLoad);
|
Loading…
Reference in a new issue