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/elevated_controller_win.h" | 5 #include "remoting/host/elevated_controller_win.h" |
6 | 6 |
7 #include <sddl.h> | 7 #include <sddl.h> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/file_version_info.h" | 10 #include "base/file_version_info.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/process_util.h" | 16 #include "base/process_util.h" |
17 #include "base/stringize_macros.h" | 17 #include "base/stringize_macros.h" |
18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
19 #include "base/values.h" | 19 #include "base/values.h" |
20 #include "base/win/scoped_handle.h" | 20 #include "base/win/scoped_handle.h" |
21 #include "remoting/host/branding.h" | 21 #include "remoting/host/branding.h" |
| 22 #include "remoting/host/breakpad.h" |
22 #include "remoting/host/elevated_controller_resource.h" | 23 #include "remoting/host/elevated_controller_resource.h" |
23 #include "remoting/host/verify_config_window_win.h" | 24 #include "remoting/host/verify_config_window_win.h" |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 // The maximum size of the configuration file. "1MB ought to be enough" for any | 28 // The maximum size of the configuration file. "1MB ought to be enough" for any |
28 // reasonable configuration we will ever need. 1MB is low enough to make | 29 // reasonable configuration we will ever need. 1MB is low enough to make |
29 // the probability of out of memory situation fairly low. OOM is still possible | 30 // the probability of out of memory situation fairly low. OOM is still possible |
30 // and we will crash if it occurs. | 31 // and we will crash if it occurs. |
31 const size_t kMaxConfigFileSize = 1024 * 1024; | 32 const size_t kMaxConfigFileSize = 1024 * 1024; |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 } | 475 } |
475 // Merge items from the given config into the old config. | 476 // Merge items from the given config into the old config. |
476 config_old->MergeDictionary(config_dict); | 477 config_old->MergeDictionary(config_dict); |
477 // Write the updated config. | 478 // Write the updated config. |
478 std::string config_updated_str; | 479 std::string config_updated_str; |
479 base::JSONWriter::Write(config_old.get(), &config_updated_str); | 480 base::JSONWriter::Write(config_old.get(), &config_updated_str); |
480 return WriteConfig(config_updated_str.c_str(), config_updated_str.size(), | 481 return WriteConfig(config_updated_str.c_str(), config_updated_str.size(), |
481 owner_window_); | 482 owner_window_); |
482 } | 483 } |
483 | 484 |
| 485 STDMETHODIMP ElevatedControllerWin::GetUsageStatsConsent(BOOL* set_by_policy, |
| 486 BOOL* allowed) { |
| 487 bool local_set_by_policy; |
| 488 bool local_allowed; |
| 489 if (::remoting::GetUsageStatsConsent(&local_set_by_policy, &local_allowed)) { |
| 490 *set_by_policy = local_set_by_policy; |
| 491 *allowed = local_allowed; |
| 492 return S_OK; |
| 493 } else { |
| 494 return E_FAIL; |
| 495 } |
| 496 } |
| 497 |
| 498 STDMETHODIMP ElevatedControllerWin::SetUsageStatsConsent(BOOL allowed) { |
| 499 if (::remoting::SetUsageStatsConsent(!!allowed)) { |
| 500 return S_OK; |
| 501 } else { |
| 502 return E_FAIL; |
| 503 } |
| 504 } |
| 505 |
484 HRESULT ElevatedControllerWin::OpenService(ScopedScHandle* service_out) { | 506 HRESULT ElevatedControllerWin::OpenService(ScopedScHandle* service_out) { |
485 DWORD error; | 507 DWORD error; |
486 | 508 |
487 ScopedScHandle scmanager( | 509 ScopedScHandle scmanager( |
488 ::OpenSCManagerW(NULL, SERVICES_ACTIVE_DATABASE, | 510 ::OpenSCManagerW(NULL, SERVICES_ACTIVE_DATABASE, |
489 SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE)); | 511 SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE)); |
490 if (!scmanager.IsValid()) { | 512 if (!scmanager.IsValid()) { |
491 error = GetLastError(); | 513 error = GetLastError(); |
492 LOG_GETLASTERROR(ERROR) | 514 LOG_GETLASTERROR(ERROR) |
493 << "Failed to connect to the service control manager"; | 515 << "Failed to connect to the service control manager"; |
(...skipping 11 matching lines...) Expand all Loading... |
505 << "Failed to open to the '" << kWindowsServiceName << "' service"; | 527 << "Failed to open to the '" << kWindowsServiceName << "' service"; |
506 | 528 |
507 return HRESULT_FROM_WIN32(error); | 529 return HRESULT_FROM_WIN32(error); |
508 } | 530 } |
509 | 531 |
510 service_out->Set(service.Take()); | 532 service_out->Set(service.Take()); |
511 return S_OK; | 533 return S_OK; |
512 } | 534 } |
513 | 535 |
514 } // namespace remoting | 536 } // namespace remoting |
OLD | NEW |