| 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/setup/daemon_installer_win.h" | 5 #include "remoting/host/setup/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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 if (FAILED(hr)) { | 128 if (FAILED(hr)) { |
| 129 Done(hr); | 129 Done(hr); |
| 130 return; | 130 return; |
| 131 } | 131 } |
| 132 if (bundle_.type() != VT_DISPATCH) { | 132 if (bundle_.type() != VT_DISPATCH) { |
| 133 Done(DISP_E_TYPEMISMATCH); | 133 Done(DISP_E_TYPEMISMATCH); |
| 134 return; | 134 return; |
| 135 } | 135 } |
| 136 | 136 |
| 137 hr = dispatch::Invoke(V_DISPATCH(&bundle_), L"initialize", DISPATCH_METHOD, | 137 hr = dispatch::Invoke(V_DISPATCH(&bundle_), L"initialize", DISPATCH_METHOD, |
| 138 NULL); | 138 nullptr); |
| 139 if (FAILED(hr)) { | 139 if (FAILED(hr)) { |
| 140 Done(hr); | 140 Done(hr); |
| 141 return; | 141 return; |
| 142 } | 142 } |
| 143 | 143 |
| 144 // Add Chromoting Host to the bundle. | 144 // Add Chromoting Host to the bundle. |
| 145 ScopedVariant appid(kHostOmahaAppid); | 145 ScopedVariant appid(kHostOmahaAppid); |
| 146 ScopedVariant empty(kOmahaEmpty); | 146 ScopedVariant empty(kOmahaEmpty); |
| 147 ScopedVariant language(kOmahaLanguage); | 147 ScopedVariant language(kOmahaLanguage); |
| 148 hr = dispatch::Invoke(V_DISPATCH(&bundle_), L"createApp", DISPATCH_METHOD, | 148 hr = dispatch::Invoke(V_DISPATCH(&bundle_), L"createApp", DISPATCH_METHOD, |
| 149 appid, empty, language, empty, NULL); | 149 appid, empty, language, empty, nullptr); |
| 150 if (FAILED(hr)) { | 150 if (FAILED(hr)) { |
| 151 Done(hr); | 151 Done(hr); |
| 152 return; | 152 return; |
| 153 } | 153 } |
| 154 | 154 |
| 155 hr = dispatch::Invoke(V_DISPATCH(&bundle_), L"checkForUpdate", | 155 hr = dispatch::Invoke(V_DISPATCH(&bundle_), L"checkForUpdate", |
| 156 DISPATCH_METHOD, NULL); | 156 DISPATCH_METHOD, nullptr); |
| 157 if (FAILED(hr)) { | 157 if (FAILED(hr)) { |
| 158 Done(hr); | 158 Done(hr); |
| 159 return; | 159 return; |
| 160 } | 160 } |
| 161 | 161 |
| 162 hr = dispatch::Invoke(V_DISPATCH(&bundle_), L"appWeb", | 162 hr = dispatch::Invoke(V_DISPATCH(&bundle_), L"appWeb", |
| 163 DISPATCH_PROPERTYGET, ScopedVariant(0), app_.Receive()); | 163 DISPATCH_PROPERTYGET, ScopedVariant(0), app_.Receive()); |
| 164 if (FAILED(hr)) { | 164 if (FAILED(hr)) { |
| 165 Done(hr); | 165 Done(hr); |
| 166 return; | 166 return; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 case STATE_WAITING_TO_DOWNLOAD: | 207 case STATE_WAITING_TO_DOWNLOAD: |
| 208 case STATE_RETRYING_DOWNLOAD: | 208 case STATE_RETRYING_DOWNLOAD: |
| 209 case STATE_DOWNLOADING: | 209 case STATE_DOWNLOADING: |
| 210 case STATE_WAITING_TO_INSTALL: | 210 case STATE_WAITING_TO_INSTALL: |
| 211 case STATE_INSTALLING: | 211 case STATE_INSTALLING: |
| 212 case STATE_PAUSED: | 212 case STATE_PAUSED: |
| 213 break; | 213 break; |
| 214 | 214 |
| 215 case STATE_UPDATE_AVAILABLE: | 215 case STATE_UPDATE_AVAILABLE: |
| 216 hr = dispatch::Invoke(V_DISPATCH(&bundle_), L"download", | 216 hr = dispatch::Invoke(V_DISPATCH(&bundle_), L"download", |
| 217 DISPATCH_METHOD, NULL); | 217 DISPATCH_METHOD, nullptr); |
| 218 if (FAILED(hr)) { | 218 if (FAILED(hr)) { |
| 219 Done(hr); | 219 Done(hr); |
| 220 return; | 220 return; |
| 221 } | 221 } |
| 222 break; | 222 break; |
| 223 | 223 |
| 224 case STATE_DOWNLOAD_COMPLETE: | 224 case STATE_DOWNLOAD_COMPLETE: |
| 225 case STATE_EXTRACTING: | 225 case STATE_EXTRACTING: |
| 226 case STATE_APPLYING_DIFFERENTIAL_PATCH: | 226 case STATE_APPLYING_DIFFERENTIAL_PATCH: |
| 227 case STATE_READY_TO_INSTALL: | 227 case STATE_READY_TO_INSTALL: |
| 228 hr = dispatch::Invoke(V_DISPATCH(&bundle_), L"install", | 228 hr = dispatch::Invoke(V_DISPATCH(&bundle_), L"install", |
| 229 DISPATCH_METHOD, NULL); | 229 DISPATCH_METHOD, nullptr); |
| 230 if (FAILED(hr)) { | 230 if (FAILED(hr)) { |
| 231 Done(hr); | 231 Done(hr); |
| 232 return; | 232 return; |
| 233 } | 233 } |
| 234 break; | 234 break; |
| 235 | 235 |
| 236 case STATE_INSTALL_COMPLETE: | 236 case STATE_INSTALL_COMPLETE: |
| 237 case STATE_NO_UPDATE: | 237 case STATE_NO_UPDATE: |
| 238 // Installation complete or not required. Report success. | 238 // Installation complete or not required. Report success. |
| 239 Done(S_OK); | 239 Done(S_OK); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 ScopedComPtr<IDispatch> update3; | 345 ScopedComPtr<IDispatch> update3; |
| 346 | 346 |
| 347 // Check if the machine instance of Omaha is available. The COM elevation is | 347 // Check if the machine instance of Omaha is available. The COM elevation is |
| 348 // supported on Vista+, so on XP/W2K3 we assume that we are running under | 348 // supported on Vista+, so on XP/W2K3 we assume that we are running under |
| 349 // a privileged user and get ACCESS_DENIED later if we are not. | 349 // a privileged user and get ACCESS_DENIED later if we are not. |
| 350 if (base::win::GetVersion() < base::win::VERSION_VISTA) { | 350 if (base::win::GetVersion() < base::win::VERSION_VISTA) { |
| 351 CLSID class_id; | 351 CLSID class_id; |
| 352 result = CLSIDFromProgID(kGoogleUpdate, &class_id); | 352 result = CLSIDFromProgID(kGoogleUpdate, &class_id); |
| 353 if (SUCCEEDED(result)) { | 353 if (SUCCEEDED(result)) { |
| 354 result = CoCreateInstance(class_id, | 354 result = CoCreateInstance(class_id, |
| 355 NULL, | 355 nullptr, |
| 356 CLSCTX_LOCAL_SERVER, | 356 CLSCTX_LOCAL_SERVER, |
| 357 IID_IDispatch, | 357 IID_IDispatch, |
| 358 update3.ReceiveVoid()); | 358 update3.ReceiveVoid()); |
| 359 } | 359 } |
| 360 } else { | 360 } else { |
| 361 BIND_OPTS3 bind_options; | 361 BIND_OPTS3 bind_options; |
| 362 memset(&bind_options, 0, sizeof(bind_options)); | 362 memset(&bind_options, 0, sizeof(bind_options)); |
| 363 bind_options.cbStruct = sizeof(bind_options); | 363 bind_options.cbStruct = sizeof(bind_options); |
| 364 bind_options.hwnd = GetTopLevelWindow(window_handle); | 364 bind_options.hwnd = GetTopLevelWindow(window_handle); |
| 365 bind_options.dwClassContext = CLSCTX_LOCAL_SERVER; | 365 bind_options.dwClassContext = CLSCTX_LOCAL_SERVER; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 382 done.Run(result); | 382 done.Run(result); |
| 383 return nullptr; | 383 return nullptr; |
| 384 } | 384 } |
| 385 | 385 |
| 386 // The machine instance of Omaha is available and we successfully passed | 386 // The machine instance of Omaha is available and we successfully passed |
| 387 // the UAC prompt. | 387 // the UAC prompt. |
| 388 return make_scoped_ptr(new DaemonComInstallerWin(update3, done)); | 388 return make_scoped_ptr(new DaemonComInstallerWin(update3, done)); |
| 389 } | 389 } |
| 390 | 390 |
| 391 HWND GetTopLevelWindow(HWND window) { | 391 HWND GetTopLevelWindow(HWND window) { |
| 392 if (window == NULL) { | 392 if (window == nullptr) { |
| 393 return NULL; | 393 return nullptr; |
| 394 } | 394 } |
| 395 | 395 |
| 396 for (;;) { | 396 for (;;) { |
| 397 LONG style = GetWindowLong(window, GWL_STYLE); | 397 LONG style = GetWindowLong(window, GWL_STYLE); |
| 398 if ((style & WS_OVERLAPPEDWINDOW) == WS_OVERLAPPEDWINDOW || | 398 if ((style & WS_OVERLAPPEDWINDOW) == WS_OVERLAPPEDWINDOW || |
| 399 (style & WS_POPUP) == WS_POPUP) { | 399 (style & WS_POPUP) == WS_POPUP) { |
| 400 return window; | 400 return window; |
| 401 } | 401 } |
| 402 | 402 |
| 403 HWND parent = GetAncestor(window, GA_PARENT); | 403 HWND parent = GetAncestor(window, GA_PARENT); |
| 404 if (parent == NULL) { | 404 if (parent == nullptr) { |
| 405 return window; | 405 return window; |
| 406 } | 406 } |
| 407 | 407 |
| 408 window = parent; | 408 window = parent; |
| 409 } | 409 } |
| 410 } | 410 } |
| 411 | 411 |
| 412 } // namespace remoting | 412 } // namespace remoting |
| OLD | NEW |