OLD | NEW |
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_SHELL_PUBLIC_CPP_SHELL_CLIENT_H_ | 5 #ifndef MOJO_SHELL_PUBLIC_CPP_SHELL_CLIENT_H_ |
6 #define MOJO_SHELL_PUBLIC_CPP_SHELL_CLIENT_H_ | 6 #define MOJO_SHELL_PUBLIC_CPP_SHELL_CLIENT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "mojo/public/cpp/system/macros.h" | 11 #include "mojo/public/cpp/system/macros.h" |
12 #include "mojo/shell/public/cpp/connection.h" | 12 #include "mojo/shell/public/cpp/connection.h" |
13 | 13 |
14 namespace mojo { | 14 namespace mojo { |
15 | 15 |
16 class Shell; | 16 class Shell; |
17 | 17 |
18 // An abstract class that the application may subclass to control various | 18 // An abstract class that the application may subclass to control various |
19 // behaviors of ApplicationImpl. | 19 // behaviors of ShellConnection. |
20 class ShellClient { | 20 class ShellClient { |
21 public: | 21 public: |
22 ShellClient(); | 22 ShellClient(); |
23 virtual ~ShellClient(); | 23 virtual ~ShellClient(); |
24 | 24 |
25 // Called once a bidirectional connection with the shell has been established. | 25 // Called once a bidirectional connection with the shell has been established. |
26 // |url| is the URL used to start the application. |id| is a unique identifier | 26 // |url| is the URL used to start the application. |id| is a unique identifier |
27 // the shell uses to identify this specific instance of the application. | 27 // the shell uses to identify this specific instance of the application. |
28 // Called exactly once before any other method. | 28 // Called exactly once before any other method. |
29 virtual void Initialize(Shell* shell, const std::string& url, uint32_t id); | 29 virtual void Initialize(Shell* shell, const std::string& url, uint32_t id); |
30 | 30 |
31 // Override this method to configure what services a connection supports when | 31 // Override this method to configure what services a connection supports when |
32 // being connected to from an app. | 32 // being connected to from an app. |
33 // Return false to reject the connection entirely. The default implementation | 33 // Return false to reject the connection entirely. The default implementation |
34 // returns false. | 34 // returns false. |
35 virtual bool AcceptConnection(Connection* connection); | 35 virtual bool AcceptConnection(Connection* connection); |
36 | 36 |
37 // Called when the shell connection has a connection error. | 37 // Called when the shell connection has a connection error. |
38 // | 38 // |
39 // Return true to shutdown the application. Return false to skip shutting | 39 // Return true to shutdown the application. Return false to skip shutting |
40 // down the connection, but user is then required to call | 40 // down the connection, but user is then required to call |
41 // ApplicationImpl::QuitNow() when done. Default implementation returns true. | 41 // ShellConnection::QuitNow() when done. Default implementation returns true. |
42 virtual bool ShellConnectionLost(); | 42 virtual bool ShellConnectionLost(); |
43 | 43 |
44 // Called before ApplicationImpl::Terminate(). After returning from this call | 44 // Called before ShellConnection::Terminate(). After returning from this call |
45 // the delegate can no longer rely on the main run loop still running. | 45 // the delegate can no longer rely on the main run loop still running. |
46 virtual void Quit(); | 46 virtual void Quit(); |
47 | 47 |
48 private: | 48 private: |
49 MOJO_DISALLOW_COPY_AND_ASSIGN(ShellClient); | 49 MOJO_DISALLOW_COPY_AND_ASSIGN(ShellClient); |
50 }; | 50 }; |
51 | 51 |
52 } // namespace mojo | 52 } // namespace mojo |
53 | 53 |
54 #endif // MOJO_SHELL_PUBLIC_CPP_SHELL_CLIENT_H_ | 54 #endif // MOJO_SHELL_PUBLIC_CPP_SHELL_CLIENT_H_ |
OLD | NEW |