mirror of
https://github.com/Alex313031/thorium.git
synced 2025-01-09 11:27:32 -03:00
compilation fixes
This commit is contained in:
parent
d75f1302c8
commit
46f9193e29
13 changed files with 1017 additions and 433 deletions
|
@ -2232,7 +2232,7 @@ config("no_chromium_code") {
|
|||
# third-party libraries.
|
||||
"-Wno-c++11-narrowing",
|
||||
]
|
||||
if (is_full_optimization_build) {
|
||||
if (is_official_build) {
|
||||
cflags += [ "-Xclang", "-O3" ]
|
||||
}
|
||||
if (!is_nacl) {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -68,7 +68,7 @@ diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
|
|||
index c9e74052c7afb..d271ccc0dca71 100644
|
||||
--- a/chrome/browser/about_flags.cc
|
||||
+++ b/chrome/browser/about_flags.cc
|
||||
@@ -8537,6 +8537,12 @@ const FeatureEntry kFeatureEntries[] = {
|
||||
@@ -8540,6 +8540,12 @@ const FeatureEntry kFeatureEntries[] = {
|
||||
FEATURE_VALUE_TYPE(
|
||||
heavy_ad_intervention::features::kHeavyAdPrivacyMitigations)},
|
||||
|
||||
|
|
|
@ -617,7 +617,7 @@ diff --git a/chrome/browser/ui/tabs/tab_strip_model.cc b/chrome/browser/ui/tabs/
|
|||
index 91513d4488166..4fa0ac198e9c6 100644
|
||||
--- a/chrome/browser/ui/tabs/tab_strip_model.cc
|
||||
+++ b/chrome/browser/ui/tabs/tab_strip_model.cc
|
||||
@@ -1296,6 +1296,7 @@ bool TabStripModel::IsContextMenuCommandEnabled(
|
||||
@@ -1298,6 +1298,7 @@ bool TabStripModel::IsContextMenuCommandEnabled(
|
||||
ContextMenuCommand command_id) const {
|
||||
DCHECK(command_id > CommandFirst && command_id < CommandLast);
|
||||
switch (command_id) {
|
||||
|
@ -625,7 +625,7 @@ index 91513d4488166..4fa0ac198e9c6 100644
|
|||
case CommandNewTabToRight:
|
||||
case CommandCloseTab:
|
||||
return true;
|
||||
@@ -1397,6 +1398,16 @@ void TabStripModel::ExecuteContextMenuCommand(int context_index,
|
||||
@@ -1399,6 +1400,16 @@ void TabStripModel::ExecuteContextMenuCommand(int context_index,
|
||||
if (!ContainsIndex(context_index))
|
||||
return;
|
||||
switch (command_id) {
|
||||
|
@ -1526,7 +1526,7 @@ index e7660352853f2..4f45152a72d4c 100644
|
|||
- vector_icons::kAddIcon);
|
||||
+ features::IsThorium2024()
|
||||
+ ? kAddIcon
|
||||
+ : kAddChromeRefreshIcon
|
||||
+ : vector_icons::kAddIcon
|
||||
+ );
|
||||
tab_strip_control_button->SetProperty(views::kElementIdentifierKey,
|
||||
kNewTabButtonElementId);
|
||||
|
|
|
@ -614,7 +614,7 @@ config("compiler") {
|
|||
}
|
||||
}
|
||||
|
||||
if (use_avx2 || use_avx512)
|
||||
if (use_avx2 || use_avx512) {
|
||||
if (is_win) {
|
||||
cflags += [ "/clang:-ffp-contract=fast" ]
|
||||
} else {
|
||||
|
@ -1246,26 +1246,26 @@ config("compiler_cpu_abi") {
|
|||
"-O3",
|
||||
"-msse3",
|
||||
]
|
||||
if (use_sse41)
|
||||
if (use_sse41) {
|
||||
cflags += [
|
||||
"-mssse3",
|
||||
"-msse4.1",
|
||||
]
|
||||
}
|
||||
if (use_sse42)
|
||||
if (use_sse42) {
|
||||
cflags += [
|
||||
"-msse4",
|
||||
"-msse4.2",
|
||||
]
|
||||
}
|
||||
if (use_avx)
|
||||
if (use_avx) {
|
||||
cflags += [
|
||||
"-mpclmul",
|
||||
"-maes",
|
||||
"-mavx",
|
||||
]
|
||||
}
|
||||
if (use_avx2)
|
||||
if (use_avx2) {
|
||||
cflags += [
|
||||
"-mavx2",
|
||||
"-mfma",
|
||||
|
@ -1276,7 +1276,7 @@ config("compiler_cpu_abi") {
|
|||
"-mtune=haswell",
|
||||
]
|
||||
}
|
||||
if (use_avx512)
|
||||
if (use_avx512) {
|
||||
cflags += [
|
||||
"-mavx512f",
|
||||
"-mavx512cd",
|
||||
|
@ -1298,25 +1298,25 @@ config("compiler_cpu_abi") {
|
|||
]
|
||||
}
|
||||
ldflags += [ "-m64", "-Wl,-O3", "-msse3", "-Wl,-mllvm,-import-instr-limit=100", ]
|
||||
if (use_sse41)
|
||||
if (use_sse41) {
|
||||
ldflags += [
|
||||
"-mssse3",
|
||||
"-msse4.1",
|
||||
]
|
||||
}
|
||||
if (use_sse42)
|
||||
if (use_sse42) {
|
||||
ldflags += [
|
||||
"-msse4.2",
|
||||
]
|
||||
}
|
||||
if (use_avx)
|
||||
if (use_avx) {
|
||||
ldflags += [
|
||||
"-mpclmul",
|
||||
"-maes",
|
||||
"-mavx",
|
||||
]
|
||||
}
|
||||
if (use_avx2)
|
||||
if (use_avx2) {
|
||||
ldflags += [
|
||||
"-mavx2",
|
||||
"-mfma",
|
||||
|
@ -1327,7 +1327,7 @@ config("compiler_cpu_abi") {
|
|||
"-Wl,-mllvm,-march=haswell",
|
||||
]
|
||||
}
|
||||
if (use_avx512)
|
||||
if (use_avx512) {
|
||||
ldflags += [
|
||||
"-mavx512f",
|
||||
"-mavx512cd",
|
||||
|
@ -1356,13 +1356,13 @@ config("compiler_cpu_abi") {
|
|||
"-mmmx",
|
||||
"-msse2",
|
||||
]
|
||||
if (use_sse3)
|
||||
if (use_sse3) {
|
||||
cflags += [ "-msse3", ]
|
||||
}
|
||||
if (use_sse41)
|
||||
if (use_sse41) {
|
||||
cflags += [ "-mssse3", "-msse4.1", ]
|
||||
}
|
||||
if (use_sse42)
|
||||
if (use_sse42) {
|
||||
cflags += [ "-msse4", "-msse4.2", ]
|
||||
}
|
||||
}
|
||||
|
@ -2331,7 +2331,7 @@ config("no_chromium_code") {
|
|||
# third-party libraries.
|
||||
"-Wno-c++11-narrowing",
|
||||
]
|
||||
if (is_full_optimization_build) {
|
||||
if (is_official_build) {
|
||||
cflags += [ "-Xclang", "-O3" ]
|
||||
}
|
||||
if (!is_nacl) {
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
## For information about compiler flags and optimizations
|
||||
## that this uses, see https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
|
||||
|
||||
import("//build/config/BUILDCONFIG.gn")
|
||||
|
||||
declare_args() {
|
||||
|
||||
# Whether to enable LLVM's Polly optimizations.
|
||||
|
@ -77,7 +75,9 @@ declare_args() {
|
|||
# `-mavx512f -mavx512cd -mavx512vl -mavx512bw -mavx512dq
|
||||
# -mf16c -mlzcnt -mbmi2`
|
||||
use_avx512 = false
|
||||
}
|
||||
|
||||
declare_args() {
|
||||
# FMA
|
||||
# "Fused Multiply Add" operations
|
||||
# Present since Haswell and AMD Piledriver (2nd Gen. refinement
|
||||
|
@ -86,7 +86,7 @@ declare_args() {
|
|||
use_fma = use_avx2
|
||||
}
|
||||
|
||||
if (is_debug || !use_thin_lto) {
|
||||
if (is_debug) {
|
||||
assert(!use_polly, "use_polly only works with non-debug builds")
|
||||
assert(!use_bolt, "use_bolt only works with non-debug builds")
|
||||
}
|
||||
|
@ -102,8 +102,7 @@ if (use_avx || use_avx2 || use_fma) {
|
|||
# to set use_fma = true even with AVX2 off, such as when making a build for
|
||||
# an AMD Piledriver or Steamroller CPU.
|
||||
if (use_avx2 && !use_fma) {
|
||||
print("WARNING: Use_avx2 is true while use_fma is false. This will create a
|
||||
build compiled with AVX2, but without FMA or floating point contraction.")
|
||||
print("WARNING: Use_avx2 is true while use_fma is false. This will create a build compiled with AVX2, but without FMA or floating point contraction.")
|
||||
print("This should only be set intentionally for testing.")
|
||||
}
|
||||
|
||||
|
@ -111,10 +110,8 @@ if (use_avx2 && !use_fma) {
|
|||
# your args. However, there are a few CPUs out there for which this makes sense.
|
||||
# Alex313031 TODO: Maybe add -mfma3 -mfma4 for this config?
|
||||
if (!use_avx2 && use_fma) {
|
||||
print("WARNING: Use_avx2 is false while use_fma true. This will
|
||||
create an AVX build with FMA.")
|
||||
print("This should only be set intentionally for testing, or for specific CPUs
|
||||
that have AVX and FMA, but not AVX2, such as AMD Piledriver.")
|
||||
print("WARNING: Use_avx2 is false while use_fma true. This will create an AVX build with FMA.")
|
||||
print("This should only be set intentionally for testing, or for specific CPUs that have AVX and FMA, but not AVX2, such as AMD Piledriver.")
|
||||
}
|
||||
|
||||
if (use_fma) {
|
||||
|
|
|
@ -100,8 +100,9 @@ aggregate_vector_icons("chrome_vector_icons") {
|
|||
"input.icon",
|
||||
"install_desktop_chrome_refresh.icon",
|
||||
"journeys.icon",
|
||||
"keep_pin_chrome_refresh.icon",
|
||||
"keep_pin_filled_chrome_refresh.icon",
|
||||
"keep.icon",
|
||||
"keep_filled.icon",
|
||||
"keep_off.icon",
|
||||
"key.icon",
|
||||
"keyboard_arrow_down.icon",
|
||||
"keyboard_arrow_down_chrome_refresh.icon",
|
||||
|
@ -116,8 +117,6 @@ aggregate_vector_icons("chrome_vector_icons") {
|
|||
"media_controls_arrow_drop_up.icon",
|
||||
"media_toolbar_button_chrome_refresh.icon",
|
||||
"media_toolbar_button_touch.icon",
|
||||
"memory_saver.icon",
|
||||
"memory_saver_chrome_refresh.icon",
|
||||
"menu_book_chrome_refresh.icon",
|
||||
"mixed_content.icon",
|
||||
"more_tools_menu.icon",
|
||||
|
@ -145,6 +144,7 @@ aggregate_vector_icons("chrome_vector_icons") {
|
|||
"payments/save_card_and_vcn_success_confirmation.icon",
|
||||
"payments/save_card_and_vcn_success_confirmation_dark.icon",
|
||||
"performance.icon",
|
||||
"performance_speedometer.icon",
|
||||
"person.icon",
|
||||
"person_filled_padded_large.icon",
|
||||
"person_filled_padded_small.icon",
|
||||
|
@ -192,6 +192,7 @@ aggregate_vector_icons("chrome_vector_icons") {
|
|||
"tab_audio.icon",
|
||||
"tab_close_normal.icon",
|
||||
"tab_group.icon",
|
||||
"tab_group_sharing.icon",
|
||||
"tab_groups_sync.icon",
|
||||
"tab_usb_connected.icon",
|
||||
"tablet.icon",
|
||||
|
@ -223,7 +224,8 @@ aggregate_vector_icons("chrome_vector_icons") {
|
|||
"webauthn/usb_security_key.icon",
|
||||
"webauthn/webauthn_error.icon",
|
||||
"webauthn/webauthn_error_dark.icon",
|
||||
"webid_globe.icon",
|
||||
"webid/webid_arrow.icon",
|
||||
"webid/webid_globe.icon",
|
||||
"zoom_in.icon",
|
||||
"zoom_minus.icon",
|
||||
"zoom_minus_chrome_refresh.icon",
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
// Copyright 2024 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.
|
||||
|
||||
#include "chrome/browser/ui/views/frame/window_caption_util.h"
|
||||
|
||||
#include "build/build_config.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
#include "chrome/browser/ui/thorium_2024.h"
|
||||
|
||||
// static
|
||||
bool WindowCaptionUtil::IsWindowsTabSearchCaptionButtonEnabled(
|
||||
const Browser* browser) {
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
static const bool remove_tabsearch_button =
|
||||
base::CommandLine::ForCurrentProcess()->HasSwitch("remove-tabsearch-button");
|
||||
static const bool disable_caption_button =
|
||||
base::CommandLine::ForCurrentProcess()->HasSwitch("disable-caption-button");
|
||||
return features::IsThorium2024() && browser->is_type_normal() &&
|
||||
!remove_tabsearch_button && !disable_caption_button;
|
||||
#else
|
||||
return false;
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
// Copyright 2024 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.
|
||||
|
||||
#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_WINDOW_CAPTION_UTIL_H_
|
||||
#define CHROME_BROWSER_UI_VIEWS_FRAME_WINDOW_CAPTION_UTIL_H_
|
||||
|
||||
class Browser;
|
||||
|
||||
// Static-only class containing values and helper functions for frame classes
|
||||
// that need to be accessible outside of /browser/ui/views.
|
||||
class WindowCaptionUtil {
|
||||
public:
|
||||
// Returns true if the Windows caption button is enabled.
|
||||
static bool IsWindowsTabSearchCaptionButtonEnabled(const Browser* browser);
|
||||
|
||||
private:
|
||||
WindowCaptionUtil() {}
|
||||
};
|
||||
|
||||
#endif // CHROME_BROWSER_UI_VIEWS_FRAME_WINDOW_CAPTION_UTIL_H_
|
|
@ -1,54 +0,0 @@
|
|||
// Copyright 2024 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.
|
||||
|
||||
#include "chrome/browser/ui/views/toolbar/restore_tab_button.h"
|
||||
|
||||
#include "chrome/app/chrome_command_ids.h"
|
||||
#include "chrome/browser/command_updater.h"
|
||||
#include "chrome/browser/external_protocol/external_protocol_handler.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
#include "components/vector_icons/vector_icons.h"
|
||||
//#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/metadata/metadata_impl_macros.h"
|
||||
#include "ui/base/ui_base_features.h"
|
||||
#include "ui/views/accessibility/view_accessibility.h"
|
||||
#include "ui/views/controls/button/button_controller.h"
|
||||
|
||||
RestoreTabButton::RestoreTabButton(CommandUpdater* command_updater)
|
||||
: ToolbarButton(base::BindRepeating(&RestoreTabButton::ButtonPressed,
|
||||
base::Unretained(this))),
|
||||
command_updater_(command_updater) {
|
||||
|
||||
SetIcon();
|
||||
|
||||
constexpr char16_t RestoreTabAccessName[] = u"Restore Tab Button";
|
||||
GetViewAccessibility().SetName(RestoreTabAccessName);
|
||||
constexpr char16_t RestoreTabAccessToolTipName[] = u"Restore Tab";
|
||||
SetTooltipText(RestoreTabAccessToolTipName);
|
||||
button_controller()->set_notify_action(
|
||||
views::ButtonController::NotifyAction::kOnPress);
|
||||
}
|
||||
|
||||
RestoreTabButton::~RestoreTabButton() = default;
|
||||
|
||||
void RestoreTabButton::ButtonPressed() {
|
||||
ExternalProtocolHandler::PermitLaunchUrl();
|
||||
|
||||
int command = IDC_RESTORE_TAB;
|
||||
ExecuteBrowserCommand(command);
|
||||
}
|
||||
|
||||
void RestoreTabButton::SetIcon() {
|
||||
SetVectorIcon(vector_icons::kRestoreIcon);
|
||||
}
|
||||
|
||||
void RestoreTabButton::ExecuteBrowserCommand(int command) {
|
||||
if (!command_updater_) {
|
||||
return;
|
||||
}
|
||||
command_updater_->ExecuteCommand(command);
|
||||
}
|
||||
|
||||
BEGIN_METADATA(RestoreTabButton)
|
||||
END_METADATA
|
|
@ -1,31 +0,0 @@
|
|||
// Copyright 2024 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.
|
||||
|
||||
#ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_RESTORE_TAB_BUTTON_H_
|
||||
#define CHROME_BROWSER_UI_VIEWS_TOOLBAR_RESTORE_TAB_BUTTON_H_
|
||||
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "chrome/browser/ui/views/toolbar/toolbar_button.h"
|
||||
#include "ui/base/metadata/metadata_header_macros.h"
|
||||
|
||||
class CommandUpdater;
|
||||
|
||||
class RestoreTabButton : public ToolbarButton {
|
||||
METADATA_HEADER(RestoreTabButton, ToolbarButton)
|
||||
|
||||
public:
|
||||
explicit RestoreTabButton(CommandUpdater* command_updater);
|
||||
RestoreTabButton(const RestoreTabButton&) = delete;
|
||||
RestoreTabButton& operator=(const RestoreTabButton&) = delete;
|
||||
~RestoreTabButton() override;
|
||||
|
||||
private:
|
||||
void SetIcon();
|
||||
void ButtonPressed();
|
||||
void ExecuteBrowserCommand(int command);
|
||||
|
||||
raw_ptr<CommandUpdater, DanglingUntriaged> command_updater_;
|
||||
};
|
||||
|
||||
#endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_RESTORE_TAB_BUTTON_H_
|
|
@ -16,7 +16,7 @@ aggregate_vector_icons("components_vector_icons") {
|
|||
"account_circle.icon",
|
||||
"account_circle_chrome_refresh.icon",
|
||||
"account_circle_off_chrome_refresh.icon",
|
||||
"add_chrome_refresh.icon",
|
||||
"add.icon",
|
||||
"ads.icon",
|
||||
"ads_chrome_refresh.icon",
|
||||
"ads_click.icon",
|
||||
|
@ -46,9 +46,10 @@ aggregate_vector_icons("components_vector_icons") {
|
|||
"caret_down.icon",
|
||||
"caret_up.icon",
|
||||
"cast.icon",
|
||||
"cast_warning.icon",
|
||||
"celebration.icon",
|
||||
"certificate_chrome_refresh.icon",
|
||||
"certificate_off_chrome_refresh.icon",
|
||||
"certificate.icon",
|
||||
"certificate_off.icon",
|
||||
"check_circle.icon",
|
||||
"close.icon",
|
||||
"close_chrome_refresh.icon",
|
||||
|
@ -57,8 +58,8 @@ aggregate_vector_icons("components_vector_icons") {
|
|||
"code_chrome_refresh.icon",
|
||||
"code_off_chrome_refresh.icon",
|
||||
"content_copy.icon",
|
||||
"content_paste_chrome_refresh.icon",
|
||||
"content_paste_off_chrome_refresh.icon",
|
||||
"content_paste.icon",
|
||||
"content_paste_off.icon",
|
||||
"cookie.icon",
|
||||
"cookie_chrome_refresh.icon",
|
||||
"cookie_off_chrome_refresh.icon",
|
||||
|
@ -68,7 +69,7 @@ aggregate_vector_icons("components_vector_icons") {
|
|||
"database_off.icon",
|
||||
"description.icon",
|
||||
"devices.icon",
|
||||
"devices_off_chrome_refresh.icon",
|
||||
"devices_off.icon",
|
||||
"document_scanner.icon",
|
||||
"dogfood.icon",
|
||||
"edit.icon",
|
||||
|
@ -102,12 +103,14 @@ aggregate_vector_icons("components_vector_icons") {
|
|||
"globe.icon",
|
||||
"google_color.icon",
|
||||
"gpp_maybe.icon",
|
||||
"hand_gesture.icon",
|
||||
"hand_gesture_off.icon",
|
||||
"headset.icon",
|
||||
"help.icon",
|
||||
"help_outline.icon",
|
||||
"history.icon",
|
||||
"history_chrome_refresh.icon",
|
||||
"https_valid_chrome_refresh.icon",
|
||||
"https_valid.icon",
|
||||
"iframe.icon",
|
||||
"iframe_off.icon",
|
||||
"image_search.icon",
|
||||
|
@ -115,6 +118,8 @@ aggregate_vector_icons("components_vector_icons") {
|
|||
"info_refresh.icon",
|
||||
"info_regular.icon",
|
||||
"insert_drive_file_outline.icon",
|
||||
"install_desktop.icon",
|
||||
"install_desktop_off.icon",
|
||||
"keyboard.icon",
|
||||
"keyboard_lock.icon",
|
||||
"keyboard_lock_off.icon",
|
||||
|
@ -202,6 +207,8 @@ aggregate_vector_icons("components_vector_icons") {
|
|||
"shoppingmode.icon",
|
||||
"skip_next.icon",
|
||||
"skip_previous.icon",
|
||||
"smart_card_reader.icon",
|
||||
"smart_card_reader_off.icon",
|
||||
"sms.icon",
|
||||
"stop_circle.icon",
|
||||
"storage_access.icon",
|
||||
|
@ -219,7 +226,7 @@ aggregate_vector_icons("components_vector_icons") {
|
|||
"thumb_up_filled.icon",
|
||||
"touchpad_mouse.icon",
|
||||
"touchpad_mouse_off.icon",
|
||||
"translate_chrome_refresh.icon",
|
||||
"translate.icon",
|
||||
"undo.icon",
|
||||
"usb.icon",
|
||||
"usb_chrome_refresh.icon",
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
// 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/351564777): Remove this and convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "google_apis/google_api_keys.h"
|
||||
|
||||
// If you add more includes to this list, you also need to add them to
|
||||
|
@ -17,6 +22,7 @@
|
|||
#include "base/lazy_instance.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/stringize_macros.h"
|
||||
#include "base/version_info/channel.h"
|
||||
#include "build/branding_buildflags.h"
|
||||
#include "build/chromeos_buildflags.h"
|
||||
#include "google_apis/buildflags.h"
|
||||
|
@ -241,25 +247,25 @@ class APIKeyCache {
|
|||
command_line, gaia_config);
|
||||
}
|
||||
|
||||
std::string api_key() const { return api_key_; }
|
||||
const std::string& api_key() const { return api_key_; }
|
||||
#if BUILDFLAG(SUPPORT_EXTERNAL_GOOGLE_API_KEY)
|
||||
void set_api_key(const std::string& api_key) { api_key_ = api_key; }
|
||||
#endif
|
||||
std::string api_key_non_stable() const { return api_key_non_stable_; }
|
||||
std::string api_key_remoting() const { return api_key_remoting_; }
|
||||
std::string api_key_soda() const { return api_key_soda_; }
|
||||
const std::string& api_key_non_stable() const { return api_key_non_stable_; }
|
||||
const std::string& api_key_remoting() const { return api_key_remoting_; }
|
||||
const std::string& api_key_soda() const { return api_key_soda_; }
|
||||
#if !BUILDFLAG(IS_ANDROID)
|
||||
std::string api_key_hats() const { return api_key_hats_; }
|
||||
const std::string& api_key_hats() const { return api_key_hats_; }
|
||||
#endif
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
std::string api_key_sharing() const { return api_key_sharing_; }
|
||||
std::string api_key_read_aloud() const { return api_key_read_aloud_; }
|
||||
std::string api_key_fresnel() const { return api_key_fresnel_; }
|
||||
const std::string& api_key_sharing() const { return api_key_sharing_; }
|
||||
const std::string& api_key_read_aloud() const { return api_key_read_aloud_; }
|
||||
const std::string& api_key_fresnel() const { return api_key_fresnel_; }
|
||||
#endif
|
||||
|
||||
std::string metrics_key() const { return metrics_key_; }
|
||||
const std::string& metrics_key() const { return metrics_key_; }
|
||||
|
||||
std::string GetClientID(OAuth2Client client) const {
|
||||
const std::string& GetClientID(OAuth2Client client) const {
|
||||
DCHECK_LT(client, CLIENT_NUM_ITEMS);
|
||||
return client_ids_[client];
|
||||
}
|
||||
|
@ -270,7 +276,7 @@ class APIKeyCache {
|
|||
}
|
||||
#endif
|
||||
|
||||
std::string GetClientSecret(OAuth2Client client) const {
|
||||
const std::string& GetClientSecret(OAuth2Client client) const {
|
||||
DCHECK_LT(client, CLIENT_NUM_ITEMS);
|
||||
return client_secrets_[client];
|
||||
}
|
||||
|
@ -377,6 +383,7 @@ class APIKeyCache {
|
|||
std::string api_key_read_aloud_;
|
||||
std::string api_key_fresnel_;
|
||||
#endif
|
||||
|
||||
std::string metrics_key_;
|
||||
std::string client_ids_[CLIENT_NUM_ITEMS];
|
||||
std::string client_secrets_[CLIENT_NUM_ITEMS];
|
||||
|
@ -389,49 +396,55 @@ bool HasAPIKeyConfigured() {
|
|||
return GetAPIKey() != DUMMY_API_TOKEN;
|
||||
}
|
||||
|
||||
std::string GetAPIKey() {
|
||||
const std::string& GetAPIKey(::version_info::Channel channel) {
|
||||
return channel == ::version_info::Channel::STABLE
|
||||
? GetAPIKey()
|
||||
: g_api_key_cache.Get().api_key_non_stable();
|
||||
}
|
||||
|
||||
const std::string& GetAPIKey() {
|
||||
return g_api_key_cache.Get().api_key();
|
||||
}
|
||||
|
||||
std::string GetNonStableAPIKey() {
|
||||
return g_api_key_cache.Get().api_key_non_stable();
|
||||
}
|
||||
|
||||
std::string GetRemotingAPIKey() {
|
||||
const std::string& GetRemotingAPIKey() {
|
||||
return g_api_key_cache.Get().api_key_remoting();
|
||||
}
|
||||
|
||||
std::string GetSodaAPIKey() {
|
||||
const std::string& GetSodaAPIKey() {
|
||||
return g_api_key_cache.Get().api_key_soda();
|
||||
}
|
||||
|
||||
#if !BUILDFLAG(IS_ANDROID)
|
||||
std::string GetHatsAPIKey() {
|
||||
const std::string& GetHatsAPIKey() {
|
||||
return g_api_key_cache.Get().api_key_hats();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
std::string GetSharingAPIKey() {
|
||||
const std::string& GetSharingAPIKey() {
|
||||
return g_api_key_cache.Get().api_key_sharing();
|
||||
}
|
||||
|
||||
std::string GetReadAloudAPIKey() {
|
||||
const std::string& GetReadAloudAPIKey() {
|
||||
return g_api_key_cache.Get().api_key_read_aloud();
|
||||
}
|
||||
|
||||
std::string GetFresnelAPIKey() {
|
||||
const std::string& GetFresnelAPIKey() {
|
||||
return g_api_key_cache.Get().api_key_fresnel();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(SUPPORT_EXTERNAL_GOOGLE_API_KEY)
|
||||
void SetAPIKey(const std::string& api_key) {
|
||||
// Overriding the API key must be made before its first usage. This check is
|
||||
// more permissive as it allows multiple calls to set the API with the same
|
||||
// value.
|
||||
CHECK(!g_api_key_cache.IsCreated(), base::NotFatalUntil::M133);
|
||||
g_api_key_cache.Get().set_api_key(api_key);
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string GetMetricsKey() {
|
||||
const std::string& GetMetricsKey() {
|
||||
return g_api_key_cache.Get().metrics_key();
|
||||
}
|
||||
|
||||
|
@ -447,11 +460,11 @@ bool HasOAuthClientConfigured() {
|
|||
return true;
|
||||
}
|
||||
|
||||
std::string GetOAuth2ClientID(OAuth2Client client) {
|
||||
const std::string& GetOAuth2ClientID(OAuth2Client client) {
|
||||
return g_api_key_cache.Get().GetClientID(client);
|
||||
}
|
||||
|
||||
std::string GetOAuth2ClientSecret(OAuth2Client client) {
|
||||
const std::string& GetOAuth2ClientSecret(OAuth2Client client) {
|
||||
return g_api_key_cache.Get().GetClientSecret(client);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue