| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "remoting/host/it2me/it2me_native_messaging_host.h" | 5 #include "remoting/host/it2me/it2me_native_messaging_host.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/callback_helpers.h" | 13 #include "base/callback_helpers.h" |
| 14 #include "base/json/json_reader.h" | 14 #include "base/json/json_reader.h" |
| 15 #include "base/json/json_writer.h" | 15 #include "base/json/json_writer.h" |
| 16 #include "base/memory/ptr_util.h" |
| 16 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 17 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 19 #include "base/strings/stringize_macros.h" | 20 #include "base/strings/stringize_macros.h" |
| 20 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
| 21 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 22 #include "base/values.h" | 23 #include "base/values.h" |
| 23 #include "build/build_config.h" | 24 #include "build/build_config.h" |
| 24 #include "components/policy/policy_constants.h" | 25 #include "components/policy/policy_constants.h" |
| 25 #include "net/base/url_util.h" | 26 #include "net/base/url_util.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 return; | 127 return; |
| 127 } | 128 } |
| 128 | 129 |
| 129 std::unique_ptr<base::DictionaryValue> message_dict( | 130 std::unique_ptr<base::DictionaryValue> message_dict( |
| 130 static_cast<base::DictionaryValue*>(message_value.release())); | 131 static_cast<base::DictionaryValue*>(message_value.release())); |
| 131 | 132 |
| 132 // If the client supplies an ID, it will expect it in the response. This | 133 // If the client supplies an ID, it will expect it in the response. This |
| 133 // might be a string or a number, so cope with both. | 134 // might be a string or a number, so cope with both. |
| 134 const base::Value* id; | 135 const base::Value* id; |
| 135 if (message_dict->Get("id", &id)) | 136 if (message_dict->Get("id", &id)) |
| 136 response->Set("id", id->CreateDeepCopy()); | 137 response->Set("id", base::MakeUnique<base::Value>(*id)); |
| 137 | 138 |
| 138 std::string type; | 139 std::string type; |
| 139 if (!message_dict->GetString("type", &type)) { | 140 if (!message_dict->GetString("type", &type)) { |
| 140 SendErrorAndExit(std::move(response), "'type' not found in request."); | 141 SendErrorAndExit(std::move(response), "'type' not found in request."); |
| 141 return; | 142 return; |
| 142 } | 143 } |
| 143 | 144 |
| 144 response->SetString("type", type + "Response"); | 145 response->SetString("type", type + "Response"); |
| 145 | 146 |
| 146 if (type == "hello") { | 147 if (type == "hello") { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 176 } | 177 } |
| 177 | 178 |
| 178 void It2MeNativeMessagingHost::ProcessHello( | 179 void It2MeNativeMessagingHost::ProcessHello( |
| 179 std::unique_ptr<base::DictionaryValue> message, | 180 std::unique_ptr<base::DictionaryValue> message, |
| 180 std::unique_ptr<base::DictionaryValue> response) const { | 181 std::unique_ptr<base::DictionaryValue> response) const { |
| 181 DCHECK(task_runner()->BelongsToCurrentThread()); | 182 DCHECK(task_runner()->BelongsToCurrentThread()); |
| 182 | 183 |
| 183 response->SetString("version", STRINGIZE(VERSION)); | 184 response->SetString("version", STRINGIZE(VERSION)); |
| 184 | 185 |
| 185 // This list will be populated when new features are added. | 186 // This list will be populated when new features are added. |
| 186 std::unique_ptr<base::ListValue> supported_features_list( | 187 response->Set("supportedFeatures", base::MakeUnique<base::ListValue>()); |
| 187 new base::ListValue()); | |
| 188 response->Set("supportedFeatures", supported_features_list.release()); | |
| 189 | 188 |
| 190 SendMessageToClient(std::move(response)); | 189 SendMessageToClient(std::move(response)); |
| 191 } | 190 } |
| 192 | 191 |
| 193 void It2MeNativeMessagingHost::ProcessConnect( | 192 void It2MeNativeMessagingHost::ProcessConnect( |
| 194 std::unique_ptr<base::DictionaryValue> message, | 193 std::unique_ptr<base::DictionaryValue> message, |
| 195 std::unique_ptr<base::DictionaryValue> response) { | 194 std::unique_ptr<base::DictionaryValue> response) { |
| 196 DCHECK(task_runner()->BelongsToCurrentThread()); | 195 DCHECK(task_runner()->BelongsToCurrentThread()); |
| 197 | 196 |
| 198 if (!policy_received_) { | 197 if (!policy_received_) { |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 | 581 |
| 583 bool It2MeNativeMessagingHost::DelegateToElevatedHost( | 582 bool It2MeNativeMessagingHost::DelegateToElevatedHost( |
| 584 std::unique_ptr<base::DictionaryValue> message) { | 583 std::unique_ptr<base::DictionaryValue> message) { |
| 585 NOTREACHED(); | 584 NOTREACHED(); |
| 586 return false; | 585 return false; |
| 587 } | 586 } |
| 588 | 587 |
| 589 #endif // !defined(OS_WIN) | 588 #endif // !defined(OS_WIN) |
| 590 | 589 |
| 591 } // namespace remoting | 590 } // namespace remoting |
| OLD | NEW |