Chromium Code Reviews| 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 "chrome/browser/feedback/system_logs/log_sources/chrome_internal_log_so urce.h" | 5 #include "chrome/browser/feedback/system_logs/log_sources/chrome_internal_log_so urce.h" |
| 6 | 6 |
| 7 #include "base/json/json_string_value_serializer.h" | 7 #include "base/json/json_string_value_serializer.h" |
| 8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
| 12 #include "chrome/browser/sync/profile_sync_service_factory.h" | 12 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 13 #include "chrome/common/channel_info.h" | 13 #include "chrome/common/channel_info.h" |
| 14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 15 #include "components/browser_sync/profile_sync_service.h" | 15 #include "components/browser_sync/profile_sync_service.h" |
| 16 #include "components/prefs/pref_service.h" | 16 #include "components/prefs/pref_service.h" |
| 17 #include "components/sync/driver/about_sync_util.h" | 17 #include "components/sync/driver/about_sync_util.h" |
| 18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 #include "extensions/browser/extension_registry.h" | 19 #include "extensions/browser/extension_registry.h" |
| 20 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
| 21 #include "extensions/common/extension_set.h" | 21 #include "extensions/common/extension_set.h" |
| 22 | 22 |
| 23 #if defined(OS_CHROMEOS) | 23 #if defined(OS_CHROMEOS) |
| 24 #include "chrome/browser/metrics/chromeos_metrics_provider.h" | 24 #include "chrome/browser/metrics/chromeos_metrics_provider.h" |
| 25 #include "chromeos/system/statistics_provider.h" | 25 #include "chromeos/system/statistics_provider.h" |
| 26 #include "chromeos/system/version_loader.h" | |
| 26 #endif | 27 #endif |
| 27 | 28 |
| 28 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
| 29 #include "base/win/win_util.h" | 30 #include "base/win/win_util.h" |
| 30 #endif | 31 #endif |
| 31 | 32 |
| 32 namespace system_logs { | 33 namespace system_logs { |
| 33 | 34 |
| 34 namespace { | 35 namespace { |
| 35 | 36 |
| 36 constexpr char kSyncDataKey[] = "about_sync_data"; | 37 constexpr char kSyncDataKey[] = "about_sync_data"; |
| 37 constexpr char kExtensionsListKey[] = "extensions"; | 38 constexpr char kExtensionsListKey[] = "extensions"; |
| 38 constexpr char kDataReductionProxyKey[] = "data_reduction_proxy"; | 39 constexpr char kDataReductionProxyKey[] = "data_reduction_proxy"; |
| 39 constexpr char kChromeVersionTag[] = "CHROME VERSION"; | 40 constexpr char kChromeVersionTag[] = "CHROME VERSION"; |
| 40 #if defined(OS_CHROMEOS) | 41 #if defined(OS_CHROMEOS) |
| 42 constexpr char kChromeOsFirmwareVersion[] = "CHROMEOS_FIRMWARE_VERSION"; | |
| 41 constexpr char kChromeEnrollmentTag[] = "ENTERPRISE_ENROLLED"; | 43 constexpr char kChromeEnrollmentTag[] = "ENTERPRISE_ENROLLED"; |
| 42 constexpr char kHWIDKey[] = "HWID"; | 44 constexpr char kHWIDKey[] = "HWID"; |
| 43 constexpr char kSettingsKey[] = "settings"; | 45 constexpr char kSettingsKey[] = "settings"; |
| 44 constexpr char kLocalStateSettingsResponseKey[] = "Local State: settings"; | 46 constexpr char kLocalStateSettingsResponseKey[] = "Local State: settings"; |
| 45 #else | 47 #else |
| 46 constexpr char kOsVersionTag[] = "OS VERSION"; | 48 constexpr char kOsVersionTag[] = "OS VERSION"; |
| 47 #endif | 49 #endif |
| 48 #if defined(OS_WIN) | 50 #if defined(OS_WIN) |
| 49 constexpr char kUsbKeyboardDetected[] = "usb_keyboard_detected"; | 51 constexpr char kUsbKeyboardDetected[] = "usb_keyboard_detected"; |
| 50 constexpr char kIsEnrolledToDomain[] = "enrolled_to_domain"; | 52 constexpr char kIsEnrolledToDomain[] = "enrolled_to_domain"; |
| 51 #endif | 53 #endif |
| 52 | 54 |
| 53 #if defined(OS_CHROMEOS) | 55 #if defined(OS_CHROMEOS) |
| 54 std::string GetEnrollmentStatusString() { | 56 std::string GetEnrollmentStatusString() { |
| 55 switch (ChromeOSMetricsProvider::GetEnrollmentStatus()) { | 57 switch (ChromeOSMetricsProvider::GetEnrollmentStatus()) { |
| 56 case ChromeOSMetricsProvider::NON_MANAGED: | 58 case ChromeOSMetricsProvider::NON_MANAGED: |
| 57 return "Not managed"; | 59 return "Not managed"; |
| 58 case ChromeOSMetricsProvider::MANAGED: | 60 case ChromeOSMetricsProvider::MANAGED: |
| 59 return "Managed"; | 61 return "Managed"; |
| 60 case ChromeOSMetricsProvider::UNUSED: | 62 case ChromeOSMetricsProvider::UNUSED: |
| 61 case ChromeOSMetricsProvider::ERROR_GETTING_ENROLLMENT_STATUS: | 63 case ChromeOSMetricsProvider::ERROR_GETTING_ENROLLMENT_STATUS: |
| 62 case ChromeOSMetricsProvider::ENROLLMENT_STATUS_MAX: | 64 case ChromeOSMetricsProvider::ENROLLMENT_STATUS_MAX: |
| 63 return "Error retrieving status"; | 65 return "Error retrieving status"; |
| 64 } | 66 } |
| 65 // For compilers that don't recognize all cases handled above. | 67 // For compilers that don't recognize all cases handled above. |
| 66 NOTREACHED(); | 68 NOTREACHED(); |
| 67 return std::string(); | 69 return std::string(); |
| 68 } | 70 } |
| 69 | 71 |
| 70 void GetHWID(SystemLogsResponse* response) { | 72 void GetBackgroundEntries(SystemLogsResponse* response) { |
|
xiyuan
2017/01/05 17:46:17
nit: If "background" here does not have special me
afakhry
2017/01/05 17:57:15
Good suggestion. Thanks! Done.
| |
| 71 DCHECK(response); | 73 DCHECK(response); |
| 72 | 74 |
| 73 chromeos::system::StatisticsProvider* stats = | 75 chromeos::system::StatisticsProvider* stats = |
| 74 chromeos::system::StatisticsProvider::GetInstance(); | 76 chromeos::system::StatisticsProvider::GetInstance(); |
| 75 DCHECK(stats); | 77 DCHECK(stats); |
| 76 | 78 |
| 79 // Get the HWID. | |
| 77 std::string hwid; | 80 std::string hwid; |
| 78 if (!stats->GetMachineStatistic(chromeos::system::kHardwareClassKey, &hwid)) { | 81 if (!stats->GetMachineStatistic(chromeos::system::kHardwareClassKey, &hwid)) |
| 79 VLOG(1) << "Couldn't get machine statistic 'hardware_class'."; | 82 VLOG(1) << "Couldn't get machine statistic 'hardware_class'."; |
| 80 return; | 83 else |
| 81 } | 84 (*response)[kHWIDKey] = hwid; |
| 82 | 85 |
| 83 (*response)[kHWIDKey] = hwid; | 86 // Get the firmware version. |
| 87 (*response)[kChromeOsFirmwareVersion] = | |
| 88 chromeos::version_loader::GetFirmware(); | |
| 84 } | 89 } |
| 85 #endif | 90 #endif |
| 86 | 91 |
| 87 } // namespace | 92 } // namespace |
| 88 | 93 |
| 89 ChromeInternalLogSource::ChromeInternalLogSource() | 94 ChromeInternalLogSource::ChromeInternalLogSource() |
| 90 : SystemLogsSource("ChromeInternal") { | 95 : SystemLogsSource("ChromeInternal") { |
| 91 } | 96 } |
| 92 | 97 |
| 93 ChromeInternalLogSource::~ChromeInternalLogSource() { | 98 ChromeInternalLogSource::~ChromeInternalLogSource() { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 117 PopulateUsbKeyboardDetected(response.get()); | 122 PopulateUsbKeyboardDetected(response.get()); |
| 118 PopulateEnrolledToDomain(response.get()); | 123 PopulateEnrolledToDomain(response.get()); |
| 119 #endif | 124 #endif |
| 120 | 125 |
| 121 if (ProfileManager::GetLastUsedProfile()->IsChild()) | 126 if (ProfileManager::GetLastUsedProfile()->IsChild()) |
| 122 (*response)["account_type"] = "child"; | 127 (*response)["account_type"] = "child"; |
| 123 | 128 |
| 124 #if defined(OS_CHROMEOS) | 129 #if defined(OS_CHROMEOS) |
| 125 PopulateLocalStateSettings(response.get()); | 130 PopulateLocalStateSettings(response.get()); |
| 126 | 131 |
| 127 // Get the HWID on the blocking pool and invoke the callback later when done. | 132 // Get the entries that should be retrieved on the blocking pool and invoke |
| 133 // the callback later when done. | |
| 128 SystemLogsResponse* response_ptr = response.release(); | 134 SystemLogsResponse* response_ptr = response.release(); |
| 129 content::BrowserThread::PostBlockingPoolTaskAndReply( | 135 content::BrowserThread::PostBlockingPoolTaskAndReply( |
| 130 FROM_HERE, base::Bind(&GetHWID, response_ptr), | 136 FROM_HERE, base::Bind(&GetBackgroundEntries, response_ptr), |
| 131 base::Bind(callback, base::Owned(response_ptr))); | 137 base::Bind(callback, base::Owned(response_ptr))); |
| 132 #else | 138 #else |
| 133 // On other platforms, we're done. Invoke the callback. | 139 // On other platforms, we're done. Invoke the callback. |
| 134 callback.Run(response.get()); | 140 callback.Run(response.get()); |
| 135 #endif // defined(OS_CHROMEOS) | 141 #endif // defined(OS_CHROMEOS) |
| 136 } | 142 } |
| 137 | 143 |
| 138 void ChromeInternalLogSource::PopulateSyncLogs(SystemLogsResponse* response) { | 144 void ChromeInternalLogSource::PopulateSyncLogs(SystemLogsResponse* response) { |
| 139 // We are only interested in sync logs for the primary user profile. | 145 // We are only interested in sync logs for the primary user profile. |
| 140 Profile* profile = ProfileManager::GetPrimaryUserProfile(); | 146 Profile* profile = ProfileManager::GetPrimaryUserProfile(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 | 248 |
| 243 void ChromeInternalLogSource::PopulateEnrolledToDomain( | 249 void ChromeInternalLogSource::PopulateEnrolledToDomain( |
| 244 SystemLogsResponse* response) { | 250 SystemLogsResponse* response) { |
| 245 (*response)[kIsEnrolledToDomain] = base::win::IsEnrolledToDomain() | 251 (*response)[kIsEnrolledToDomain] = base::win::IsEnrolledToDomain() |
| 246 ? "Enrolled to domain" | 252 ? "Enrolled to domain" |
| 247 : "Not enrolled to domain"; | 253 : "Not enrolled to domain"; |
| 248 } | 254 } |
| 249 #endif | 255 #endif |
| 250 | 256 |
| 251 } // namespace system_logs | 257 } // namespace system_logs |
| OLD | NEW |