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

Side by Side Diff: chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.cc

Issue 2399423004: [Extensions] Convert some ChromeSyncExtensionFunctions (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/extensions/api/signed_in_devices/signed_in_devices_api. h" 5 #include "chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api. h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 106 }
107 107
108 LocalDeviceInfoProvider* local_device = pss->GetLocalDeviceInfoProvider(); 108 LocalDeviceInfoProvider* local_device = pss->GetLocalDeviceInfoProvider();
109 DCHECK(local_device); 109 DCHECK(local_device);
110 std::string guid = local_device->GetLocalSyncCacheGUID(); 110 std::string guid = local_device->GetLocalSyncCacheGUID();
111 std::unique_ptr<DeviceInfo> device = 111 std::unique_ptr<DeviceInfo> device =
112 GetDeviceInfoForClientId(guid, extension_id, profile); 112 GetDeviceInfoForClientId(guid, extension_id, profile);
113 return device; 113 return device;
114 } 114 }
115 115
116 bool SignedInDevicesGetFunction::RunSync() { 116 ExtensionFunction::ResponseAction SignedInDevicesGetFunction::Run() {
117 std::unique_ptr<api::signed_in_devices::Get::Params> params( 117 std::unique_ptr<api::signed_in_devices::Get::Params> params(
118 api::signed_in_devices::Get::Params::Create(*args_)); 118 api::signed_in_devices::Get::Params::Create(*args_));
119 EXTENSION_FUNCTION_VALIDATE(params.get()); 119 EXTENSION_FUNCTION_VALIDATE(params.get());
120 120
121 bool is_local = params->is_local.get() ? *params->is_local : false; 121 bool is_local = params->is_local.get() ? *params->is_local : false;
122 122
123 Profile* profile = Profile::FromBrowserContext(browser_context());
123 if (is_local) { 124 if (is_local) {
124 std::unique_ptr<DeviceInfo> device = 125 std::unique_ptr<DeviceInfo> device =
125 GetLocalDeviceInfo(extension_id(), GetProfile()); 126 GetLocalDeviceInfo(extension_id(), profile);
126 std::unique_ptr<base::ListValue> result(new base::ListValue()); 127 std::unique_ptr<base::ListValue> result(new base::ListValue());
127 if (device.get()) { 128 if (device.get()) {
128 result->Append(device->ToValue()); 129 result->Append(device->ToValue());
129 } 130 }
130 SetResult(std::move(result)); 131 return RespondNow(OneArgument(std::move(result)));
131 return true;
132 } 132 }
133 133
134 std::vector<std::unique_ptr<DeviceInfo>> devices = 134 std::vector<std::unique_ptr<DeviceInfo>> devices =
135 GetAllSignedInDevices(extension_id(), GetProfile()); 135 GetAllSignedInDevices(extension_id(), profile);
136 136
137 std::unique_ptr<base::ListValue> result(new base::ListValue()); 137 std::unique_ptr<base::ListValue> result(new base::ListValue());
138 138
139 for (const std::unique_ptr<DeviceInfo>& device : devices) 139 for (const std::unique_ptr<DeviceInfo>& device : devices)
140 result->Append(device->ToValue()); 140 result->Append(device->ToValue());
141 141
142 SetResult(std::move(result)); 142 return RespondNow(OneArgument(std::move(result)));
143 return true;
144 } 143 }
145 144
146 } // namespace extensions 145 } // namespace extensions
147 146
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698