| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/api/copresence/copresence_translations.h" | 5 #include "chrome/browser/extensions/api/copresence/copresence_translations.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | |
| 8 #include "chrome/common/extensions/api/copresence.h" | 7 #include "chrome/common/extensions/api/copresence.h" |
| 9 #include "components/copresence/proto/data.pb.h" | 8 #include "components/copresence/proto/data.pb.h" |
| 10 #include "components/copresence/proto/enums.pb.h" | 9 #include "components/copresence/proto/enums.pb.h" |
| 11 #include "components/copresence/proto/rpcs.pb.h" | 10 #include "components/copresence/proto/rpcs.pb.h" |
| 12 | 11 |
| 13 using copresence::AUDIO_CONFIGURATION_AUDIBLE; | 12 using copresence::AUDIO_CONFIGURATION_AUDIBLE; |
| 14 using copresence::AUDIO_CONFIGURATION_UNKNOWN; | 13 using copresence::AUDIO_CONFIGURATION_UNKNOWN; |
| 15 using copresence::BROADCAST_AND_SCAN; | 14 using copresence::BROADCAST_AND_SCAN; |
| 16 using copresence::BROADCAST_ONLY; | 15 using copresence::BROADCAST_ONLY; |
| 17 using copresence::BROADCAST_SCAN_CONFIGURATION_UNKNOWN; | 16 using copresence::BROADCAST_SCAN_CONFIGURATION_UNKNOWN; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 bool AddPublishToRequest(const std::string& app_id, | 82 bool AddPublishToRequest(const std::string& app_id, |
| 84 const api::copresence::PublishOperation& publish, | 83 const api::copresence::PublishOperation& publish, |
| 85 ReportRequest* request) { | 84 ReportRequest* request) { |
| 86 copresence::PublishedMessage* publish_proto = | 85 copresence::PublishedMessage* publish_proto = |
| 87 request->mutable_manage_messages_request()->add_message_to_publish(); | 86 request->mutable_manage_messages_request()->add_message_to_publish(); |
| 88 publish_proto->mutable_access_policy()->mutable_acl()->set_acl_type( | 87 publish_proto->mutable_access_policy()->mutable_acl()->set_acl_type( |
| 89 copresence::NO_ACL_CHECK); | 88 copresence::NO_ACL_CHECK); |
| 90 publish_proto->set_id(publish.id); | 89 publish_proto->set_id(publish.id); |
| 91 publish_proto->mutable_message()->mutable_type()->set_type( | 90 publish_proto->mutable_message()->mutable_type()->set_type( |
| 92 publish.message.type); | 91 publish.message.type); |
| 93 publish_proto->mutable_message()->set_payload( | 92 publish_proto->mutable_message()->set_payload(publish.message.payload.data(), |
| 94 vector_as_array(&publish.message.payload), | 93 publish.message.payload.size()); |
| 95 publish.message.payload.size()); | |
| 96 | 94 |
| 97 int ttl = SanitizeTtl(publish.time_to_live_millis.get()); | 95 int ttl = SanitizeTtl(publish.time_to_live_millis.get()); |
| 98 if (ttl < 0) | 96 if (ttl < 0) |
| 99 return false; | 97 return false; |
| 100 publish_proto->mutable_access_policy()->set_ttl_millis(ttl); | 98 publish_proto->mutable_access_policy()->set_ttl_millis(ttl); |
| 101 | 99 |
| 102 SetTokenExchangeStrategy(publish.strategies.get(), | 100 SetTokenExchangeStrategy(publish.strategies.get(), |
| 103 BROADCAST_ONLY, | 101 BROADCAST_ONLY, |
| 104 publish_proto->mutable_token_exchange_strategy()); | 102 publish_proto->mutable_token_exchange_strategy()); |
| 105 | 103 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 apps_by_subscription_id, | 229 apps_by_subscription_id, |
| 232 request)) | 230 request)) |
| 233 return false; | 231 return false; |
| 234 } | 232 } |
| 235 } | 233 } |
| 236 | 234 |
| 237 return true; | 235 return true; |
| 238 } | 236 } |
| 239 | 237 |
| 240 } // namespace extensions | 238 } // namespace extensions |
| OLD | NEW |