Chromium Code Reviews| 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 "chrome/browser/feedback/feedback_data.h" | 5 #include "chrome/browser/feedback/feedback_data.h" |
| 6 | 6 |
| 7 #include "base/json/json_string_value_serializer.h" | 7 #include "base/json/json_string_value_serializer.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/browser_process.h" | |
| 10 #include "chrome/browser/chromeos/settings/cros_settings.h" | |
| 11 #include "chrome/browser/extensions/extension_service.h" | |
| 9 #include "chrome/browser/feedback/feedback_util.h" | 12 #include "chrome/browser/feedback/feedback_util.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 11 #include "chrome/browser/sync/about_sync_util.h" | 14 #include "chrome/browser/sync/about_sync_util.h" |
| 12 #include "chrome/browser/sync/profile_sync_service_factory.h" | 15 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 16 #include "chrome/common/extensions/extension.h" | |
| 17 #include "chrome/common/extensions/extension_set.h" | |
| 13 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 14 | 19 |
| 15 using content::BrowserThread; | 20 using content::BrowserThread; |
| 16 | 21 |
| 17 #if defined(OS_CHROMEOS) | 22 #if defined(OS_CHROMEOS) |
| 18 // TODO(rkc): Remove all the code that gather sync data and move it to a | 23 // TODO(rkc): Remove all the code that gather sync data and move it to a |
| 19 // log data source once crbug.com/138582 is fixed. | 24 // log data source once crbug.com/138582 is fixed. |
| 20 namespace { | 25 namespace { |
| 21 | 26 |
| 27 const char kExtensionsListKey[] = "extensions"; | |
| 28 | |
| 22 void AddSyncLogs(chromeos::system::LogDictionaryType* logs) { | 29 void AddSyncLogs(chromeos::system::LogDictionaryType* logs) { |
| 23 Profile* profile = ProfileManager::GetDefaultProfile(); | 30 Profile* profile = ProfileManager::GetDefaultProfile(); |
| 24 if (!ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService( | 31 if (!ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService( |
| 25 profile)) | 32 profile)) |
| 26 return; | 33 return; |
| 27 | 34 |
| 28 ProfileSyncService* service = | 35 ProfileSyncService* service = |
| 29 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); | 36 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); |
| 30 scoped_ptr<DictionaryValue> sync_logs( | 37 scoped_ptr<DictionaryValue> sync_logs( |
| 31 sync_ui_util::ConstructAboutInformation(service)); | 38 sync_ui_util::ConstructAboutInformation(service)); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 48 } | 55 } |
| 49 } | 56 } |
| 50 | 57 |
| 51 // Add sync logs to logs. | 58 // Add sync logs to logs. |
| 52 std::string sync_logs_string; | 59 std::string sync_logs_string; |
| 53 JSONStringValueSerializer serializer(&sync_logs_string); | 60 JSONStringValueSerializer serializer(&sync_logs_string); |
| 54 serializer.Serialize(*sync_logs.get()); | 61 serializer.Serialize(*sync_logs.get()); |
| 55 (*logs)[kSyncDataKey] = sync_logs_string; | 62 (*logs)[kSyncDataKey] = sync_logs_string; |
| 56 } | 63 } |
| 57 | 64 |
| 65 void AddExtensionInfoLogs(chromeos::system::LogDictionaryType* logs) { | |
| 66 bool reporting_enabled = false; | |
| 67 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, | |
| 68 &reporting_enabled); | |
| 69 if (!reporting_enabled) | |
| 70 return; | |
| 71 | |
| 72 Profile* default_profile = | |
| 73 g_browser_process->profile_manager()->GetDefaultProfile(); | |
| 74 if (!default_profile) | |
| 75 return; | |
| 76 | |
| 77 ExtensionService* service = default_profile->GetExtensionService(); | |
|
tbarzic
2012/12/11 02:47:57
Actually, this should be extensions::ExtensionSyst
rkc
2012/12/11 02:50:39
Done.
| |
| 78 if (!service) | |
| 79 return; | |
| 80 | |
| 81 std::string extensions_list; | |
| 82 const ExtensionSet* extensions = service->extensions(); | |
| 83 for (ExtensionSet::const_iterator it = extensions->begin(); | |
| 84 it != extensions->end(); | |
| 85 ++it) { | |
| 86 const extensions::Extension* extension = *it; | |
| 87 if (extensions_list.empty()) { | |
| 88 extensions_list = extension->name(); | |
| 89 } else { | |
| 90 extensions_list += ", " + extension->name(); | |
| 91 } | |
| 92 } | |
| 93 | |
| 94 if (!extensions_list.empty()) | |
| 95 (*logs)[kExtensionsListKey] = extensions_list; | |
| 96 } | |
| 97 | |
| 58 } | 98 } |
| 59 #endif // OS_CHROMEOS | 99 #endif // OS_CHROMEOS |
| 60 | 100 |
| 61 FeedbackData::FeedbackData() | 101 FeedbackData::FeedbackData() |
| 62 : profile_(NULL) | 102 : profile_(NULL) |
| 63 #if defined(OS_CHROMEOS) | 103 #if defined(OS_CHROMEOS) |
| 64 , sys_info_(NULL) | 104 , sys_info_(NULL) |
| 65 , zip_content_(NULL) | 105 , zip_content_(NULL) |
| 66 , sent_report_(false) | 106 , sent_report_(false) |
| 67 , send_sys_info_(false) | 107 , send_sys_info_(false) |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 if (sent_report_) { | 191 if (sent_report_) { |
| 152 // We already sent the report, just delete the data. | 192 // We already sent the report, just delete the data. |
| 153 if (logs) | 193 if (logs) |
| 154 delete logs; | 194 delete logs; |
| 155 if (zip_content) | 195 if (zip_content) |
| 156 delete zip_content; | 196 delete zip_content; |
| 157 } else { | 197 } else { |
| 158 | 198 |
| 159 // TODO(rkc): Move to the correct place once crbug.com/138582 is done. | 199 // TODO(rkc): Move to the correct place once crbug.com/138582 is done. |
| 160 AddSyncLogs(logs); | 200 AddSyncLogs(logs); |
| 201 AddExtensionInfoLogs(logs); | |
| 161 | 202 |
| 162 // Will get deleted when SendReport() is called. | 203 // Will get deleted when SendReport() is called. |
| 163 zip_content_ = zip_content; | 204 zip_content_ = zip_content; |
| 164 sys_info_ = logs; | 205 sys_info_ = logs; |
| 165 | 206 |
| 166 if (send_sys_info_) { | 207 if (send_sys_info_) { |
| 167 // We already prepared the report, send it now. | 208 // We already prepared the report, send it now. |
| 168 this->SendReport(); | 209 this->SendReport(); |
| 169 } | 210 } |
| 170 } | 211 } |
| 171 } | 212 } |
| 172 #endif | 213 #endif |
| OLD | NEW |