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 MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_DELEGATE_H_
6 #define MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_DELEGATE_H_
10 #include "mojo/public/cpp/system/macros.h"
14 class ApplicationConnection
;
15 class ApplicationImpl
;
17 // An abstract class that the application may subclass to control various
18 // behaviors of ApplicationImpl.
19 class ApplicationDelegate
{
21 ApplicationDelegate();
22 virtual ~ApplicationDelegate();
24 // Called exactly once before any other method.
25 virtual void Initialize(ApplicationImpl
* app
);
27 // Override this method to configure what services a connection supports when
28 // being connected to from an app.
29 // Return false to reject the connection entirely.
30 virtual bool ConfigureIncomingConnection(ApplicationConnection
* connection
);
32 // Override this method to configure what services a connection supports when
33 // connecting to another app.
34 // Return false to reject the connection entirely.
35 virtual bool ConfigureOutgoingConnection(ApplicationConnection
* connection
);
37 // Called when an ApplicationConnection is about to close. After returning,
38 // the |connection| object will be destroyed.
39 virtual void OnWillCloseConnection(ApplicationConnection
* connection
) {}
41 // Called when the shell connection has a connection error.
43 // Return true to shutdown the application. Return false to skip shutting
44 // down the connection, but user is then required to call
45 // ApplicationImpl::QuitNow() when done.
46 virtual bool OnShellConnectionError();
48 // Called before ApplicationImpl::Terminate(). After returning from this call
49 // the delegate can no longer rely on the main run loop still running.
53 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationDelegate
);
58 #endif // MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_DELEGATE_H_