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_PUBLIC_CPP_VIEW_MANAGER_VIEW_MANAGER_H_ 6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_MANAGER_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "mojo/services/public/cpp/view_manager/types.h" 12 #include "mojo/services/public/interfaces/input_events/input_events.mojom.h" 13 14 namespace mojo { 15 class View; 16 class ViewManagerDelegate; 17 class WindowManagerDelegate; 18 19 // Encapsulates a connection to the view manager service. 20 // A unique connection is made for every unique embed path for an app. e.g. for 21 // app B embed by the following paths: A->B, A->C->B - there are two connections 22 // and thus two instances of this class. 23 class ViewManager { 24 public: 25 // Sets the window manager delegate. Can only be called by the app embedded at 26 // the service root view. Can only be called once. 27 virtual void SetWindowManagerDelegate( 28 WindowManagerDelegate* window_manager_delegate) = 0; 29 30 // Dispatches the supplied event to the specified View. Can be called only 31 // by the application that called SetWindowManagerDelegate(). 32 virtual void DispatchEvent(View* target, EventPtr event) = 0; 33 34 // Returns the URL of the application that embedded this application. 35 virtual const std::string& GetEmbedderURL() const = 0; 36 37 // Returns all root views known to this connection. 38 virtual const std::vector<View*>& GetRoots() const = 0; 39 40 // Returns a View known to this connection. 41 virtual View* GetViewById(Id id) = 0; 42 43 protected: 44 virtual ~ViewManager() {} 45 }; 46 47 } // namespace mojo 48 49 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_MANAGER_H_ 50