refactor: use auto env = base::Environment::Create(); everywhere (#29502)

This commit is contained in:
Milan Burda 2021-06-04 02:23:06 +02:00 committed by GitHub
parent 5929d6335f
commit 00693bab30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 14 additions and 14 deletions

View file

@ -52,7 +52,7 @@ void ElectronCrashReporterClient::Create() {
// By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate
// location to write crash dumps can be set. // location to write crash dumps can be set.
std::unique_ptr<base::Environment> env(base::Environment::Create()); auto env = base::Environment::Create();
std::string alternate_crash_dump_location; std::string alternate_crash_dump_location;
base::FilePath crash_dumps_dir_path; base::FilePath crash_dumps_dir_path;
if (env->GetVar("BREAKPAD_DUMP_LOCATION", &alternate_crash_dump_location)) { if (env->GetVar("BREAKPAD_DUMP_LOCATION", &alternate_crash_dump_location)) {

View file

@ -1012,7 +1012,7 @@ void App::SetPath(gin_helper::ErrorThrower thrower,
void App::SetDesktopName(const std::string& desktop_name) { void App::SetDesktopName(const std::string& desktop_name) {
#if defined(OS_LINUX) #if defined(OS_LINUX)
std::unique_ptr<base::Environment> env(base::Environment::Create()); auto env = base::Environment::Create();
env->SetVar("CHROME_DESKTOP", desktop_name); env->SetVar("CHROME_DESKTOP", desktop_name);
#endif #endif
} }

View file

@ -66,7 +66,7 @@ absl::optional<std::string> GetXdgAppOutput(
} }
bool SetDefaultWebClient(const std::string& protocol) { bool SetDefaultWebClient(const std::string& protocol) {
std::unique_ptr<base::Environment> env(base::Environment::Create()); auto env = base::Environment::Create();
std::vector<std::string> argv = {kXdgSettings, "set"}; std::vector<std::string> argv = {kXdgSettings, "set"};
if (!protocol.empty()) { if (!protocol.empty()) {
@ -95,7 +95,7 @@ bool Browser::SetAsDefaultProtocolClient(const std::string& protocol,
bool Browser::IsDefaultProtocolClient(const std::string& protocol, bool Browser::IsDefaultProtocolClient(const std::string& protocol,
gin::Arguments* args) { gin::Arguments* args) {
std::unique_ptr<base::Environment> env(base::Environment::Create()); auto env = base::Environment::Create();
if (protocol.empty()) if (protocol.empty())
return false; return false;

View file

@ -572,7 +572,7 @@ void ElectronBrowserClient::AppendExtraCommandLineSwitches(
command_line->AppendSwitchPath(switches::kAppPath, app_path); command_line->AppendSwitchPath(switches::kAppPath, app_path);
} }
std::unique_ptr<base::Environment> env(base::Environment::Create()); auto env = base::Environment::Create();
if (env->HasVar("ELECTRON_PROFILE_INIT_SCRIPTS")) { if (env->HasVar("ELECTRON_PROFILE_INIT_SCRIPTS")) {
command_line->AppendSwitch("profile-electron-init"); command_line->AppendSwitch("profile-electron-init");
} }
@ -603,7 +603,7 @@ void ElectronBrowserClient::DidCreatePpapiPlugin(
// attempt to get api key from env // attempt to get api key from env
std::string ElectronBrowserClient::GetGeolocationApiKey() { std::string ElectronBrowserClient::GetGeolocationApiKey() {
std::unique_ptr<base::Environment> env(base::Environment::Create()); auto env = base::Environment::Create();
std::string api_key; std::string api_key;
env->GetVar("GOOGLE_API_KEY", &api_key); env->GetVar("GOOGLE_API_KEY", &api_key);
return api_key; return api_key;

View file

@ -160,7 +160,7 @@ void OverrideLinuxAppDataPath() {
base::FilePath path; base::FilePath path;
if (base::PathService::Get(DIR_APP_DATA, &path)) if (base::PathService::Get(DIR_APP_DATA, &path))
return; return;
std::unique_ptr<base::Environment> env(base::Environment::Create()); auto env = base::Environment::Create();
path = base::nix::GetXDGDirectory(env.get(), base::nix::kXdgConfigHomeEnvVar, path = base::nix::GetXDGDirectory(env.get(), base::nix::kXdgConfigHomeEnvVar,
base::nix::kDotConfigDir); base::nix::kDotConfigDir);
base::PathService::Override(DIR_APP_DATA, path); base::PathService::Override(DIR_APP_DATA, path);
@ -313,7 +313,7 @@ int ElectronBrowserMainParts::PreCreateThreads() {
// which keys off of getenv("LC_ALL"). // which keys off of getenv("LC_ALL").
// We must set this env first to make ui::ResourceBundle accept the custom // We must set this env first to make ui::ResourceBundle accept the custom
// locale. // locale.
std::unique_ptr<base::Environment> env(base::Environment::Create()); auto env = base::Environment::Create();
absl::optional<std::string> lc_all; absl::optional<std::string> lc_all;
if (!locale.empty()) { if (!locale.empty()) {
std::string str; std::string str;

View file

@ -58,7 +58,7 @@ void EnsureLibUnityLoaded() {
return; return;
attempted_load = true; attempted_load = true;
std::unique_ptr<base::Environment> env(base::Environment::Create()); auto env = base::Environment::Create();
base::nix::DesktopEnvironment desktop_env = GetDesktopEnvironment(env.get()); base::nix::DesktopEnvironment desktop_env = GetDesktopEnvironment(env.get());
// The "icon-tasks" KDE task manager also honors Unity Launcher API. // The "icon-tasks" KDE task manager also honors Unity Launcher API.

View file

@ -160,7 +160,7 @@ AppIndicatorIcon::AppIndicatorIcon(std::string id,
const gfx::ImageSkia& image, const gfx::ImageSkia& image,
const std::u16string& tool_tip) const std::u16string& tool_tip)
: id_(id) { : id_(id) {
std::unique_ptr<base::Environment> env(base::Environment::Create()); auto env = base::Environment::Create();
desktop_env_ = base::nix::GetDesktopEnvironment(env.get()); desktop_env_ = base::nix::GetDesktopEnvironment(env.get());
EnsureLibAppIndicatorLoaded(); EnsureLibAppIndicatorLoaded();

View file

@ -19,7 +19,7 @@ namespace {
#if defined(OS_LINUX) #if defined(OS_LINUX)
bool IsDesktopEnvironmentUnity() { bool IsDesktopEnvironmentUnity() {
std::unique_ptr<base::Environment> env(base::Environment::Create()); auto env = base::Environment::Create();
base::nix::DesktopEnvironment desktop_env = base::nix::DesktopEnvironment desktop_env =
base::nix::GetDesktopEnvironment(env.get()); base::nix::GetDesktopEnvironment(env.get());
return desktop_env == base::nix::DESKTOP_ENVIRONMENT_UNITY; return desktop_env == base::nix::DESKTOP_ENVIRONMENT_UNITY;

View file

@ -35,7 +35,7 @@ void SetWindowType(x11::Window window, const std::string& type) {
bool ShouldUseGlobalMenuBar() { bool ShouldUseGlobalMenuBar() {
base::ThreadRestrictions::ScopedAllowIO allow_io; base::ThreadRestrictions::ScopedAllowIO allow_io;
std::unique_ptr<base::Environment> env(base::Environment::Create()); auto env = base::Environment::Create();
if (env->HasVar("ELECTRON_FORCE_WINDOW_MENU_BAR")) if (env->HasVar("ELECTRON_FORCE_WINDOW_MENU_BAR"))
return false; return false;

View file

@ -353,7 +353,7 @@ void NodeBindings::Initialize() {
// Parse and set Node.js cli flags. // Parse and set Node.js cli flags.
SetNodeCliFlags(); SetNodeCliFlags();
std::unique_ptr<base::Environment> env(base::Environment::Create()); auto env = base::Environment::Create();
SetNodeOptions(env.get()); SetNodeOptions(env.get());
std::vector<std::string> argv = {"electron"}; std::vector<std::string> argv = {"electron"};

View file

@ -190,7 +190,7 @@ void OpenExternal(const GURL& url,
} }
bool MoveItemToTrash(const base::FilePath& full_path, bool delete_on_fail) { bool MoveItemToTrash(const base::FilePath& full_path, bool delete_on_fail) {
std::unique_ptr<base::Environment> env(base::Environment::Create()); auto env = base::Environment::Create();
// find the trash method // find the trash method
std::string trash; std::string trash;