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