Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(750)

Side by Side Diff: remoting/host/elevated_controller_win.cc

Issue 10537182: The user's consent to crash dumps reporting can now be set via the UI (Windows only). The checkbox … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/elevated_controller_win.h ('k') | remoting/host/host_service_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "base/win/scoped_handle.h" 19 #include "base/win/scoped_handle.h"
20 #include "remoting/host/branding.h" 20 #include "remoting/host/branding.h"
21 #include "remoting/host/elevated_controller_resource.h" 21 #include "remoting/host/elevated_controller_resource.h"
22 #include "remoting/host/usage_stats_consent.h"
22 #include "remoting/host/verify_config_window_win.h" 23 #include "remoting/host/verify_config_window_win.h"
23 24
24 namespace { 25 namespace {
25 26
26 // The maximum size of the configuration file. "1MB ought to be enough" for any 27 // The maximum size of the configuration file. "1MB ought to be enough" for any
27 // reasonable configuration we will ever need. 1MB is low enough to make 28 // reasonable configuration we will ever need. 1MB is low enough to make
28 // the probability of out of memory situation fairly low. OOM is still possible 29 // the probability of out of memory situation fairly low. OOM is still possible
29 // and we will crash if it occurs. 30 // and we will crash if it occurs.
30 const size_t kMaxConfigFileSize = 1024 * 1024; 31 const size_t kMaxConfigFileSize = 1024 * 1024;
31 32
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 } 474 }
474 // Merge items from the given config into the old config. 475 // Merge items from the given config into the old config.
475 config_old->MergeDictionary(config_dict); 476 config_old->MergeDictionary(config_dict);
476 // Write the updated config. 477 // Write the updated config.
477 std::string config_updated_str; 478 std::string config_updated_str;
478 base::JSONWriter::Write(config_old.get(), &config_updated_str); 479 base::JSONWriter::Write(config_old.get(), &config_updated_str);
479 return WriteConfig(config_updated_str.c_str(), config_updated_str.size(), 480 return WriteConfig(config_updated_str.c_str(), config_updated_str.size(),
480 owner_window_); 481 owner_window_);
481 } 482 }
482 483
484 STDMETHODIMP ElevatedControllerWin::GetUsageStatsConsent(BOOL* allowed,
485 BOOL* set_by_policy) {
486 bool local_allowed;
487 bool local_set_by_policy;
488 if (remoting::GetUsageStatsConsent(&local_allowed, &local_set_by_policy)) {
489 *allowed = local_allowed;
490 *set_by_policy = local_set_by_policy;
491 return S_OK;
492 } else {
493 return E_FAIL;
494 }
495 }
496
497 STDMETHODIMP ElevatedControllerWin::SetUsageStatsConsent(BOOL allowed) {
498 if (remoting::SetUsageStatsConsent(!!allowed)) {
499 return S_OK;
500 } else {
501 return E_FAIL;
502 }
503 }
504
483 HRESULT ElevatedControllerWin::OpenService(ScopedScHandle* service_out) { 505 HRESULT ElevatedControllerWin::OpenService(ScopedScHandle* service_out) {
484 DWORD error; 506 DWORD error;
485 507
486 ScopedScHandle scmanager( 508 ScopedScHandle scmanager(
487 ::OpenSCManagerW(NULL, SERVICES_ACTIVE_DATABASE, 509 ::OpenSCManagerW(NULL, SERVICES_ACTIVE_DATABASE,
488 SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE)); 510 SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE));
489 if (!scmanager.IsValid()) { 511 if (!scmanager.IsValid()) {
490 error = GetLastError(); 512 error = GetLastError();
491 LOG_GETLASTERROR(ERROR) 513 LOG_GETLASTERROR(ERROR)
492 << "Failed to connect to the service control manager"; 514 << "Failed to connect to the service control manager";
(...skipping 11 matching lines...) Expand all
504 << "Failed to open to the '" << kWindowsServiceName << "' service"; 526 << "Failed to open to the '" << kWindowsServiceName << "' service";
505 527
506 return HRESULT_FROM_WIN32(error); 528 return HRESULT_FROM_WIN32(error);
507 } 529 }
508 530
509 service_out->Set(service.Take()); 531 service_out->Set(service.Take());
510 return S_OK; 532 return S_OK;
511 } 533 }
512 534
513 } // namespace remoting 535 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/elevated_controller_win.h ('k') | remoting/host/host_service_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698