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

Unified Diff: chrome/browser/chromeos/system_logs/chrome_internal_log_source.cc

Issue 12529024: Fix feedback log collection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/system_logs/chrome_internal_log_source.cc
diff --git a/chrome/browser/chromeos/system_logs/chrome_internal_log_source.cc b/chrome/browser/chromeos/system_logs/chrome_internal_log_source.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5375012d9497da715ed58dbb2c0a0d596813d328
--- /dev/null
+++ b/chrome/browser/chromeos/system_logs/chrome_internal_log_source.cc
@@ -0,0 +1,109 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/system_logs/chrome_internal_log_source.h"
+
+#include "base/json/json_string_value_serializer.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chromeos/settings/cros_settings.h"
+#include "chrome/browser/chromeos/system_logs/system_logs_fetcher.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/sync/about_sync_util.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/extension_set.h"
+#include "content/public/browser/browser_thread.h"
+
+
+const char kSyncDataKey[] = "about_sync_data";
+const char kExtensionsListKey[] = "extensions";
+
+namespace chromeos {
+
+void ChromeInternalLogSource::Fetch(const SysLogsSourceCallback& callback) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
+ SystemLogsResponse response;
+ PopulateSyncLogs(&response);
+ PopulateExtensionInfoLogs(&response);
+
+ callback.Run(&response);
+}
+
+void ChromeInternalLogSource::PopulateSyncLogs(SystemLogsResponse* response) {
+ Profile* profile = ProfileManager::GetDefaultProfile();
+ if (!ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService(
+ profile))
+ return;
+
+ ProfileSyncService* service =
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
+ scoped_ptr<base::DictionaryValue> sync_logs(
+ sync_ui_util::ConstructAboutInformation(service));
+
+ // Remove credentials section.
+ base::ListValue* details = NULL;
+ sync_logs->GetList(kDetailsKey, &details);
+ if (!details)
+ return;
+ for (base::ListValue::iterator it = details->begin();
+ it != details->end(); ++it) {
+ base::DictionaryValue* dict = NULL;
+ if ((*it)->GetAsDictionary(&dict)) {
+ std::string title;
+ dict->GetString("title", &title);
+ if (title == kCredentialsTitle) {
+ details->Erase(it, NULL);
+ break;
+ }
+ }
+ }
+
+ // Add sync logs to logs.
+ std::string sync_logs_string;
+ JSONStringValueSerializer serializer(&sync_logs_string);
+ serializer.Serialize(*sync_logs.get());
+
+ (*response)[kSyncDataKey] = sync_logs_string;
+}
+
+void ChromeInternalLogSource::PopulateExtensionInfoLogs(
+ SystemLogsResponse* response) {
+ bool reporting_enabled = false;
+ chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref,
+ &reporting_enabled);
+ if (!reporting_enabled)
+ return;
+
+ Profile* default_profile =
+ g_browser_process->profile_manager()->GetDefaultProfile();
+ if (!default_profile)
+ return;
+
+ ExtensionService* service =
+ extensions::ExtensionSystem::Get(default_profile)->extension_service();
+ if (!service)
+ return;
+
+ std::string extensions_list;
+ const ExtensionSet* extensions = service->extensions();
+ for (ExtensionSet::const_iterator it = extensions->begin();
+ it != extensions->end();
+ ++it) {
+ const extensions::Extension* extension = *it;
+ if (extensions_list.empty()) {
+ extensions_list = extension->name();
+ } else {
+ extensions_list += ", " + extension->name();
+ }
+ }
+
+ if (!extensions_list.empty())
+ (*response)[kExtensionsListKey] = extensions_list;
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698