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

Unified Diff: chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.cc

Issue 14765003: Gets the initial sync service status. In the next patch I'll make the syncfs-internals dashboard a … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: arv review #1 Created 7 years, 7 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/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.cc
diff --git a/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.cc b/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..46c2b25dbccfb2770f771a19a5cedd530e2278db
--- /dev/null
+++ b/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.cc
@@ -0,0 +1,46 @@
+// Copyright 2013 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/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.h"
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/values.h"
+#include "chrome/browser/extensions/api/sync_file_system/sync_file_system_api_helpers.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sync_file_system/sync_file_system_service.h"
+#include "chrome/browser/sync_file_system/sync_file_system_service_factory.h"
+#include "chrome/browser/sync_file_system/sync_service_state.h"
+#include "chrome/common/extensions/api/sync_file_system.h"
+#include "content/public/browser/storage_partition.h"
+#include "content/public/browser/web_ui.h"
+
+using sync_file_system::SyncFileSystemServiceFactory;
+using sync_file_system::SyncServiceState;
+
+namespace syncfs_internals {
+
+SyncFileSystemInternalsHandler::SyncFileSystemInternalsHandler(Profile* profile)
+ : profile_(profile) {}
+
+SyncFileSystemInternalsHandler::~SyncFileSystemInternalsHandler() {}
+
+void SyncFileSystemInternalsHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "getServiceStatus",
+ base::Bind(&SyncFileSystemInternalsHandler::GetServiceStatus,
+ base::Unretained(this)));
+}
+
+void SyncFileSystemInternalsHandler::GetServiceStatus(
+ const base::ListValue* args) {
+ SyncServiceState state_enum = SyncFileSystemServiceFactory::GetForProfile(
+ profile_)->GetSyncServiceState();
+ std::string state_string = extensions::api::sync_file_system::ToString(
+ extensions::SyncServiceStateToExtensionEnum(state_enum));
+ web_ui()->CallJavascriptFunction("syncService.getServiceStatusResult",
+ base::StringValue(state_string));
+}
+
+} // namespace syncfs_internals

Powered by Google App Engine
This is Rietveld 408576698