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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 74 } |
75 | 75 |
76 // static | 76 // static |
77 void ExtensionStatusesHandler::GetExtensionStatusesAsDictionary( | 77 void ExtensionStatusesHandler::GetExtensionStatusesAsDictionary( |
78 Profile* profile, | 78 Profile* profile, |
79 const base::Callback<void(const base::ListValue&)>& callback) { | 79 const base::Callback<void(const base::ListValue&)>& callback) { |
80 DCHECK(profile); | 80 DCHECK(profile); |
81 | 81 |
82 sync_file_system::SyncFileSystemService* sync_service = | 82 sync_file_system::SyncFileSystemService* sync_service = |
83 SyncFileSystemServiceFactory::GetForProfile(profile); | 83 SyncFileSystemServiceFactory::GetForProfile(profile); |
84 if (!sync_service) | 84 if (!sync_service) { |
| 85 callback.Run(base::ListValue()); |
85 return; | 86 return; |
| 87 } |
86 | 88 |
87 ExtensionService* extension_service = | 89 ExtensionService* extension_service = |
88 extensions::ExtensionSystem::Get(profile)->extension_service(); | 90 extensions::ExtensionSystem::Get(profile)->extension_service(); |
89 if (!extension_service) | 91 if (!extension_service) { |
| 92 callback.Run(base::ListValue()); |
90 return; | 93 return; |
| 94 } |
91 | 95 |
92 sync_service->GetExtensionStatusMap(base::Bind( | 96 sync_service->GetExtensionStatusMap(base::Bind( |
93 &ConvertExtensionStatusToDictionary, | 97 &ConvertExtensionStatusToDictionary, |
94 extension_service->AsWeakPtr(), callback)); | 98 extension_service->AsWeakPtr(), callback)); |
95 } | 99 } |
96 | 100 |
97 void ExtensionStatusesHandler::GetExtensionStatuses( | 101 void ExtensionStatusesHandler::GetExtensionStatuses( |
98 const base::ListValue* args) { | 102 const base::ListValue* args) { |
99 DCHECK(args); | 103 DCHECK(args); |
100 GetExtensionStatusesAsDictionary( | 104 GetExtensionStatusesAsDictionary( |
101 profile_, | 105 profile_, |
102 base::Bind(&ExtensionStatusesHandler::DidGetExtensionStatuses, | 106 base::Bind(&ExtensionStatusesHandler::DidGetExtensionStatuses, |
103 weak_ptr_factory_.GetWeakPtr())); | 107 weak_ptr_factory_.GetWeakPtr())); |
104 } | 108 } |
105 | 109 |
106 void ExtensionStatusesHandler::DidGetExtensionStatuses( | 110 void ExtensionStatusesHandler::DidGetExtensionStatuses( |
107 const base::ListValue& list) { | 111 const base::ListValue& list) { |
108 web_ui()->CallJavascriptFunction("ExtensionStatuses.onGetExtensionStatuses", | 112 web_ui()->CallJavascriptFunction("ExtensionStatuses.onGetExtensionStatuses", |
109 list); | 113 list); |
110 } | 114 } |
111 | 115 |
112 } // namespace syncfs_internals | 116 } // namespace syncfs_internals |
OLD | NEW |