| 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 "base/task_scheduler/post_task.h" | 9 #include "base/task_scheduler/post_task.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/google/google_brand.h" | 12 #include "chrome/browser/google/google_brand.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/browser/sync/profile_sync_service_factory.h" | 14 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 15 #include "chrome/common/channel_info.h" | 15 #include "chrome/common/channel_info.h" |
| 16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "components/browser_sync/profile_sync_service.h" | 17 #include "components/browser_sync/profile_sync_service.h" |
| 18 #include "components/prefs/pref_service.h" | 18 #include "components/prefs/pref_service.h" |
| 19 #include "components/sync/driver/about_sync_util.h" | 19 #include "components/sync/driver/about_sync_util.h" |
| 20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 21 #include "extensions/browser/api/power/power_api.h" |
| 21 #include "extensions/browser/extension_registry.h" | 22 #include "extensions/browser/extension_registry.h" |
| 23 #include "extensions/common/api/power.h" |
| 22 #include "extensions/common/extension.h" | 24 #include "extensions/common/extension.h" |
| 23 #include "extensions/common/extension_set.h" | 25 #include "extensions/common/extension_set.h" |
| 24 | 26 |
| 25 #if defined(OS_CHROMEOS) | 27 #if defined(OS_CHROMEOS) |
| 26 #include "chrome/browser/metrics/chromeos_metrics_provider.h" | 28 #include "chrome/browser/metrics/chromeos_metrics_provider.h" |
| 27 #include "chromeos/system/statistics_provider.h" | 29 #include "chromeos/system/statistics_provider.h" |
| 28 #include "chromeos/system/version_loader.h" | 30 #include "chromeos/system/version_loader.h" |
| 29 #endif | 31 #endif |
| 30 | 32 |
| 31 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
| 32 #include "base/win/win_util.h" | 34 #include "base/win/win_util.h" |
| 33 #endif | 35 #endif |
| 34 | 36 |
| 35 namespace system_logs { | 37 namespace system_logs { |
| 36 | 38 |
| 37 namespace { | 39 namespace { |
| 38 | 40 |
| 39 constexpr char kSyncDataKey[] = "about_sync_data"; | 41 constexpr char kSyncDataKey[] = "about_sync_data"; |
| 40 constexpr char kExtensionsListKey[] = "extensions"; | 42 constexpr char kExtensionsListKey[] = "extensions"; |
| 43 constexpr char kPowerApiListKey[] = "chrome.power extensions"; |
| 41 constexpr char kDataReductionProxyKey[] = "data_reduction_proxy"; | 44 constexpr char kDataReductionProxyKey[] = "data_reduction_proxy"; |
| 42 constexpr char kChromeVersionTag[] = "CHROME VERSION"; | 45 constexpr char kChromeVersionTag[] = "CHROME VERSION"; |
| 43 #if defined(OS_CHROMEOS) | 46 #if defined(OS_CHROMEOS) |
| 44 constexpr char kChromeOsFirmwareVersion[] = "CHROMEOS_FIRMWARE_VERSION"; | 47 constexpr char kChromeOsFirmwareVersion[] = "CHROMEOS_FIRMWARE_VERSION"; |
| 45 constexpr char kChromeEnrollmentTag[] = "ENTERPRISE_ENROLLED"; | 48 constexpr char kChromeEnrollmentTag[] = "ENTERPRISE_ENROLLED"; |
| 46 constexpr char kHWIDKey[] = "HWID"; | 49 constexpr char kHWIDKey[] = "HWID"; |
| 47 constexpr char kSettingsKey[] = "settings"; | 50 constexpr char kSettingsKey[] = "settings"; |
| 48 constexpr char kLocalStateSettingsResponseKey[] = "Local State: settings"; | 51 constexpr char kLocalStateSettingsResponseKey[] = "Local State: settings"; |
| 49 #else | 52 #else |
| 50 constexpr char kOsVersionTag[] = "OS VERSION"; | 53 constexpr char kOsVersionTag[] = "OS VERSION"; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 (*response)[kChromeEnrollmentTag] = GetEnrollmentStatusString(); | 116 (*response)[kChromeEnrollmentTag] = GetEnrollmentStatusString(); |
| 114 #else | 117 #else |
| 115 // On ChromeOS, this will be pulled in from the LSB_RELEASE. | 118 // On ChromeOS, this will be pulled in from the LSB_RELEASE. |
| 116 std::string os_version = base::SysInfo::OperatingSystemName() + ": " + | 119 std::string os_version = base::SysInfo::OperatingSystemName() + ": " + |
| 117 base::SysInfo::OperatingSystemVersion(); | 120 base::SysInfo::OperatingSystemVersion(); |
| 118 (*response)[kOsVersionTag] = os_version; | 121 (*response)[kOsVersionTag] = os_version; |
| 119 #endif | 122 #endif |
| 120 | 123 |
| 121 PopulateSyncLogs(response.get()); | 124 PopulateSyncLogs(response.get()); |
| 122 PopulateExtensionInfoLogs(response.get()); | 125 PopulateExtensionInfoLogs(response.get()); |
| 126 PopulatePowerApiLogs(response.get()); |
| 123 PopulateDataReductionProxyLogs(response.get()); | 127 PopulateDataReductionProxyLogs(response.get()); |
| 124 #if defined(OS_WIN) | 128 #if defined(OS_WIN) |
| 125 PopulateUsbKeyboardDetected(response.get()); | 129 PopulateUsbKeyboardDetected(response.get()); |
| 126 PopulateEnrolledToDomain(response.get()); | 130 PopulateEnrolledToDomain(response.get()); |
| 127 PopulateInstallerBrandCode(response.get()); | 131 PopulateInstallerBrandCode(response.get()); |
| 128 #endif | 132 #endif |
| 129 | 133 |
| 130 if (ProfileManager::GetLastUsedProfile()->IsChild()) | 134 if (ProfileManager::GetLastUsedProfile()->IsChild()) |
| 131 (*response)["account_type"] = "child"; | 135 (*response)["account_type"] = "child"; |
| 132 | 136 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 extensions_list += ",\n" + extension->name(); | 208 extensions_list += ",\n" + extension->name(); |
| 205 } | 209 } |
| 206 } | 210 } |
| 207 if (!extensions_list.empty()) | 211 if (!extensions_list.empty()) |
| 208 extensions_list += "\n"; | 212 extensions_list += "\n"; |
| 209 | 213 |
| 210 if (!extensions_list.empty()) | 214 if (!extensions_list.empty()) |
| 211 (*response)[kExtensionsListKey] = extensions_list; | 215 (*response)[kExtensionsListKey] = extensions_list; |
| 212 } | 216 } |
| 213 | 217 |
| 218 void ChromeInternalLogSource::PopulatePowerApiLogs( |
| 219 SystemLogsResponse* response) { |
| 220 std::string info; |
| 221 for (auto* profile : |
| 222 g_browser_process->profile_manager()->GetLoadedProfiles()) { |
| 223 for (const auto& it : |
| 224 extensions::PowerAPI::Get(profile)->extension_levels()) { |
| 225 if (!info.empty()) |
| 226 info += ",\n"; |
| 227 info += it.first + ": " + extensions::api::power::ToString(it.second); |
| 228 } |
| 229 } |
| 230 |
| 231 if (!info.empty()) |
| 232 (*response)[kPowerApiListKey] = info; |
| 233 } |
| 234 |
| 214 void ChromeInternalLogSource::PopulateDataReductionProxyLogs( | 235 void ChromeInternalLogSource::PopulateDataReductionProxyLogs( |
| 215 SystemLogsResponse* response) { | 236 SystemLogsResponse* response) { |
| 216 PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); | 237 PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); |
| 217 bool is_data_reduction_proxy_enabled = | 238 bool is_data_reduction_proxy_enabled = |
| 218 prefs->HasPrefPath(prefs::kDataSaverEnabled) && | 239 prefs->HasPrefPath(prefs::kDataSaverEnabled) && |
| 219 prefs->GetBoolean(prefs::kDataSaverEnabled); | 240 prefs->GetBoolean(prefs::kDataSaverEnabled); |
| 220 (*response)[kDataReductionProxyKey] = is_data_reduction_proxy_enabled ? | 241 (*response)[kDataReductionProxyKey] = is_data_reduction_proxy_enabled ? |
| 221 "enabled" : "disabled"; | 242 "enabled" : "disabled"; |
| 222 } | 243 } |
| 223 | 244 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 void ChromeInternalLogSource::PopulateInstallerBrandCode( | 283 void ChromeInternalLogSource::PopulateInstallerBrandCode( |
| 263 SystemLogsResponse* response) { | 284 SystemLogsResponse* response) { |
| 264 std::string brand; | 285 std::string brand; |
| 265 google_brand::GetBrand(&brand); | 286 google_brand::GetBrand(&brand); |
| 266 (*response)[kInstallerBrandCode] = | 287 (*response)[kInstallerBrandCode] = |
| 267 brand.empty() ? "Unknown brand code" : brand; | 288 brand.empty() ? "Unknown brand code" : brand; |
| 268 } | 289 } |
| 269 #endif | 290 #endif |
| 270 | 291 |
| 271 } // namespace system_logs | 292 } // namespace system_logs |
| OLD | NEW |