Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: mojo/services/clipboard/main.cc

Issue 562483002: mojo: Create a basic clipboard. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes to the gn files. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "base/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/base_paths.h" 6 #include "base/base_paths.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "mojo/application/application_runner_chromium.h" 11 #include "mojo/application/application_runner_chromium.h"
12 #include "mojo/public/c/system/main.h" 12 #include "mojo/public/c/system/main.h"
13 #include "mojo/public/cpp/application/application_connection.h" 13 #include "mojo/public/cpp/application/application_connection.h"
14 #include "mojo/public/cpp/application/application_delegate.h" 14 #include "mojo/public/cpp/application/application_delegate.h"
15 #include "mojo/public/cpp/application/interface_factory.h" 15 #include "mojo/public/cpp/application/interface_factory.h"
16 #include "mojo/public/cpp/bindings/interface_ptr.h" 16 #include "mojo/public/cpp/bindings/interface_ptr.h"
17 #include "mojo/services/network/network_context.h" 17 #include "mojo/services/clipboard/clipboard_standalone_impl.h"
18 #include "mojo/services/network/network_service_impl.h"
19 18
20 class Delegate : public mojo::ApplicationDelegate, 19 class Delegate : public mojo::ApplicationDelegate,
21 public mojo::InterfaceFactory<mojo::NetworkService> { 20 public mojo::InterfaceFactory<mojo::Clipboard> {
22 public: 21 public:
23 Delegate() {} 22 Delegate() {}
24 23 virtual ~Delegate() {}
25 virtual void Initialize(mojo::ApplicationImpl* app) OVERRIDE {
26 base::FilePath base_path;
27 CHECK(PathService::Get(base::DIR_TEMP, &base_path));
28 base_path = base_path.Append(FILE_PATH_LITERAL("network_service"));
29 context_.reset(new mojo::NetworkContext(base_path));
30 }
31 24
32 // mojo::ApplicationDelegate implementation. 25 // mojo::ApplicationDelegate implementation.
33 virtual bool ConfigureIncomingConnection( 26 virtual bool ConfigureIncomingConnection(
34 mojo::ApplicationConnection* connection) OVERRIDE { 27 mojo::ApplicationConnection* connection) OVERRIDE {
35 DCHECK(context_);
36 connection->AddService(this); 28 connection->AddService(this);
37 return true; 29 return true;
38 } 30 }
39 31
40 // mojo::InterfaceFactory<mojo::NetworkService> implementation. 32 // mojo::InterfaceFactory<mojo::Clipboard> implementation.
41 virtual void Create( 33 virtual void Create(
42 mojo::ApplicationConnection* connection, 34 mojo::ApplicationConnection* connection,
43 mojo::InterfaceRequest<mojo::NetworkService> request) OVERRIDE { 35 mojo::InterfaceRequest<mojo::Clipboard> request) OVERRIDE {
44 mojo::BindToRequest( 36 // TODO(erg): Write native implementations of the clipboard. For now, we
45 new mojo::NetworkServiceImpl(connection, context_.get()), &request); 37 // just build a clipboard which doesn't interact with the system.
38 mojo::BindToRequest(new mojo::ClipboardStandaloneImpl(), &request);
46 } 39 }
47
48 private:
49 scoped_ptr<mojo::NetworkContext> context_;
50 }; 40 };
51 41
52 MojoResult MojoMain(MojoHandle shell_handle) { 42 MojoResult MojoMain(MojoHandle shell_handle) {
53 mojo::ApplicationRunnerChromium runner(new Delegate); 43 mojo::ApplicationRunnerChromium runner(new Delegate);
54 runner.set_message_loop_type(base::MessageLoop::TYPE_IO);
55 return runner.Run(shell_handle); 44 return runner.Run(shell_handle);
56 } 45 }
OLDNEW
« no previous file with comments | « mojo/services/clipboard/clipboard_standalone_unittest.cc ('k') | mojo/services/html_viewer/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698