Commit 38fa94b4 authored by Jesse McKenna's avatar Jesse McKenna Committed by Commit Bot

desktop-pwas: Remove GetCurrentPath from launcher

This change removes the unneeded function GetCurrentExecutablePath
from the PWA launcher executable.

Previously, this function got the current executable's path and then
called base::NormalizeFilePath to preserve its capitalization.
Preserving the file path's capitalization was left over from when the
PWA launcher updated itself in-place, and therefore needed its
filename exactly as displayed in order to create an updated file with
that filename.

With the removal of this unneeded call to base::NormalizeFilePath, the
whole function is trivial and can be extracted into the rest of the
code.

This change also fixes LaunchResult::kMaxValue, which was incorrectly
set to an enum value that was not the highest.

Bug: 960245
Change-Id: If7d737d14f6cc56e0aab10a83fde8cd379e05ce0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2149945
Commit-Queue: Jesse McKenna <jessemckenna@google.com>
Reviewed-by: default avatarDavid Bienvenu <davidbienvenu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759082}
parent 1dfb62a6
...@@ -25,23 +25,16 @@ enum LaunchResult { ...@@ -25,23 +25,16 @@ enum LaunchResult {
kSuccess = 0, kSuccess = 0,
kStarted = 1, kStarted = 1,
kError = 2, kError = 2,
kMaxValue = kStarted kMaxValue = kError
}; };
// Returns the current executable's path, with capitalization preserved. If
// getting the current path fails, the launcher crashes.
base::FilePath GetCurrentExecutablePath() {
base::FilePath current_path;
CHECK(base::PathService::Get(base::FILE_EXE, &current_path));
base::NormalizeFilePath(current_path, &current_path);
return current_path;
}
// Returns the path to chrome.exe stored in the "Last Browser" file. If the file // Returns the path to chrome.exe stored in the "Last Browser" file. If the file
// is not found, can't be read, or does not contain a valid path, the launcher // is not found, can't be read, or does not contain a valid path, the launcher
// crashes. // crashes.
base::FilePath GetChromePathFromLastBrowserFile( base::FilePath GetChromePathFromLastBrowserFile() {
const base::FilePath& current_path) { base::FilePath current_path;
CHECK(base::PathService::Get(base::FILE_EXE, &current_path));
// The Last Browser file is expected to be in the User Data directory, which // The Last Browser file is expected to be in the User Data directory, which
// is the great-grandparent of the current directory (User Data\<profile>\Web // is the great-grandparent of the current directory (User Data\<profile>\Web
// Applications\<app ID>). // Applications\<app ID>).
...@@ -99,8 +92,7 @@ int WINAPI wWinMain(HINSTANCE instance, ...@@ -99,8 +92,7 @@ int WINAPI wWinMain(HINSTANCE instance,
logging_settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; logging_settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
logging::InitLogging(logging_settings); logging::InitLogging(logging_settings);
base::FilePath current_path = GetCurrentExecutablePath(); const base::FilePath chrome_path = GetChromePathFromLastBrowserFile();
base::FilePath chrome_path = GetChromePathFromLastBrowserFile(current_path);
install_static::InstallDetails::SetForProcess( install_static::InstallDetails::SetForProcess(
install_static::MakeProductDetails(chrome_path.value())); install_static::MakeProductDetails(chrome_path.value()));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment