| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_
handler.h" |
| 6 |
| 7 #include <map> |
| 8 |
| 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" |
| 11 #include "base/values.h" |
| 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/sync_file_system/sync_file_system_service.h" |
| 14 #include "chrome/browser/sync_file_system/sync_file_system_service_factory.h" |
| 15 #include "content/public/browser/web_ui.h" |
| 16 #include "content/public/browser/web_ui_data_source.h" |
| 17 #include "grit/sync_file_system_internals_resources.h" |
| 18 |
| 19 using sync_file_system::SyncFileSystemServiceFactory; |
| 20 using sync_file_system::SyncServiceState; |
| 21 |
| 22 namespace syncfs_internals { |
| 23 |
| 24 ExtensionStatusesHandler::ExtensionStatusesHandler(Profile* profile) |
| 25 : profile_(profile) {} |
| 26 |
| 27 ExtensionStatusesHandler::~ExtensionStatusesHandler() {} |
| 28 |
| 29 void ExtensionStatusesHandler::RegisterMessages() { |
| 30 web_ui()->RegisterMessageCallback( |
| 31 "getExtensionStatuses", |
| 32 base::Bind(&ExtensionStatusesHandler::GetExtensionStatuses, |
| 33 base::Unretained(this))); |
| 34 } |
| 35 |
| 36 void ExtensionStatusesHandler::GetExtensionStatuses( |
| 37 const base::ListValue* args) { |
| 38 DCHECK(args); |
| 39 std::map<GURL, std::string> status_map; |
| 40 SyncFileSystemServiceFactory::GetForProfile(profile_)->GetExtensionStatusMap( |
| 41 &status_map); |
| 42 |
| 43 base::ListValue list; |
| 44 for (std::map<GURL, std::string>::const_iterator itr = status_map.begin(); |
| 45 itr != status_map.end(); |
| 46 ++itr) { |
| 47 base::DictionaryValue* dict = new DictionaryValue; |
| 48 dict->SetString("extensionID", itr->first.spec()); |
| 49 dict->SetString("status", itr->second); |
| 50 list.Append(dict); |
| 51 } |
| 52 |
| 53 web_ui()->CallJavascriptFunction("ExtensionStatuses.onGetExtensionStatuses", |
| 54 list); |
| 55 } |
| 56 |
| 57 } // namespace syncfs_internals |
| OLD | NEW |