OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/printing/printer_manager_dialog.h" | 5 #include "chrome/browser/printing/printer_manager_dialog.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/environment.h" | 8 #include "base/environment.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/nix/xdg_util.h" | 11 #include "base/nix/xdg_util.h" |
(...skipping 14 matching lines...) Expand all Loading... |
26 // manager dialog. | 26 // manager dialog. |
27 void DetectAndOpenPrinterConfigDialog() { | 27 void DetectAndOpenPrinterConfigDialog() { |
28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
29 scoped_ptr<Environment> env(Environment::Create()); | 29 scoped_ptr<Environment> env(Environment::Create()); |
30 | 30 |
31 const char* command = NULL; | 31 const char* command = NULL; |
32 switch (base::nix::GetDesktopEnvironment(env.get())) { | 32 switch (base::nix::GetDesktopEnvironment(env.get())) { |
33 case base::nix::DESKTOP_ENVIRONMENT_GNOME: | 33 case base::nix::DESKTOP_ENVIRONMENT_GNOME: |
34 case base::nix::DESKTOP_ENVIRONMENT_KDE3: | 34 case base::nix::DESKTOP_ENVIRONMENT_KDE3: |
35 case base::nix::DESKTOP_ENVIRONMENT_KDE4: | 35 case base::nix::DESKTOP_ENVIRONMENT_KDE4: |
| 36 case base::nix::DESKTOP_ENVIRONMENT_UNITY: |
36 command = kGNOMEPrinterConfigCommand; | 37 command = kGNOMEPrinterConfigCommand; |
37 break; | 38 break; |
38 case base::nix::DESKTOP_ENVIRONMENT_XFCE: | 39 case base::nix::DESKTOP_ENVIRONMENT_XFCE: |
39 case base::nix::DESKTOP_ENVIRONMENT_OTHER: | 40 case base::nix::DESKTOP_ENVIRONMENT_OTHER: |
40 break; | 41 break; |
41 default: | |
42 NOTREACHED(); | |
43 break; | |
44 } | 42 } |
45 | 43 |
46 if (!command) { | 44 if (!command) { |
47 LOG(ERROR) << "Failed to detect the command to open printer config dialog"; | 45 LOG(ERROR) << "Failed to detect the command to open printer config dialog"; |
48 return; | 46 return; |
49 } | 47 } |
50 | 48 |
51 std::vector<std::string> argv; | 49 std::vector<std::string> argv; |
52 argv.push_back(command); | 50 argv.push_back(command); |
53 base::ProcessHandle handle; | 51 base::ProcessHandle handle; |
54 if (!base::LaunchProcess(argv, base::LaunchOptions(), &handle)) { | 52 if (!base::LaunchProcess(argv, base::LaunchOptions(), &handle)) { |
55 LOG(ERROR) << "Failed to open printer manager dialog "; | 53 LOG(ERROR) << "Failed to open printer manager dialog "; |
56 return; | 54 return; |
57 } | 55 } |
58 base::EnsureProcessGetsReaped(handle); | 56 base::EnsureProcessGetsReaped(handle); |
59 } | 57 } |
60 | 58 |
61 } // anonymous namespace | 59 } // anonymous namespace |
62 | 60 |
63 namespace printing { | 61 namespace printing { |
64 | 62 |
65 void PrinterManagerDialog::ShowPrinterManagerDialog() { | 63 void PrinterManagerDialog::ShowPrinterManagerDialog() { |
66 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 64 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
67 base::Bind(&DetectAndOpenPrinterConfigDialog)); | 65 base::Bind(&DetectAndOpenPrinterConfigDialog)); |
68 } | 66 } |
69 | 67 |
70 } // namespace printing | 68 } // namespace printing |
OLD | NEW |