This source file includes following definitions.
- DetectAndOpenPrinterConfigDialog
- ShowPrinterManagerDialog
#include "chrome/browser/printing/printer_manager_dialog.h"
#include "base/bind.h"
#include "base/environment.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/nix/xdg_util.h"
#include "base/process/kill.h"
#include "base/process/launch.h"
#include "content/public/browser/browser_thread.h"
using base::Environment;
using content::BrowserThread;
namespace {
const char kGNOMEPrinterConfigCommand[] = "system-config-printer";
void DetectAndOpenPrinterConfigDialog() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
scoped_ptr<Environment> env(Environment::Create());
const char* command = NULL;
switch (base::nix::GetDesktopEnvironment(env.get())) {
case base::nix::DESKTOP_ENVIRONMENT_GNOME:
case base::nix::DESKTOP_ENVIRONMENT_KDE3:
case base::nix::DESKTOP_ENVIRONMENT_KDE4:
case base::nix::DESKTOP_ENVIRONMENT_UNITY:
command = kGNOMEPrinterConfigCommand;
break;
case base::nix::DESKTOP_ENVIRONMENT_XFCE:
case base::nix::DESKTOP_ENVIRONMENT_OTHER:
break;
}
if (!command) {
LOG(ERROR) << "Failed to detect the command to open printer config dialog";
return;
}
std::vector<std::string> argv;
argv.push_back(command);
base::ProcessHandle handle;
if (!base::LaunchProcess(argv, base::LaunchOptions(), &handle)) {
LOG(ERROR) << "Failed to open printer manager dialog ";
return;
}
base::EnsureProcessGetsReaped(handle);
}
}
namespace printing {
void PrinterManagerDialog::ShowPrinterManagerDialog() {
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
base::Bind(&DetectAndOpenPrinterConfigDialog));
}
}