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

Unified Diff: cloud_print/virtual_driver/linux/printer_driver_util_linux.cc

Issue 7222011: Linux Virtual Printer Driver (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Virtual Print Driver Created 9 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
Index: cloud_print/virtual_driver/linux/printer_driver_util_linux.cc
diff --git a/cloud_print/virtual_driver/linux/printer_driver_util_linux.cc b/cloud_print/virtual_driver/linux/printer_driver_util_linux.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7518679ac91f9d40ba872b98dbe1a6da3ce72980
--- /dev/null
+++ b/cloud_print/virtual_driver/linux/printer_driver_util_linux.cc
@@ -0,0 +1,81 @@
+#include <errno.h>
Albert Bodenhamer 2011/07/08 20:40:13 You need to start the file with a correct header.
+#include <fstream>
+#include <iostream>
+#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
Albert Bodenhamer 2011/07/08 20:40:13 This looks like a lot of headers. Are they all re
+
+#include <cups/backend.h>
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include "base/base_paths.h"
+#include "base/command_line.h"
+#include "base/file_path.h"
+#include "base/logging.h"
+#include "base/path_service.h"
+
+#include "cloud_print/virtual_driver/linux/printer_driver_util_posix.h"
+
+
+namespace switches {
Albert Bodenhamer 2011/07/08 20:40:13 Extract these to a common location in the print dr
+// These constants are duplicated from chrome/common/chrome_switches.cc
+// in order to avoid dependency problems.
+
+// Used with kCloudPrintFile. Tells Chrome to delete the file when
+// finished displaying the print dialog.
+const char kCloudPrintDeleteFile[] = "cloud-print-delete-file";
+
+// Tells chrome to display the cloud print dialog and upload the
+// specified file for printing.
+const char kCloudPrintFile[] = "cloud-print-file";
+
+// Used with kCloudPrintFile to specify a title for the resulting print
+// job.
+const char kCloudPrintJobTitle[] = "cloud-print-job-title";
+
+// Specifies the mime type to be used when uploading data from the
+// file referenced by cloud-print-file.
+// Defaults to "application/pdf" if unspecified.
+const char kCloudPrintFileType[] = "cloud-print-file-type";
+
+}
+
+using namespace std;
Albert Bodenhamer 2011/07/08 20:40:13 It looks like you're referring to std::string belo
+
+void launchChrome(std::string output_path, std::string job_title,
Albert Bodenhamer 2011/07/08 20:40:13 Should be LaunchChrome or, even better, LaunchPrin
+ std::string current_user){
+ std::string set_var;
+
+ // Set Environment variable to control display.
+ set_var="/home/" + current_user + "/.Xauthority";
+ if(setenv("DISPLAY",":0.0",0) == -1) {
+ LOG(ERROR) << "Unable to set DISPLAY environment variable";
+ }
+ if(setenv("XAUTHORITY",set_var.c_str(),0) == -1) {
+ LOG(ERROR) << "Unable to set XAUTHORITY environment variable";
+ }
+
+ // Construct the call to Chrome
+
+ //FilePath chrome_path("/home/abeera/src/out/Release/chrome");
+ FilePath chrome_path("google-chrome");
+ FilePath job_path(output_path);
+ CommandLine command_line(chrome_path);
+ command_line.AppendSwitchPath(switches::kCloudPrintFile,job_path);
+ command_line.AppendSwitchNative(switches::kCloudPrintJobTitle, job_title);
+ command_line.AppendSwitch(switches::kCloudPrintDeleteFile);
+ LOG(INFO) << "Call to chrome is " << command_line.command_line_string();
+
+ if(system(command_line.command_line_string().c_str())== -1 ){
+ LOG(ERROR) << "Unable to call Chrome";
+ }
+
+ else {
+ LOG(INFO) << "Call to Chrome succeeded";
+ }
+}
+

Powered by Google App Engine
This is Rietveld 408576698