Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/ui/webui/sync_file_system_internals/extension_statuses_ handler.h" | 5 #include "chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_ handler.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 using sync_file_system::SyncServiceState; | 24 using sync_file_system::SyncServiceState; |
| 25 | 25 |
| 26 namespace syncfs_internals { | 26 namespace syncfs_internals { |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 void ConvertExtensionStatusToDictionary( | 30 void ConvertExtensionStatusToDictionary( |
| 31 const base::WeakPtr<ExtensionService>& extension_service, | 31 const base::WeakPtr<ExtensionService>& extension_service, |
| 32 const base::Callback<void(const base::ListValue&)>& callback, | 32 const base::Callback<void(const base::ListValue&)>& callback, |
| 33 const std::map<GURL, std::string>& status_map) { | 33 const std::map<GURL, std::string>& status_map) { |
| 34 DCHECK(!extension_service); | 34 if (!extension_service) { |
| 35 callback.Run(base::ListValue()); | |
| 36 return; | |
| 37 } | |
| 35 | 38 |
| 36 base::ListValue list; | 39 base::ListValue list; |
| 37 for (std::map<GURL, std::string>::const_iterator itr = status_map.begin(); | 40 for (std::map<GURL, std::string>::const_iterator itr = status_map.begin(); |
| 38 itr != status_map.end(); | 41 itr != status_map.end(); |
| 39 ++itr) { | 42 ++itr) { |
| 40 std::string extension_id = itr->first.HostNoBrackets(); | 43 std::string extension_id = itr->first.HostNoBrackets(); |
| 41 | 44 |
| 42 // Join with human readable extension name. | 45 // Join with human readable extension name. |
| 43 const extensions::Extension* extension = | 46 const extensions::Extension* extension = |
| 44 extension_service->GetExtensionById(extension_id, true); | 47 extension_service->GetExtensionById(extension_id, true); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 71 } | 74 } |
| 72 | 75 |
| 73 // static | 76 // static |
| 74 void ExtensionStatusesHandler::GetExtensionStatusesAsDictionary( | 77 void ExtensionStatusesHandler::GetExtensionStatusesAsDictionary( |
| 75 Profile* profile, | 78 Profile* profile, |
| 76 const base::Callback<void(const base::ListValue&)>& callback) { | 79 const base::Callback<void(const base::ListValue&)>& callback) { |
| 77 DCHECK(profile); | 80 DCHECK(profile); |
| 78 | 81 |
| 79 sync_file_system::SyncFileSystemService* sync_service = | 82 sync_file_system::SyncFileSystemService* sync_service = |
| 80 SyncFileSystemServiceFactory::GetForProfile(profile); | 83 SyncFileSystemServiceFactory::GetForProfile(profile); |
| 81 if (!sync_service) | 84 if (!sync_service) |
|
nhiroki
2014/05/27 09:04:32
Is it okay to ignore |callback|?
tzik
2014/05/27 12:54:12
Hmm?
No. It should handle. Let me do later.
| |
| 82 return; | 85 return; |
| 83 | 86 |
| 84 ExtensionService* extension_service = | 87 ExtensionService* extension_service = |
| 85 extensions::ExtensionSystem::Get(profile)->extension_service(); | 88 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 86 if (!extension_service) | 89 if (!extension_service) |
|
nhiroki
2014/05/27 09:04:32
ditto.
| |
| 87 return; | 90 return; |
| 88 | 91 |
| 89 sync_service->GetExtensionStatusMap(base::Bind( | 92 sync_service->GetExtensionStatusMap(base::Bind( |
| 90 &ConvertExtensionStatusToDictionary, | 93 &ConvertExtensionStatusToDictionary, |
| 91 extension_service->AsWeakPtr(), callback)); | 94 extension_service->AsWeakPtr(), callback)); |
| 92 } | 95 } |
| 93 | 96 |
| 94 void ExtensionStatusesHandler::GetExtensionStatuses( | 97 void ExtensionStatusesHandler::GetExtensionStatuses( |
| 95 const base::ListValue* args) { | 98 const base::ListValue* args) { |
| 96 DCHECK(args); | 99 DCHECK(args); |
| 97 GetExtensionStatusesAsDictionary( | 100 GetExtensionStatusesAsDictionary( |
| 98 profile_, | 101 profile_, |
| 99 base::Bind(&ExtensionStatusesHandler::DidGetExtensionStatuses, | 102 base::Bind(&ExtensionStatusesHandler::DidGetExtensionStatuses, |
| 100 weak_ptr_factory_.GetWeakPtr())); | 103 weak_ptr_factory_.GetWeakPtr())); |
| 101 } | 104 } |
| 102 | 105 |
| 103 void ExtensionStatusesHandler::DidGetExtensionStatuses( | 106 void ExtensionStatusesHandler::DidGetExtensionStatuses( |
| 104 const base::ListValue& list) { | 107 const base::ListValue& list) { |
| 105 web_ui()->CallJavascriptFunction("ExtensionStatuses.onGetExtensionStatuses", | 108 web_ui()->CallJavascriptFunction("ExtensionStatuses.onGetExtensionStatuses", |
| 106 list); | 109 list); |
| 107 } | 110 } |
| 108 | 111 |
| 109 } // namespace syncfs_internals | 112 } // namespace syncfs_internals |
| OLD | NEW |