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

Side by Side Diff: mojo/application/public/cpp/application_connection.h

Issue 1244233002: Allow trusted brokers to restrict connections for spawned applications to whitelisted applications … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 5 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 unified diff | Download patch
OLDNEW
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 #ifndef MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_CONNECTION_H_ 5 #ifndef MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_CONNECTION_H_
6 #define MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_CONNECTION_H_ 6 #define MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_CONNECTION_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "mojo/application/public/cpp/lib/interface_factory_connector.h" 10 #include "mojo/application/public/cpp/lib/interface_factory_connector.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 // Closes the connection and destroys this object. This is the only valid way 50 // Closes the connection and destroys this object. This is the only valid way
51 // to destroy this object. 51 // to destroy this object.
52 void CloseConnection(); 52 void CloseConnection();
53 53
54 // See class description for details. 54 // See class description for details.
55 virtual void SetServiceConnector(ServiceConnector* connector) = 0; 55 virtual void SetServiceConnector(ServiceConnector* connector) = 0;
56 56
57 // Makes Interface available as a service to the remote application. 57 // Makes Interface available as a service to the remote application.
58 // |factory| will create implementations of Interface on demand. 58 // |factory| will create implementations of Interface on demand.
59 // Returns true if the service was exposed, false if capability filtering
60 // from the shell prevented the service from being exposed.
59 template <typename Interface> 61 template <typename Interface>
60 void AddService(InterfaceFactory<Interface>* factory) { 62 bool AddService(InterfaceFactory<Interface>* factory) {
61 SetServiceConnectorForName( 63 return SetServiceConnectorForName(
62 new internal::InterfaceFactoryConnector<Interface>(factory), 64 new internal::InterfaceFactoryConnector<Interface>(factory),
63 Interface::Name_); 65 Interface::Name_);
64 } 66 }
65 67
66 // Binds |ptr| to an implemention of Interface in the remote application. 68 // Binds |ptr| to an implemention of Interface in the remote application.
67 // |ptr| can immediately be used to start sending requests to the remote 69 // |ptr| can immediately be used to start sending requests to the remote
68 // service. 70 // service.
69 template <typename Interface> 71 template <typename Interface>
70 void ConnectToService(InterfacePtr<Interface>* ptr) { 72 void ConnectToService(InterfacePtr<Interface>* ptr) {
71 if (ServiceProvider* sp = GetServiceProvider()) { 73 if (ServiceProvider* sp = GetServiceProvider()) {
(...skipping 20 matching lines...) Expand all
92 94
93 // Returns the raw proxy to the remote application's ServiceProvider 95 // Returns the raw proxy to the remote application's ServiceProvider
94 // interface. Most applications will just use ConnectToService() instead. 96 // interface. Most applications will just use ConnectToService() instead.
95 // Caller does not take ownership. 97 // Caller does not take ownership.
96 virtual ServiceProvider* GetServiceProvider() = 0; 98 virtual ServiceProvider* GetServiceProvider() = 0;
97 99
98 // Returns the local application's ServiceProvider interface. The return 100 // Returns the local application's ServiceProvider interface. The return
99 // value is owned by this connection. 101 // value is owned by this connection.
100 virtual ServiceProvider* GetLocalServiceProvider() = 0; 102 virtual ServiceProvider* GetLocalServiceProvider() = 0;
101 103
104 // Register a handler to receive an error notification on the pipe to the
105 // remote application's service provider.
106 virtual void SetRemoteServiceProviderConnectionErrorHandler(
107 const Closure& handler) = 0;
108
102 protected: 109 protected:
103 virtual ~ApplicationConnection(); 110 virtual ~ApplicationConnection();
104 111
105 // Called to give the derived type to perform some cleanup before destruction. 112 // Called to give the derived type to perform some cleanup before destruction.
106 virtual void OnCloseConnection() = 0; 113 virtual void OnCloseConnection() = 0;
107 114
108 private: 115 private:
109 virtual void SetServiceConnectorForName(ServiceConnector* service_connector, 116 // Returns true if the connector was set, false if it was not set (e.g. by
117 // some filtering policy preventing this interface from being exposed).
118 virtual bool SetServiceConnectorForName(ServiceConnector* service_connector,
110 const std::string& name) = 0; 119 const std::string& name) = 0;
111 120
112 // Ensures that CloseConnection can only be called once and the 121 // Ensures that CloseConnection can only be called once and the
113 // ApplicationConnection's destructor can only be called after the connection 122 // ApplicationConnection's destructor can only be called after the connection
114 // is closed. 123 // is closed.
115 bool connection_closed_; 124 bool connection_closed_;
116 }; 125 };
117 126
118 } // namespace mojo 127 } // namespace mojo
119 128
120 #endif // MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_CONNECTION_H_ 129 #endif // MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_CONNECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698