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 3// found in the LICENSE file. 4 5#ifndef MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_SERVICE_CONTEXT_H_ 6#define MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_SERVICE_CONTEXT_H_ 7 8#include "base/memory/scoped_ptr.h" 9#include "mojo/public/cpp/bindings/callback.h" 10#include "mojo/public/cpp/bindings/interface_request.h" 11#include "mojo/public/interfaces/application/service_provider.mojom.h" 12#include "mojo/services/view_manager/view_manager_export.h" 13 14namespace mojo { 15class ApplicationConnection; 16 17namespace service { 18 19class ConnectionManager; 20class ViewManagerInitServiceImpl; 21 22// State shared between all ViewManagerInitService impls. 23class MOJO_VIEW_MANAGER_EXPORT ViewManagerInitServiceContext { 24 public: 25 ViewManagerInitServiceContext(); 26 virtual ~ViewManagerInitServiceContext(); 27 28 void AddConnection(ViewManagerInitServiceImpl* connection); 29 void RemoveConnection(ViewManagerInitServiceImpl* connection); 30 31 void ConfigureIncomingConnection(ApplicationConnection* connection); 32 33 void Embed(const String& url, 34 ServiceProviderPtr service_provider, 35 const Callback<void(bool)>& callback); 36 37 ConnectionManager* connection_manager() { return connection_manager_.get(); } 38 39 private: 40 typedef std::vector<ViewManagerInitServiceImpl*> Connections; 41 42 struct ConnectParams { 43 ConnectParams(); 44 ~ConnectParams(); 45 46 std::string url; 47 InterfaceRequest<ServiceProvider> service_provider; 48 Callback<void(bool)> callback; 49 }; 50 51 void OnNativeViewportDeleted(); 52 53 scoped_ptr<ConnectionManager> connection_manager_; 54 Connections connections_; 55 56 bool deleting_connection_; 57 58 DISALLOW_COPY_AND_ASSIGN(ViewManagerInitServiceContext); 59}; 60 61} // namespace service 62} // namespace mojo 63 64#endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_SERVICE_CONTEXT_H_ 65