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.
5 #ifndef COMPONENTS_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_DELEGATE_H_
6 #define COMPONENTS_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_DELEGATE_H_
10 #include "components/view_manager/public/interfaces/view_manager.mojom.h"
11 #include "mojo/application/public/interfaces/service_provider.mojom.h"
12 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
19 // Interface implemented by an application using the view manager.
21 // Each call to OnEmbed() results in a new ViewManager and new root View.
22 // ViewManager is deleted by any of the following:
23 // . If the root of the connection is destroyed. This happens if the owner
24 // of the root Embed()s another app in root, or the owner explicitly deletes
26 // . The connection to the viewmanager is lost.
27 // . Explicitly by way of calling delete.
29 // When the ViewManager is deleted all views are deleted (and observers
30 // notified). This is followed by notifying the delegate by way of
31 // OnViewManagerDestroyed().
32 class ViewManagerDelegate
{
34 // Called when the application implementing this interface is embedded at
37 // |services| exposes the services offered by the embedder to the delegate.
39 // |exposed_services| is an object that the delegate can add services to
40 // expose to the embedder.
42 // Note that if a different application is subsequently embedded at |root|,
43 // the pipes connecting |services| and |exposed_services| to the embedder and
44 // any services obtained from them are not broken and will continue to be
46 virtual void OnEmbed(View
* root
) = 0;
48 // Sent when another app is embedded in the same View as this connection.
49 // Subsequently the root View and this object are destroyed (observers are
50 // notified appropriately).
51 virtual void OnUnembed();
53 // Only invoked if the connection has been marked as an embed root. This
54 // allows the delegate to disallow the embed (return false), or change
55 // the ServiceProviders that would be exposed to the new client.
57 // This implementation returns true (allowing the embed), and does not alter
58 // the supplied ServiceProviders.
60 // See the mojom for more details.
61 virtual void OnEmbedForDescendant(View
* view
,
62 URLRequestPtr request
,
63 ViewManagerClientPtr
* client
);
65 // Called from the destructor of ViewManager after all the Views have been
66 // destroyed. |view_manager| is no longer valid after this call.
67 virtual void OnViewManagerDestroyed(ViewManager
* view_manager
) = 0;
70 virtual ~ViewManagerDelegate() {}
75 #endif // COMPONENTS_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_DELEGATE_H_