| 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 "remoting/host/plugin/daemon_installer_win.h" | 5 #include "remoting/host/plugin/daemon_installer_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/process_util.h" | 11 #include "base/process_util.h" |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 #include "base/stringize_macros.h" | |
| 14 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
| 15 #include "base/time.h" | 14 #include "base/time.h" |
| 16 #include "base/timer.h" | 15 #include "base/timer.h" |
| 16 #include "base/utf_string_conversions.h" |
| 17 #include "base/win/object_watcher.h" | 17 #include "base/win/object_watcher.h" |
| 18 #include "base/win/registry.h" | 18 #include "base/win/registry.h" |
| 19 #include "base/win/scoped_bstr.h" | 19 #include "base/win/scoped_bstr.h" |
| 20 #include "base/win/scoped_comptr.h" | 20 #include "base/win/scoped_comptr.h" |
| 21 #include "base/win/scoped_handle.h" | 21 #include "base/win/scoped_handle.h" |
| 22 #include "base/win/scoped_variant.h" | 22 #include "base/win/scoped_variant.h" |
| 23 #include "google_update/google_update_idl.h" | 23 #include "google_update/google_update_idl.h" |
| 24 #include "remoting/base/dispatch_win.h" | 24 #include "remoting/base/dispatch_win.h" |
| 25 #include "remoting/host/constants.h" | 25 #include "remoting/host/constants.h" |
| 26 | 26 |
| 27 using base::win::ScopedBstr; | 27 using base::win::ScopedBstr; |
| 28 using base::win::ScopedComPtr; | 28 using base::win::ScopedComPtr; |
| 29 using base::win::ScopedVariant; | 29 using base::win::ScopedVariant; |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 // The COM elevation moniker for Omaha. | 33 // The COM elevation moniker for Omaha. |
| 34 const char16 kOmahaElevationMoniker[] = | 34 const wchar_t kOmahaElevationMoniker[] = |
| 35 TO_L_STRING("Elevation:Administrator!new:GoogleUpdate.Update3WebMachine"); | 35 L"Elevation:Administrator!new:GoogleUpdate.Update3WebMachine"; |
| 36 | 36 |
| 37 // The registry key where the configuration of Omaha is stored. | 37 // The registry key where the configuration of Omaha is stored. |
| 38 const char16 kOmahaUpdateKeyName[] = TO_L_STRING("Software\\Google\\Update"); | 38 const wchar_t kOmahaUpdateKeyName[] = L"Software\\Google\\Update"; |
| 39 | 39 |
| 40 // The name of the value where the full path to GoogleUpdate.exe is stored. | 40 // The name of the value where the full path to GoogleUpdate.exe is stored. |
| 41 const char16 kOmahaPathValueName[] = TO_L_STRING("path"); | 41 const wchar_t kOmahaPathValueName[] = L"path"; |
| 42 | 42 |
| 43 // The command line format string for GoogleUpdate.exe | 43 // The command line format string for GoogleUpdate.exe |
| 44 const char16 kGoogleUpdateCommandLineFormat[] = | 44 const wchar_t kGoogleUpdateCommandLineFormat[] = |
| 45 TO_L_STRING("\"%ls\" /install \"bundlename=Chromoting%%20Host&appguid=%ls&") | 45 L"\"%ls\" /install \"bundlename=Chromoting%%20Host&appguid=%ls&" |
| 46 TO_L_STRING("appname=Chromoting%%20Host&needsadmin=True&lang=%ls\""); | 46 L"appname=Chromoting%%20Host&needsadmin=True&lang=%ls\""; |
| 47 | 47 |
| 48 // TODO(alexeypa): Get the desired laungage from the web app. | 48 // TODO(alexeypa): Get the desired laungage from the web app. |
| 49 const char16 kOmahaLanguage[] = TO_L_STRING("en"); | 49 const wchar_t kOmahaLanguage[] = L"en"; |
| 50 | 50 |
| 51 // An empty string for optional parameters. | 51 // An empty string for optional parameters. |
| 52 const char16 kOmahaEmpty[] = TO_L_STRING(""); | 52 const wchar_t kOmahaEmpty[] = L""; |
| 53 | 53 |
| 54 // The installation status polling interval. | 54 // The installation status polling interval. |
| 55 const int kOmahaPollIntervalMs = 500; | 55 const int kOmahaPollIntervalMs = 500; |
| 56 | 56 |
| 57 } // namespace | 57 } // namespace |
| 58 | 58 |
| 59 namespace remoting { | 59 namespace remoting { |
| 60 | 60 |
| 61 // This class implements on-demand installation of the Chromoting Host via | 61 // This class implements on-demand installation of the Chromoting Host via |
| 62 // per-machine Omaha instance. | 62 // per-machine Omaha instance. |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 // Get the full path to GoogleUpdate.exe from the registry. | 274 // Get the full path to GoogleUpdate.exe from the registry. |
| 275 base::win::RegKey update_key; | 275 base::win::RegKey update_key; |
| 276 LONG result = update_key.Open(HKEY_CURRENT_USER, | 276 LONG result = update_key.Open(HKEY_CURRENT_USER, |
| 277 kOmahaUpdateKeyName, | 277 kOmahaUpdateKeyName, |
| 278 KEY_READ); | 278 KEY_READ); |
| 279 if (result != ERROR_SUCCESS) { | 279 if (result != ERROR_SUCCESS) { |
| 280 Done(HRESULT_FROM_WIN32(result)); | 280 Done(HRESULT_FROM_WIN32(result)); |
| 281 return; | 281 return; |
| 282 } | 282 } |
| 283 | 283 |
| 284 string16 google_update; | 284 std::wstring google_update; |
| 285 result = update_key.ReadValue(kOmahaPathValueName, | 285 result = update_key.ReadValue(kOmahaPathValueName, |
| 286 &google_update); | 286 &google_update); |
| 287 if (result != ERROR_SUCCESS) { | 287 if (result != ERROR_SUCCESS) { |
| 288 Done(HRESULT_FROM_WIN32(result)); | 288 Done(HRESULT_FROM_WIN32(result)); |
| 289 return; | 289 return; |
| 290 } | 290 } |
| 291 | 291 |
| 292 // Launch the updater process and wait for its termination. | 292 // Launch the updater process and wait for its termination. |
| 293 string16 command_line = | 293 std::wstring command_line = |
| 294 StringPrintf(kGoogleUpdateCommandLineFormat, | 294 StringPrintf(kGoogleUpdateCommandLineFormat, |
| 295 google_update.c_str(), | 295 google_update.c_str(), |
| 296 kHostOmahaAppid, | 296 kHostOmahaAppid, |
| 297 kOmahaLanguage); | 297 kOmahaLanguage); |
| 298 | 298 |
| 299 base::LaunchOptions options; | 299 base::LaunchOptions options; |
| 300 if (!base::LaunchProcess(command_line, options, process_.Receive())) { | 300 if (!base::LaunchProcess(WideToUTF16(command_line), options, |
| 301 process_.Receive())) { |
| 301 result = GetLastError(); | 302 result = GetLastError(); |
| 302 Done(HRESULT_FROM_WIN32(result)); | 303 Done(HRESULT_FROM_WIN32(result)); |
| 303 return; | 304 return; |
| 304 } | 305 } |
| 305 | 306 |
| 306 if (!process_watcher_.StartWatching(process_.Get(), this)) { | 307 if (!process_watcher_.StartWatching(process_.Get(), this)) { |
| 307 result = GetLastError(); | 308 result = GetLastError(); |
| 308 Done(HRESULT_FROM_WIN32(result)); | 309 Done(HRESULT_FROM_WIN32(result)); |
| 309 return; | 310 return; |
| 310 } | 311 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 HWND parent = GetAncestor(window, GA_PARENT); | 383 HWND parent = GetAncestor(window, GA_PARENT); |
| 383 if (parent == NULL) { | 384 if (parent == NULL) { |
| 384 return window; | 385 return window; |
| 385 } | 386 } |
| 386 | 387 |
| 387 window = parent; | 388 window = parent; |
| 388 } | 389 } |
| 389 } | 390 } |
| 390 | 391 |
| 391 } // namespace remoting | 392 } // namespace remoting |
| OLD | NEW |