James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 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. |
| 4 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 5 | #include "mojo/public/c/system/main.h" |
Viet-Trung Luu | 9030792 | 2016-05-25 11:25:08 -0700 | [diff] [blame^] | 6 | #include "mojo/public/cpp/application/application_impl_base.h" |
| 7 | #include "mojo/public/cpp/application/run_application.h" |
Viet-Trung Luu | b237bca | 2016-05-13 16:35:11 -0700 | [diff] [blame] | 8 | #include "mojo/public/cpp/application/service_provider_impl.h" |
James Robinson | 28099f7 | 2014-12-02 10:54:46 -0800 | [diff] [blame] | 9 | #include "services/clipboard/clipboard_standalone_impl.h" |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 10 | |
Viet-Trung Luu | 9030792 | 2016-05-25 11:25:08 -0700 | [diff] [blame^] | 11 | namespace { |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 12 | |
Viet-Trung Luu | 9030792 | 2016-05-25 11:25:08 -0700 | [diff] [blame^] | 13 | class ClipboardApp : public mojo::ApplicationImplBase { |
| 14 | public: |
| 15 | ClipboardApp() {} |
| 16 | ~ClipboardApp() override {} |
| 17 | |
| 18 | // mojo::ApplicationImplBase override. |
| 19 | bool OnAcceptConnection( |
Viet-Trung Luu | 22e78b3 | 2016-05-13 15:27:15 -0700 | [diff] [blame] | 20 | mojo::ServiceProviderImpl* service_provider_impl) override { |
| 21 | service_provider_impl->AddService<mojo::Clipboard>( |
Viet-Trung Luu | 688f68e | 2016-05-13 14:12:04 -0700 | [diff] [blame] | 22 | [](const mojo::ConnectionContext& connection_context, |
| 23 | mojo::InterfaceRequest<mojo::Clipboard> clipboard_request) { |
| 24 | // TODO(erg): Write native implementations of the clipboard. For now, |
| 25 | // we just build a clipboard which doesn't interact with the system. |
| 26 | new clipboard::ClipboardStandaloneImpl(clipboard_request.Pass()); |
| 27 | }); |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 28 | return true; |
| 29 | } |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 30 | }; |
| 31 | |
Viet-Trung Luu | 9030792 | 2016-05-25 11:25:08 -0700 | [diff] [blame^] | 32 | } // namespace |
| 33 | |
Mitch Rudominer | 963aa77 | 2015-04-03 08:22:46 -0700 | [diff] [blame] | 34 | MojoResult MojoMain(MojoHandle application_request) { |
Viet-Trung Luu | 9030792 | 2016-05-25 11:25:08 -0700 | [diff] [blame^] | 35 | ClipboardApp clipboard_app; |
| 36 | return mojo::RunMainApplication(application_request, &clipboard_app); |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 37 | } |