OLD | NEW |
1 // Copyright (c) 2012 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 "cloud_print/virtual_driver/win/port_monitor/port_monitor.h" | 5 #include "cloud_print/virtual_driver/win/port_monitor/port_monitor.h" |
6 | 6 |
7 #include <lmcons.h> | 7 #include <lmcons.h> |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 #include <shlobj.h> | 9 #include <shlobj.h> |
10 #include <strsafe.h> | 10 #include <strsafe.h> |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 const wchar_t kChromeExePath[] = L"google\\chrome\\application\\chrome.exe"; | 33 const wchar_t kChromeExePath[] = L"google\\chrome\\application\\chrome.exe"; |
34 const wchar_t kChromeExePathRegValue[] = L"PathToChromeExe"; | 34 const wchar_t kChromeExePathRegValue[] = L"PathToChromeExe"; |
35 const wchar_t kChromeProfilePathRegValue[] = L"PathToChromeProfile"; | 35 const wchar_t kChromeProfilePathRegValue[] = L"PathToChromeProfile"; |
36 const bool kIsUnittest = false; | 36 const bool kIsUnittest = false; |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 // Returns true if Xps support is installed. | 40 // Returns true if Xps support is installed. |
41 bool XpsIsInstalled() { | 41 bool XpsIsInstalled() { |
42 FilePath xps_path; | 42 base::FilePath xps_path; |
43 if (!SUCCEEDED(GetPrinterDriverDir(&xps_path))) { | 43 if (!SUCCEEDED(GetPrinterDriverDir(&xps_path))) { |
44 return false; | 44 return false; |
45 } | 45 } |
46 xps_path = xps_path.Append(L"mxdwdrv.dll"); | 46 xps_path = xps_path.Append(L"mxdwdrv.dll"); |
47 if (!file_util::PathExists(xps_path)) { | 47 if (!file_util::PathExists(xps_path)) { |
48 return false; | 48 return false; |
49 } | 49 } |
50 return true; | 50 return true; |
51 } | 51 } |
52 | 52 |
(...skipping 20 matching lines...) Expand all Loading... |
73 } // namespace cloud_print | 73 } // namespace cloud_print |
74 | 74 |
75 HRESULT WINAPI DllRegisterServer(void) { | 75 HRESULT WINAPI DllRegisterServer(void) { |
76 base::AtExitManager at_exit_manager; | 76 base::AtExitManager at_exit_manager; |
77 if (!cloud_print::CanRegister()) { | 77 if (!cloud_print::CanRegister()) { |
78 return E_ACCESSDENIED; | 78 return E_ACCESSDENIED; |
79 } | 79 } |
80 MONITOR_INFO_2 monitor_info = {0}; | 80 MONITOR_INFO_2 monitor_info = {0}; |
81 // YUCK!!! I can either copy the constant, const_cast, or define my own | 81 // YUCK!!! I can either copy the constant, const_cast, or define my own |
82 // MONITOR_INFO_2 that will take const strings. | 82 // MONITOR_INFO_2 that will take const strings. |
83 FilePath dll_path(cloud_print::GetPortMonitorDllName()); | 83 base::FilePath dll_path(cloud_print::GetPortMonitorDllName()); |
84 monitor_info.pDLLName = const_cast<LPWSTR>(dll_path.value().c_str()); | 84 monitor_info.pDLLName = const_cast<LPWSTR>(dll_path.value().c_str()); |
85 monitor_info.pName = const_cast<LPWSTR>(dll_path.value().c_str()); | 85 monitor_info.pName = const_cast<LPWSTR>(dll_path.value().c_str()); |
86 if (AddMonitor(NULL, 2, reinterpret_cast<BYTE*>(&monitor_info))) { | 86 if (AddMonitor(NULL, 2, reinterpret_cast<BYTE*>(&monitor_info))) { |
87 return S_OK; | 87 return S_OK; |
88 } | 88 } |
89 return cloud_print::GetLastHResult(); | 89 return cloud_print::GetLastHResult(); |
90 } | 90 } |
91 | 91 |
92 HRESULT WINAPI DllUnregisterServer(void) { | 92 HRESULT WINAPI DllUnregisterServer(void) { |
93 base::AtExitManager at_exit_manager; | 93 base::AtExitManager at_exit_manager; |
94 if (!cloud_print::CanRegister()) { | 94 if (!cloud_print::CanRegister()) { |
95 return E_ACCESSDENIED; | 95 return E_ACCESSDENIED; |
96 } | 96 } |
97 FilePath dll_path(cloud_print::GetPortMonitorDllName()); | 97 base::FilePath dll_path(cloud_print::GetPortMonitorDllName()); |
98 if (DeleteMonitor(NULL, | 98 if (DeleteMonitor(NULL, |
99 NULL, | 99 NULL, |
100 const_cast<LPWSTR>(dll_path.value().c_str()))) { | 100 const_cast<LPWSTR>(dll_path.value().c_str()))) { |
101 return S_OK; | 101 return S_OK; |
102 } | 102 } |
103 return cloud_print::GetLastHResult(); | 103 return cloud_print::GetLastHResult(); |
104 } | 104 } |
OLD | NEW |