| 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" |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 | 325 |
| 326 DaemonInstallerWin::~DaemonInstallerWin() { | 326 DaemonInstallerWin::~DaemonInstallerWin() { |
| 327 } | 327 } |
| 328 | 328 |
| 329 void DaemonInstallerWin::Done(HRESULT result) { | 329 void DaemonInstallerWin::Done(HRESULT result) { |
| 330 done_.Run(result); | 330 done_.Run(result); |
| 331 } | 331 } |
| 332 | 332 |
| 333 // static | 333 // static |
| 334 scoped_ptr<DaemonInstallerWin> DaemonInstallerWin::Create( | 334 scoped_ptr<DaemonInstallerWin> DaemonInstallerWin::Create( |
| 335 void* window_handle, |
| 335 CompletionCallback done) { | 336 CompletionCallback done) { |
| 336 // Check if the machine instance of Omaha is available. | 337 // Check if the machine instance of Omaha is available. |
| 337 BIND_OPTS3 bind_options; | 338 BIND_OPTS3 bind_options; |
| 338 memset(&bind_options, 0, sizeof(bind_options)); | 339 memset(&bind_options, 0, sizeof(bind_options)); |
| 339 bind_options.cbStruct = sizeof(bind_options); | 340 bind_options.cbStruct = sizeof(bind_options); |
| 340 bind_options.hwnd = NULL; | 341 bind_options.hwnd = GetTopLevelWindow(reinterpret_cast<HWND>(window_handle)); |
| 341 bind_options.dwClassContext = CLSCTX_LOCAL_SERVER; | 342 bind_options.dwClassContext = CLSCTX_LOCAL_SERVER; |
| 342 | 343 |
| 343 ScopedComPtr<omaha::IGoogleUpdate3Web> update3; | 344 ScopedComPtr<omaha::IGoogleUpdate3Web> update3; |
| 344 HRESULT result = ::CoGetObject( | 345 HRESULT result = ::CoGetObject( |
| 345 kOmahaElevationMoniker, | 346 kOmahaElevationMoniker, |
| 346 &bind_options, | 347 &bind_options, |
| 347 omaha::IID_IGoogleUpdate3Web, | 348 omaha::IID_IGoogleUpdate3Web, |
| 348 update3.ReceiveVoid()); | 349 update3.ReceiveVoid()); |
| 349 if (SUCCEEDED(result)) { | 350 if (SUCCEEDED(result)) { |
| 350 // The machine instance of Omaha is available and we successfully passed | 351 // The machine instance of Omaha is available and we successfully passed |
| 351 // the UAC prompt. | 352 // the UAC prompt. |
| 352 return scoped_ptr<DaemonInstallerWin>( | 353 return scoped_ptr<DaemonInstallerWin>( |
| 353 new DaemonComInstallerWin(update3, done)); | 354 new DaemonComInstallerWin(update3, done)); |
| 354 } else if (result == CO_E_CLASSSTRING) { | 355 } else if (result == CO_E_CLASSSTRING) { |
| 355 // The machine instance of Omaha is not available so we will have to run | 356 // The machine instance of Omaha is not available so we will have to run |
| 356 // GoogleUpdate.exe manually passing "needsadmin=True". This will cause | 357 // GoogleUpdate.exe manually passing "needsadmin=True". This will cause |
| 357 // Omaha to install the machine instance first and then install Chromoting | 358 // Omaha to install the machine instance first and then install Chromoting |
| 358 // Host. | 359 // Host. |
| 359 return scoped_ptr<DaemonInstallerWin>( | 360 return scoped_ptr<DaemonInstallerWin>( |
| 360 new DaemonCommandLineInstallerWin(done)); | 361 new DaemonCommandLineInstallerWin(done)); |
| 361 } else { | 362 } else { |
| 362 // The user declined the UAC prompt or some other error occured. | 363 // The user declined the UAC prompt or some other error occured. |
| 363 done.Run(result); | 364 done.Run(result); |
| 364 return scoped_ptr<DaemonInstallerWin>(); | 365 return scoped_ptr<DaemonInstallerWin>(); |
| 365 } | 366 } |
| 366 } | 367 } |
| 367 | 368 |
| 369 HWND GetTopLevelWindow(HWND window) { |
| 370 if (window == NULL) { |
| 371 return NULL; |
| 372 } |
| 373 |
| 374 for (;;) { |
| 375 LONG style = GetWindowLong(window, GWL_STYLE); |
| 376 if ((style & WS_OVERLAPPEDWINDOW) == WS_OVERLAPPEDWINDOW || |
| 377 (style & WS_POPUP) == WS_POPUP) { |
| 378 return window; |
| 379 } |
| 380 |
| 381 HWND parent = GetAncestor(window, GA_PARENT); |
| 382 if (parent == NULL) { |
| 383 return window; |
| 384 } |
| 385 |
| 386 window = parent; |
| 387 } |
| 388 } |
| 389 |
| 368 } // namespace remoting | 390 } // namespace remoting |
| OLD | NEW |