Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: chrome/browser/printing/printer_manager_dialog_linux.cc

Issue 2086103002: Add base::ExecutableExistsInPath (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't leak base::Environment Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/files/file_util_unittest.cc ('k') | chrome/browser/ui/webui/settings_utils_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/printing/printer_manager_dialog_linux.cc
diff --git a/chrome/browser/printing/printer_manager_dialog_linux.cc b/chrome/browser/printing/printer_manager_dialog_linux.cc
index 48b891dd811462a6001eee262284760ee0715d7d..29ee3f353556071f7f187bce2512e6a711ecda73 100644
--- a/chrome/browser/printing/printer_manager_dialog_linux.cc
+++ b/chrome/browser/printing/printer_manager_dialog_linux.cc
@@ -30,28 +30,11 @@ const char* const kSystemConfigPrinterCommand[] = {"system-config-printer",
const char* const kGnomeControlCenterPrintersCommand[] = {
"gnome-control-center", "printers", nullptr};
-bool CommandExists(const char* command) {
- std::unique_ptr<base::Environment> env(base::Environment::Create());
- std::string path;
- if (!env->GetVar("PATH", &path)) {
- LOG(ERROR) << "No $PATH variable. Assuming no " << command << ".";
- return false;
- }
-
- for (const base::StringPiece& cur_path :
- base::SplitStringPiece(path, ":", base::KEEP_WHITESPACE,
- base::SPLIT_WANT_NONEMPTY)) {
- base::FilePath file(cur_path);
- if (base::PathExists(file.Append(command)))
- return true;
- }
- return false;
-}
-
// Returns true if the dialog was opened successfully.
bool OpenPrinterConfigDialog(const char* const* command) {
DCHECK(command);
- if (!CommandExists(*command))
+ std::unique_ptr<base::Environment> env(base::Environment::Create());
+ if (!base::ExecutableExistsInPath(env.get(), *command))
return false;
std::vector<std::string> argv;
while (*command)
« no previous file with comments | « base/files/file_util_unittest.cc ('k') | chrome/browser/ui/webui/settings_utils_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698