| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <cups/backend.h> | |
| 6 | |
| 7 #include "base/base_paths.h" | |
| 8 #include "base/command_line.h" | |
| 9 #include "base/file_path.h" | |
| 10 #include "base/logging.h" | |
| 11 #include "base/path_service.h" | |
| 12 | |
| 13 #include "cloud_print/virtual_driver/posix/printer_driver_util_posix.h" | |
| 14 #include "cloud_print/virtual_driver/virtual_driver_switches.h" | |
| 15 | |
| 16 void LaunchPrintDialog(std::string output_path, std::string job_title, | |
| 17 std::string current_user) { | |
| 18 std::string set_var; | |
| 19 | |
| 20 // Set Environment variable to control display. | |
| 21 set_var="/home/" + current_user + "/.Xauthority"; | |
| 22 if(setenv("DISPLAY",":0.0",0) == -1) { | |
| 23 LOG(ERROR) << "Unable to set DISPLAY environment variable"; | |
| 24 } | |
| 25 if(setenv("XAUTHORITY",set_var.c_str(),0) == -1) { | |
| 26 LOG(ERROR) << "Unable to set XAUTHORITY environment variable"; | |
| 27 } | |
| 28 | |
| 29 // Construct the call to Chrome | |
| 30 | |
| 31 FilePath chrome_path("google-chrome"); | |
| 32 FilePath job_path(output_path); | |
| 33 CommandLine command_line(chrome_path); | |
| 34 command_line.AppendSwitchPath(switches::kCloudPrintFile,job_path); | |
| 35 command_line.AppendSwitchNative(switches::kCloudPrintJobTitle, job_title); | |
| 36 command_line.AppendSwitch(switches::kCloudPrintDeleteFile); | |
| 37 LOG(INFO) << "Call to chrome is " << command_line.command_line_string(); | |
| 38 | |
| 39 if(system(command_line.command_line_string().c_str())== -1 ) { | |
| 40 LOG(ERROR) << "Unable to call Chrome"; | |
| 41 exit(CUPS_BACKEND_CANCEL); | |
| 42 } | |
| 43 | |
| 44 else { | |
| 45 LOG(INFO) << "Call to Chrome succeeded"; | |
| 46 } | |
| 47 } | |
| 48 | |
| OLD | NEW |