buffet: Add the ability to change command visibility

Now it is possible to change the visibility of command and make it
visible to cloud only, local only, both or none.

BUG=brillo:797
TEST=`FEATURES=test emerge-link buffet`

Change-Id: I81d526b3d43adf5d6cd03a4e31a31e1494ff5c1b
Reviewed-on: https://chromium-review.googlesource.com/266396
Trybot-Ready: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Vitaly Buka <vitalybuka@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/buffet/manager.cc b/buffet/manager.cc
index 860e880..b83ccb9 100644
--- a/buffet/manager.cc
+++ b/buffet/manager.cc
@@ -22,6 +22,7 @@
 #include <dbus/values_util.h>
 
 #include "buffet/commands/command_instance.h"
+#include "buffet/commands/schema_constants.h"
 #include "buffet/states/state_change_queue.h"
 #include "buffet/states/state_manager.h"
 #include "buffet/storage_impls.h"
@@ -207,6 +208,23 @@
   response->Return(command_str);
 }
 
+void Manager::SetCommandVisibility(
+    scoped_ptr<chromeos::dbus_utils::DBusMethodResponse<>> response,
+    const std::vector<std::string>& in_names,
+    const std::string& in_visibility) {
+  CommandDefinition::Visibility visibility;
+  chromeos::ErrorPtr error;
+  if (!visibility.FromString(in_visibility, &error)) {
+    response->ReplyWithError(error.get());
+    return;
+  }
+  if (!command_manager_->SetCommandVisibility(in_names, visibility, &error)) {
+    response->ReplyWithError(error.get());
+    return;
+  }
+  response->Return();
+}
+
 std::string Manager::TestMethod(const std::string& message) {
   LOG(INFO) << "Received call to test method: " << message;
   return message;