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

Unified 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: Fixed flag usage 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/extensions/networking_private_api.cc
diff --git a/chrome/browser/chromeos/extensions/networking_private_api.cc b/chrome/browser/chromeos/extensions/networking_private_api.cc
index dbafaf8a7379f8913974fdb37ada39ae22eb7189..3b8acd623bde61e9444b413c605ad5f9e8346418 100644
--- a/chrome/browser/chromeos/extensions/networking_private_api.cc
+++ b/chrome/browser/chromeos/extensions/networking_private_api.cc
@@ -63,6 +63,71 @@ void NetworkingPrivateGetPropertiesFunction::GetPropertiesFailed(
}
////////////////////////////////////////////////////////////////////////////////
+// NetworkingPrivateGetStateFunction
+
+NetworkingPrivateGetStateFunction::
+ ~NetworkingPrivateGetStateFunction() {
+}
+
+bool NetworkingPrivateGetStateFunction::RunImpl() {
+ scoped_ptr<api::GetState::Params> params =
+ api::GetState::Params::Create(*args_);
+ EXTENSION_FUNCTION_VALIDATE(params);
+ // The |network_guid| parameter is storing the service path.
+ std::string service_path = params->network_guid;
+
+ const NetworkState* state =
+ NetworkStateHandler::Get()->GetNetworkState(service_path);
+ if (!state) {
+ error_ = "Error.InvalidParameter";
stevenjb 2013/03/07 00:43:22 Should this be "InvalidParameter"? A network might
Greg Spencer (Chromium) 2013/03/07 22:01:23 Well, my thought was that the service path was no
stevenjb 2013/03/08 19:04:16 I guess I was thinking that the service could be "
+ SendResponse(false);
+ }
+
+ scoped_ptr<base::DictionaryValue> result_dict(new base::DictionaryValue);
+ state->FillDictionary(result_dict.get());
pneubeck (no reviews) 2013/03/07 13:06:18 |result_dict| has to be translated to ONC, since "
Greg Spencer (Chromium) 2013/03/07 22:01:23 Ahh, no wonder my results were off...
+ SetResult(result_dict.release());
+ SendResponse(true);
+
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// NetworkingPrivateSetPropertiesFunction
+
+NetworkingPrivateSetPropertiesFunction::
+ ~NetworkingPrivateSetPropertiesFunction() {
stevenjb 2013/03/07 00:43:22 No WS at beginning of line here I think
Greg Spencer (Chromium) 2013/03/07 22:01:23 OK. :-) I don't think there's a lot of precedent
stevenjb 2013/03/08 19:04:16 There's not a ton of precedent, but it's what I ha
+}
+
+bool NetworkingPrivateSetPropertiesFunction::RunImpl() {
+ scoped_ptr<api::SetProperties::Params> params =
+ api::SetProperties::Params::Create(*args_);
+ EXTENSION_FUNCTION_VALIDATE(params);
+
+ scoped_ptr<base::DictionaryValue> properties_dict(
+ params->properties.ToValue());
+
+ ManagedNetworkConfigurationHandler::Get()->SetProperties(
+ params->network_guid,
+ *properties_dict,
+ base::Bind(&NetworkingPrivateSetPropertiesFunction::ResultCallback,
+ this),
+ base::Bind(&NetworkingPrivateSetPropertiesFunction::ErrorCallback,
+ this));
+ return true;
+}
+
+void NetworkingPrivateSetPropertiesFunction::ErrorCallback(
+ const std::string& error_name,
+ const scoped_ptr<base::DictionaryValue> error_data) {
+ error_ = error_name;
+ SendResponse(false);
+}
+
+void NetworkingPrivateSetPropertiesFunction::ResultCallback() {
+ SendResponse(true);
+}
+
+////////////////////////////////////////////////////////////////////////////////
// NetworkingPrivateGetVisibleNetworksFunction
NetworkingPrivateGetVisibleNetworksFunction::
@@ -304,3 +369,4 @@ void NetworkingPrivateVerifyAndEncryptDataFunction::ErrorCallback(
error_ = error_name;
SendResponse(false);
}
+

Powered by Google App Engine
This is Rietveld 408576698