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