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

Side by Side Diff: chrome/browser/chromeos/extensions/networking_private_api.cc

Issue 12541007: This adds the setProperties and getState functions to the networking API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Upload after merge Created 7 years, 9 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 | Annotate | Revision Log
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/chromeos/extensions/networking_private_api.h" 5 #include "chrome/browser/chromeos/extensions/networking_private_api.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "chrome/browser/chromeos/net/managed_network_configuration_handler.h" 10 #include "chrome/browser/chromeos/net/managed_network_configuration_handler.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 57
58 void NetworkingPrivateGetPropertiesFunction::GetPropertiesFailed( 58 void NetworkingPrivateGetPropertiesFunction::GetPropertiesFailed(
59 const std::string& error_name, 59 const std::string& error_name,
60 scoped_ptr<base::DictionaryValue> error_data) { 60 scoped_ptr<base::DictionaryValue> error_data) {
61 error_ = error_name; 61 error_ = error_name;
62 SendResponse(false); 62 SendResponse(false);
63 } 63 }
64 64
65 //////////////////////////////////////////////////////////////////////////////// 65 ////////////////////////////////////////////////////////////////////////////////
66 // NetworkingPrivateGetStateFunction
67
68 NetworkingPrivateGetStateFunction::
69 ~NetworkingPrivateGetStateFunction() {
70 }
71
72 bool NetworkingPrivateGetStateFunction::RunImpl() {
73 scoped_ptr<api::GetState::Params> params =
74 api::GetState::Params::Create(*args_);
75 EXTENSION_FUNCTION_VALIDATE(params);
76 // The |network_guid| parameter is storing the service path.
77 std::string service_path = params->network_guid;
78
79 const NetworkState* state =
80 NetworkStateHandler::Get()->GetNetworkState(service_path);
81 if (!state) {
82 error_ = "Error.InvalidParameter";
83 SendResponse(false);
84 }
85
86 scoped_ptr<base::DictionaryValue> result_dict(new base::DictionaryValue);
87 state->GetProperties(result_dict.get());
88 scoped_ptr<base::DictionaryValue> onc_network_part =
89 onc::TranslateShillServiceToONCPart(*result_dict,
90 &onc::kNetworkWithStateSignature);
91 SetResult(onc_network_part.release());
92 SendResponse(true);
93
94 return true;
95 }
96
97 ////////////////////////////////////////////////////////////////////////////////
98 // NetworkingPrivateSetPropertiesFunction
99
100 NetworkingPrivateSetPropertiesFunction::
101 ~NetworkingPrivateSetPropertiesFunction() {
102 }
103
104 bool NetworkingPrivateSetPropertiesFunction::RunImpl() {
105 scoped_ptr<api::SetProperties::Params> params =
106 api::SetProperties::Params::Create(*args_);
107 EXTENSION_FUNCTION_VALIDATE(params);
108
109 scoped_ptr<base::DictionaryValue> properties_dict(
110 params->properties.ToValue());
111
112 ManagedNetworkConfigurationHandler::Get()->SetProperties(
113 params->network_guid,
114 *properties_dict,
115 base::Bind(&NetworkingPrivateSetPropertiesFunction::ResultCallback,
116 this),
117 base::Bind(&NetworkingPrivateSetPropertiesFunction::ErrorCallback,
118 this));
119 return true;
120 }
121
122 void NetworkingPrivateSetPropertiesFunction::ErrorCallback(
123 const std::string& error_name,
124 const scoped_ptr<base::DictionaryValue> error_data) {
125 error_ = error_name;
126 SendResponse(false);
127 }
128
129 void NetworkingPrivateSetPropertiesFunction::ResultCallback() {
130 SendResponse(true);
131 }
132
133 ////////////////////////////////////////////////////////////////////////////////
66 // NetworkingPrivateGetVisibleNetworksFunction 134 // NetworkingPrivateGetVisibleNetworksFunction
67 135
68 NetworkingPrivateGetVisibleNetworksFunction:: 136 NetworkingPrivateGetVisibleNetworksFunction::
69 ~NetworkingPrivateGetVisibleNetworksFunction() { 137 ~NetworkingPrivateGetVisibleNetworksFunction() {
70 } 138 }
71 139
72 bool NetworkingPrivateGetVisibleNetworksFunction::RunImpl() { 140 bool NetworkingPrivateGetVisibleNetworksFunction::RunImpl() {
73 scoped_ptr<api::GetVisibleNetworks::Params> params = 141 scoped_ptr<api::GetVisibleNetworks::Params> params =
74 api::GetVisibleNetworks::Params::Create(*args_); 142 api::GetVisibleNetworks::Params::Create(*args_);
75 EXTENSION_FUNCTION_VALIDATE(params); 143 EXTENSION_FUNCTION_VALIDATE(params);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 const std::string& result) { 361 const std::string& result) {
294 results_ = api::VerifyAndEncryptData::Results::Create(result); 362 results_ = api::VerifyAndEncryptData::Results::Create(result);
295 SendResponse(true); 363 SendResponse(true);
296 } 364 }
297 365
298 void NetworkingPrivateVerifyAndEncryptDataFunction::ErrorCallback( 366 void NetworkingPrivateVerifyAndEncryptDataFunction::ErrorCallback(
299 const std::string& error_name, const std::string& error) { 367 const std::string& error_name, const std::string& error) {
300 error_ = error_name; 368 error_ = error_name;
301 SendResponse(false); 369 SendResponse(false);
302 } 370 }
371
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698