| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef MOJO_SHELL_CONNECT_UTIL_H_ | 5 #ifndef MOJO_SHELL_CONNECT_UTIL_H_ |
| 6 #define MOJO_SHELL_CONNECT_UTIL_H_ | 6 #define MOJO_SHELL_CONNECT_UTIL_H_ |
| 7 | 7 |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "mojo/public/cpp/bindings/interface_ptr.h" | 10 #include "mojo/public/cpp/bindings/interface_ptr.h" |
| 11 #include "mojo/public/cpp/system/handle.h" | 11 #include "mojo/public/cpp/system/handle.h" |
| 12 #include "mojo/shell/identity.h" |
| 12 | 13 |
| 13 class GURL; | 14 class GURL; |
| 14 | 15 |
| 15 namespace mojo { | 16 namespace mojo { |
| 16 namespace shell { | 17 namespace shell { |
| 17 | 18 |
| 18 class ApplicationManager; | 19 class ApplicationManager; |
| 19 | 20 |
| 20 ScopedMessagePipeHandle ConnectToInterfaceByName( | 21 ScopedMessagePipeHandle ConnectToInterfaceByName( |
| 21 ApplicationManager* application_manager, | 22 ApplicationManager* application_manager, |
| 23 const Identity& source, |
| 22 const GURL& application_url, | 24 const GURL& application_url, |
| 23 const std::string& interface_name); | 25 const std::string& interface_name); |
| 24 | 26 |
| 25 // Must only be used by shell internals and test code as it does not forward | 27 // Must only be used by shell internals and test code as it does not forward |
| 26 // capability filters. Runs |application_url| with a permissive capability | 28 // capability filters. Runs |application_url| with a permissive capability |
| 27 // filter. | 29 // filter. |
| 28 template <typename Interface> | 30 template <typename Interface> |
| 29 inline void ConnectToInterface(ApplicationManager* application_manager, | 31 inline void ConnectToInterface(ApplicationManager* application_manager, |
| 32 const Identity& source, |
| 30 const GURL& application_url, | 33 const GURL& application_url, |
| 31 InterfacePtr<Interface>* ptr) { | 34 InterfacePtr<Interface>* ptr) { |
| 32 ScopedMessagePipeHandle service_handle = | 35 ScopedMessagePipeHandle service_handle = |
| 33 ConnectToInterfaceByName(application_manager, application_url, | 36 ConnectToInterfaceByName(application_manager, source, application_url, |
| 34 Interface::Name_); | 37 Interface::Name_); |
| 35 ptr->Bind(InterfacePtrInfo<Interface>(std::move(service_handle), 0u)); | 38 ptr->Bind(InterfacePtrInfo<Interface>(std::move(service_handle), 0u)); |
| 36 } | 39 } |
| 37 | 40 |
| 38 } // namespace shell | 41 } // namespace shell |
| 39 } // namespace mojo | 42 } // namespace mojo |
| 40 | 43 |
| 41 | 44 |
| 42 #endif // MOJO_SHELL_CONNECT_UTIL_H_ | 45 #endif // MOJO_SHELL_CONNECT_UTIL_H_ |
| OLD | NEW |