Chromium Code Reviews| Index: chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.cc |
| diff --git a/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.cc b/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..10c157ab21a5896ca33cc285789eeb2a2f907688 |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.cc |
| @@ -0,0 +1,57 @@ |
| +// 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/extension_statuses_handler.h" |
| + |
| +#include <map> |
| + |
| +#include "base/bind.h" |
| +#include "base/bind_helpers.h" |
| +#include "base/values.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 "content/public/browser/web_ui.h" |
| +#include "content/public/browser/web_ui_data_source.h" |
| +#include "grit/sync_file_system_internals_resources.h" |
| + |
| +using sync_file_system::SyncFileSystemServiceFactory; |
| +using sync_file_system::SyncServiceState; |
| + |
| +namespace syncfs_internals { |
| + |
| +ExtensionStatusesHandler::ExtensionStatusesHandler(Profile* profile) |
| + : profile_(profile) {} |
| + |
| +ExtensionStatusesHandler::~ExtensionStatusesHandler() {} |
| + |
| +void ExtensionStatusesHandler::RegisterMessages() { |
| + web_ui()->RegisterMessageCallback( |
| + "getExtensionStatuses", |
| + base::Bind(&ExtensionStatusesHandler::GetExtensionStatuses, |
| + base::Unretained(this))); |
| +} |
| + |
| +void ExtensionStatusesHandler::GetExtensionStatuses( |
| + const base::ListValue* args) { |
|
nhiroki
2013/06/07 06:31:25
Can you add "DCHECK(args);"?
calvinlo
2013/06/07 06:40:29
Done.
|
| + std::map<GURL, std::string> status_map; |
| + SyncFileSystemServiceFactory::GetForProfile(profile_)->GetExtensionStatusMap( |
| + &status_map); |
| + |
| + base::ListValue list; |
| + for (std::map<GURL, std::string>::const_iterator itr = status_map.begin(); |
| + itr != status_map.end(); |
| + ++itr) { |
| + base::DictionaryValue* dict = new DictionaryValue; |
|
nhiroki
2013/06/07 06:31:25
nit: indent
calvinlo
2013/06/07 06:40:29
Done.
|
| + dict->SetString("extensionID", itr->first.spec()); |
| + dict->SetString("status", itr->second); |
| + list.Append(dict); |
| + } |
| + |
| + LOG(ERROR) << "GOT TO HERE list.size=" << status_map.size(); |
|
nhiroki
2013/06/07 06:31:25
Is this for debugging?
calvinlo
2013/06/07 06:40:29
Done. Sorry, forgot to take this out.
|
| + web_ui()->CallJavascriptFunction("extensionStatuses.onGetExtensionStatuses", |
| + list); |
| +} |
| + |
| +} // namespace syncfs_internals |