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