OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_controller_delegate_win.h" | 5 #include "remoting/host/setup/daemon_controller_delegate_win.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 // consent to collecting crash dumps. | 319 // consent to collecting crash dumps. |
320 return consent; | 320 return consent; |
321 } | 321 } |
322 | 322 |
323 consent.allowed = !!allowed; | 323 consent.allowed = !!allowed; |
324 consent.set_by_policy = !!set_by_policy; | 324 consent.set_by_policy = !!set_by_policy; |
325 return consent; | 325 return consent; |
326 } | 326 } |
327 | 327 |
328 HRESULT DaemonControllerDelegateWin::ActivateController() { | 328 HRESULT DaemonControllerDelegateWin::ActivateController() { |
329 if (!control_) { | 329 if (!control_.get()) { |
330 CLSID class_id; | 330 CLSID class_id; |
331 HRESULT hr = CLSIDFromProgID(kDaemonController, &class_id); | 331 HRESULT hr = CLSIDFromProgID(kDaemonController, &class_id); |
332 if (FAILED(hr)) { | 332 if (FAILED(hr)) { |
333 return hr; | 333 return hr; |
334 } | 334 } |
335 | 335 |
336 hr = CoCreateInstance(class_id, NULL, CLSCTX_LOCAL_SERVER, | 336 hr = CoCreateInstance(class_id, NULL, CLSCTX_LOCAL_SERVER, |
337 IID_IDaemonControl, control_.ReceiveVoid()); | 337 IID_IDaemonControl, control_.ReceiveVoid()); |
338 if (FAILED(hr)) { | 338 if (FAILED(hr)) { |
339 return hr; | 339 return hr; |
(...skipping 15 matching lines...) Expand all Loading... |
355 | 355 |
356 HRESULT DaemonControllerDelegateWin::ActivateElevatedController() { | 356 HRESULT DaemonControllerDelegateWin::ActivateElevatedController() { |
357 // The COM elevation is supported on Vista and above. | 357 // The COM elevation is supported on Vista and above. |
358 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 358 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
359 return ActivateController(); | 359 return ActivateController(); |
360 | 360 |
361 // Release an unprivileged instance of the daemon controller if any. | 361 // Release an unprivileged instance of the daemon controller if any. |
362 if (!control_is_elevated_) | 362 if (!control_is_elevated_) |
363 ReleaseController(); | 363 ReleaseController(); |
364 | 364 |
365 if (!control_) { | 365 if (!control_.get()) { |
366 BIND_OPTS3 bind_options; | 366 BIND_OPTS3 bind_options; |
367 memset(&bind_options, 0, sizeof(bind_options)); | 367 memset(&bind_options, 0, sizeof(bind_options)); |
368 bind_options.cbStruct = sizeof(bind_options); | 368 bind_options.cbStruct = sizeof(bind_options); |
369 bind_options.hwnd = GetTopLevelWindow(window_handle_); | 369 bind_options.hwnd = GetTopLevelWindow(window_handle_); |
370 bind_options.dwClassContext = CLSCTX_LOCAL_SERVER; | 370 bind_options.dwClassContext = CLSCTX_LOCAL_SERVER; |
371 | 371 |
372 HRESULT hr = ::CoGetObject( | 372 HRESULT hr = ::CoGetObject( |
373 kDaemonControllerElevationMoniker, | 373 kDaemonControllerElevationMoniker, |
374 &bind_options, | 374 &bind_options, |
375 IID_IDaemonControl, | 375 IID_IDaemonControl, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 return; | 416 return; |
417 } | 417 } |
418 | 418 |
419 hr = ActivateElevatedController(); | 419 hr = ActivateElevatedController(); |
420 if (FAILED(hr)) { | 420 if (FAILED(hr)) { |
421 InvokeCompletionCallback(done, hr); | 421 InvokeCompletionCallback(done, hr); |
422 return; | 422 return; |
423 } | 423 } |
424 | 424 |
425 // Record the user's consent. | 425 // Record the user's consent. |
426 if (control2_) { | 426 if (control2_.get()) { |
427 hr = control2_->SetUsageStatsConsent(consent); | 427 hr = control2_->SetUsageStatsConsent(consent); |
428 if (FAILED(hr)) { | 428 if (FAILED(hr)) { |
429 InvokeCompletionCallback(done, hr); | 429 InvokeCompletionCallback(done, hr); |
430 return; | 430 return; |
431 } | 431 } |
432 } | 432 } |
433 | 433 |
434 // Set the configuration. | 434 // Set the configuration. |
435 ScopedBstr config_str(NULL); | 435 ScopedBstr config_str(NULL); |
436 ConfigToString(*config, &config_str); | 436 ConfigToString(*config, &config_str); |
(...skipping 20 matching lines...) Expand all Loading... |
457 InvokeCompletionCallback(done, hr); | 457 InvokeCompletionCallback(done, hr); |
458 } | 458 } |
459 | 459 |
460 scoped_refptr<DaemonController> DaemonController::Create() { | 460 scoped_refptr<DaemonController> DaemonController::Create() { |
461 scoped_ptr<DaemonController::Delegate> delegate( | 461 scoped_ptr<DaemonController::Delegate> delegate( |
462 new DaemonControllerDelegateWin()); | 462 new DaemonControllerDelegateWin()); |
463 return new DaemonController(delegate.Pass()); | 463 return new DaemonController(delegate.Pass()); |
464 } | 464 } |
465 | 465 |
466 } // namespace remoting | 466 } // namespace remoting |
OLD | NEW |