Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 <windows.h> | 7 #include <windows.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 | 9 |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 | 14 |
| 15 namespace printing { | 15 namespace printing { |
| 16 | 16 |
| 17 // A helper method that opens the printer management dialog. | 17 // A helper callback that opens the printer management dialog. |
| 18 class OpenPrintersDialogTask : public Task { | 18 void OpenPrintersDialogCallback() { |
| 19 public: | 19 FilePath sys_dir; |
| 20 OpenPrintersDialogTask() {} | 20 PathService::Get(base::DIR_SYSTEM, &sys_dir); |
| 21 FilePath rundll32 = sys_dir.AppendASCII("rundll32.exe"); | |
| 22 FilePath shell32dll = sys_dir.AppendASCII("shell32.dll"); | |
| 21 | 23 |
| 22 virtual void Run() { | 24 std::wstring args(shell32dll.value()); |
| 23 FilePath sys_dir; | 25 args.append(L",SHHelpShortcuts_RunDLL PrintersFolder"); |
| 24 PathService::Get(base::DIR_SYSTEM, &sys_dir); | 26 ShellExecute(NULL, L"open", rundll32.value().c_str(), args.c_str(), NULL, |
| 25 FilePath rundll32 = sys_dir.AppendASCII("rundll32.exe"); | 27 SW_SHOWNORMAL); |
| 26 FilePath shell32dll = sys_dir.AppendASCII("shell32.dll"); | 28 } |
| 27 | |
| 28 std::wstring args(shell32dll.value()); | |
| 29 args.append(L",SHHelpShortcuts_RunDLL PrintersFolder"); | |
| 30 ShellExecute(NULL, L"open", rundll32.value().c_str(), args.c_str(), NULL, | |
| 31 SW_SHOWNORMAL); | |
| 32 } | |
| 33 | |
| 34 private: | |
| 35 DISALLOW_COPY_AND_ASSIGN(OpenPrintersDialogTask); | |
| 36 }; | |
| 37 | 29 |
| 38 void PrinterManagerDialog::ShowPrinterManagerDialog() { | 30 void PrinterManagerDialog::ShowPrinterManagerDialog() { |
| 39 g_browser_process->file_thread()->message_loop()->PostTask( | 31 g_browser_process->file_thread()->message_loop()->PostTask( |
| 40 FROM_HERE, new OpenPrintersDialogTask); | 32 FROM_HERE, base::Bind(OpenPrintersDialogTask)); |
|
Lei Zhang
2011/11/23 23:34:04
Do you need to #include "base/bind.h" here?
James Hawkins
2011/11/24 00:35:11
Done.
| |
| 41 } | 33 } |
| 42 | 34 |
| 43 } // namespace printing | 35 } // namespace printing |
| OLD | NEW |