summaryrefslogtreecommitdiffstats
path: root/chrome/utility
diff options
context:
space:
mode:
authorsanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-22 00:01:55 +0000
committersanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-22 00:01:55 +0000
commit574c7bb72cdc18bc52b69a10aad1287c85a57c70 (patch)
treeb52524b1ad81c3311603d421af4b3587a22320c8 /chrome/utility
parent3ab6796d3645a13a56a2fc311fc36c66d31089d6 (diff)
downloadchromium_src-574c7bb72cdc18bc52b69a10aad1287c85a57c70.zip
chromium_src-574c7bb72cdc18bc52b69a10aad1287c85a57c70.tar.gz
chromium_src-574c7bb72cdc18bc52b69a10aad1287c85a57c70.tar.bz2
As the first step in an effort to improve robustness of the cloud print proxy, we fetch printer capabilities and defaults in a child process so that printer driver crashes do not crash the entire proxy.
BUG=None TEST=Registration of printers, printer update in Cloud Print Proxy. Review URL: http://codereview.chromium.org/5947002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69899 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/utility')
-rw-r--r--chrome/utility/utility_main.cc14
-rw-r--r--chrome/utility/utility_thread.cc17
-rw-r--r--chrome/utility/utility_thread.h6
3 files changed, 31 insertions, 6 deletions
diff --git a/chrome/utility/utility_main.cc b/chrome/utility/utility_main.cc
index 09d0156..0fa6777 100644
--- a/chrome/utility/utility_main.cc
+++ b/chrome/utility/utility_main.cc
@@ -45,12 +45,14 @@ int UtilityMain(const MainFunctionParams& parameters) {
DCHECK(rv) << "Couldn't load PDF plugin";
}
- sandbox::TargetServices* target_services =
- parameters.sandbox_info_.TargetServices();
- if (!target_services)
- return false;
-
- target_services->LowerToken();
+ bool no_sandbox = parameters.command_line_.HasSwitch(switches::kNoSandbox);
+ if (!no_sandbox) {
+ sandbox::TargetServices* target_services =
+ parameters.sandbox_info_.TargetServices();
+ if (!target_services)
+ return false;
+ target_services->LowerToken();
+ }
#endif
CommandLine* command_line = CommandLine::ForCurrentProcess();
diff --git a/chrome/utility/utility_thread.cc b/chrome/utility/utility_thread.cc
index 81e7ff4..baf831f 100644
--- a/chrome/utility/utility_thread.cc
+++ b/chrome/utility/utility_thread.cc
@@ -63,6 +63,8 @@ void UtilityThread::OnControlMessageReceived(const IPC::Message& msg) {
OnIDBKeysFromValuesAndKeyPath)
IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Started, OnBatchModeStarted)
IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Finished, OnBatchModeFinished)
+ IPC_MESSAGE_HANDLER(UtilityMsg_GetPrinterCapsAndDefaults,
+ OnGetPrinterCapsAndDefaults)
IPC_END_MESSAGE_MAP()
}
@@ -306,7 +308,22 @@ void UtilityThread::OnBatchModeFinished() {
ChildProcess::current()->ReleaseProcess();
}
+void UtilityThread::OnGetPrinterCapsAndDefaults(
+ const std::string& printer_name) {
+ scoped_refptr<printing::PrintBackend> print_backend =
+ printing::PrintBackend::CreateInstance(NULL);
+ printing::PrinterCapsAndDefaults printer_info;
+ if (print_backend->GetPrinterCapsAndDefaults(printer_name, &printer_info)) {
+ Send(new UtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded(printer_name,
+ printer_info));
+ } else {
+ Send(new UtilityHostMsg_GetPrinterCapsAndDefaults_Failed(printer_name));
+ }
+ ReleaseProcessIfNeeded();
+}
+
void UtilityThread::ReleaseProcessIfNeeded() {
if (!batch_mode_)
ChildProcess::current()->ReleaseProcess();
}
+
diff --git a/chrome/utility/utility_thread.h b/chrome/utility/utility_thread.h
index 36419aa..187f914 100644
--- a/chrome/utility/utility_thread.h
+++ b/chrome/utility/utility_thread.h
@@ -84,6 +84,12 @@ class UtilityThread : public ChildThread {
// IPC to notify batch mode has finished and we should now quit.
void OnBatchModeFinished();
+ // IPC to get capabilities and defaults for the specified
+ // printer. Used on Windows to isolate the service process from printer driver
+ // crashes by executing this in a separate process. This does not run in a
+ // sandbox.
+ void OnGetPrinterCapsAndDefaults(const std::string& printer_name);
+
// Releases the process if we are not (or no longer) in batch mode.
void ReleaseProcessIfNeeded();