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

Side by Side Diff: extensions/browser/api/networking_config/networking_config_service.cc

Issue 1226353004: Generate all extension schema namespaces as "api" and instead vary the generated bundle names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <algorithm> 5 #include <algorithm>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 const std::string& extension_id, 175 const std::string& extension_id,
176 const std::string& guid, 176 const std::string& guid,
177 const std::string* bssid) { 177 const std::string* bssid) {
178 const chromeos::NetworkState* network = chromeos::NetworkHandler::Get() 178 const chromeos::NetworkState* network = chromeos::NetworkHandler::Get()
179 ->network_state_handler() 179 ->network_state_handler()
180 ->GetNetworkStateFromGuid(guid); 180 ->GetNetworkStateFromGuid(guid);
181 if (!network) 181 if (!network)
182 return nullptr; 182 return nullptr;
183 183
184 // Populate the NetworkInfo object. 184 // Populate the NetworkInfo object.
185 core_api::networking_config::NetworkInfo network_info; 185 api::networking_config::NetworkInfo network_info;
186 network_info.type = core_api::networking_config::NETWORK_TYPE_WIFI; 186 network_info.type = api::networking_config::NETWORK_TYPE_WIFI;
187 const std::vector<uint8_t>& raw_ssid = network->raw_ssid(); 187 const std::vector<uint8_t>& raw_ssid = network->raw_ssid();
188 std::string hex_ssid = 188 std::string hex_ssid =
189 base::HexEncode(vector_as_array(&raw_ssid), raw_ssid.size()); 189 base::HexEncode(vector_as_array(&raw_ssid), raw_ssid.size());
190 network_info.hex_ssid = make_scoped_ptr(new std::string(hex_ssid)); 190 network_info.hex_ssid = make_scoped_ptr(new std::string(hex_ssid));
191 network_info.ssid = make_scoped_ptr(new std::string(network->name())); 191 network_info.ssid = make_scoped_ptr(new std::string(network->name()));
192 network_info.guid = make_scoped_ptr(new std::string(network->guid())); 192 network_info.guid = make_scoped_ptr(new std::string(network->guid()));
193 if (bssid) 193 if (bssid)
194 network_info.bssid.reset(new std::string(*bssid)); 194 network_info.bssid.reset(new std::string(*bssid));
195 scoped_ptr<base::ListValue> results = 195 scoped_ptr<base::ListValue> results =
196 core_api::networking_config::OnCaptivePortalDetected::Create( 196 api::networking_config::OnCaptivePortalDetected::Create(network_info);
197 network_info); 197 scoped_ptr<Event> event(
198 scoped_ptr<Event> event(new Event( 198 new Event(events::NETWORKING_CONFIG_ON_CAPTIVE_PORTAL_DETECTED,
199 events::NETWORKING_CONFIG_ON_CAPTIVE_PORTAL_DETECTED, 199 api::networking_config::OnCaptivePortalDetected::kEventName,
200 core_api::networking_config::OnCaptivePortalDetected::kEventName, 200 results.Pass()));
201 results.Pass()));
202 return event.Pass(); 201 return event.Pass();
203 } 202 }
204 203
205 void NetworkingConfigService::DispatchPortalDetectedEvent( 204 void NetworkingConfigService::DispatchPortalDetectedEvent(
206 const std::string& extension_id, 205 const std::string& extension_id,
207 const std::string& guid, 206 const std::string& guid,
208 const base::Closure& authentication_callback) { 207 const base::Closure& authentication_callback) {
209 // This dispatch starts a new cycle of portal detection and authentication. 208 // This dispatch starts a new cycle of portal detection and authentication.
210 // Ensure that any old |authentication_callback_| is dropped. 209 // Ensure that any old |authentication_callback_| is dropped.
211 authentication_callback_.Reset(); 210 authentication_callback_.Reset();
212 211
213 // Determine |service_path| of network identified by |guid|. 212 // Determine |service_path| of network identified by |guid|.
214 chromeos::NetworkHandler* network_handler = chromeos::NetworkHandler::Get(); 213 chromeos::NetworkHandler* network_handler = chromeos::NetworkHandler::Get();
215 const chromeos::NetworkState* network = 214 const chromeos::NetworkState* network =
216 network_handler->network_state_handler()->GetNetworkStateFromGuid(guid); 215 network_handler->network_state_handler()->GetNetworkStateFromGuid(guid);
217 if (!network) 216 if (!network)
218 return; 217 return;
219 const std::string service_path = network->path(); 218 const std::string service_path = network->path();
220 219
221 network_handler->managed_network_configuration_handler()->GetProperties( 220 network_handler->managed_network_configuration_handler()->GetProperties(
222 service_path, base::Bind(&NetworkingConfigService::OnGotProperties, 221 service_path, base::Bind(&NetworkingConfigService::OnGotProperties,
223 weak_factory_.GetWeakPtr(), extension_id, guid, 222 weak_factory_.GetWeakPtr(), extension_id, guid,
224 authentication_callback), 223 authentication_callback),
225 base::Bind(&NetworkingConfigService::OnGetPropertiesFailed, 224 base::Bind(&NetworkingConfigService::OnGetPropertiesFailed,
226 weak_factory_.GetWeakPtr(), extension_id, guid)); 225 weak_factory_.GetWeakPtr(), extension_id, guid));
227 } 226 }
228 227
229 } // namespace extensions 228 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698