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 #include <algorithm> | |
6 | |
7 #include "base/command_line.h" | 5 #include "base/command_line.h" |
8 #include "base/macros.h" | 6 #include "base/macros.h" |
9 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
10 #include "components/gles2/gpu_impl.h" | 8 #include "components/gles2/gpu_impl.h" |
11 #include "components/native_viewport/native_viewport_impl.h" | 9 #include "components/native_viewport/native_viewport_impl.h" |
12 #include "components/native_viewport/public/cpp/args.h" | 10 #include "components/native_viewport/public/cpp/args.h" |
13 #include "mojo/application/application_runner_chromium.h" | 11 #include "mojo/application/application_runner_chromium.h" |
14 #include "mojo/common/tracing_impl.h" | 12 #include "mojo/common/tracing_impl.h" |
15 #include "third_party/mojo/src/mojo/public/c/system/main.h" | 13 #include "third_party/mojo/src/mojo/public/c/system/main.h" |
16 #include "third_party/mojo/src/mojo/public/cpp/application/application_connectio
n.h" | 14 #include "third_party/mojo/src/mojo/public/cpp/application/application_connectio
n.h" |
(...skipping 14 matching lines...) Expand all Loading... |
31 public mojo::InterfaceFactory<Gpu> { | 29 public mojo::InterfaceFactory<Gpu> { |
32 public: | 30 public: |
33 NativeViewportAppDelegate() : is_headless_(false) {} | 31 NativeViewportAppDelegate() : is_headless_(false) {} |
34 ~NativeViewportAppDelegate() override {} | 32 ~NativeViewportAppDelegate() override {} |
35 | 33 |
36 private: | 34 private: |
37 // mojo::ApplicationDelegate implementation. | 35 // mojo::ApplicationDelegate implementation. |
38 void Initialize(mojo::ApplicationImpl* application) override { | 36 void Initialize(mojo::ApplicationImpl* application) override { |
39 tracing_.Initialize(application); | 37 tracing_.Initialize(application); |
40 | 38 |
41 #if defined(OS_LINUX) | |
42 // Apply the switch for kTouchEvents to CommandLine (if set). This allows | |
43 // redirecting the mouse to a touch device on X for testing. | |
44 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 39 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
45 const std::string touch_event_string("--" + | 40 if (command_line->HasSwitch(mojo::kUseTestConfig)) |
46 std::string(switches::kTouchDevices)); | |
47 auto touch_iter = std::find(application->args().begin(), | |
48 application->args().end(), | |
49 touch_event_string); | |
50 if (touch_iter != application->args().end() && | |
51 ++touch_iter != application->args().end()) { | |
52 command_line->AppendSwitchASCII(touch_event_string, *touch_iter); | |
53 } | |
54 #endif | |
55 | |
56 if (application->HasArg(mojo::kUseTestConfig)) | |
57 gfx::GLSurface::InitializeOneOffForTests(); | 41 gfx::GLSurface::InitializeOneOffForTests(); |
58 else | 42 else |
59 gfx::GLSurface::InitializeOneOff(); | 43 gfx::GLSurface::InitializeOneOff(); |
60 | 44 |
61 is_headless_ = application->HasArg(mojo::kUseHeadlessConfig); | 45 is_headless_ = command_line->HasSwitch(mojo::kUseHeadlessConfig); |
62 } | 46 } |
63 | 47 |
64 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { | 48 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { |
65 connection->AddService<NativeViewport>(this); | 49 connection->AddService<NativeViewport>(this); |
66 connection->AddService<Gpu>(this); | 50 connection->AddService<Gpu>(this); |
67 return true; | 51 return true; |
68 } | 52 } |
69 | 53 |
70 // mojo::InterfaceFactory<NativeViewport> implementation. | 54 // mojo::InterfaceFactory<NativeViewport> implementation. |
71 void Create(ApplicationConnection* connection, | 55 void Create(ApplicationConnection* connection, |
(...skipping 18 matching lines...) Expand all Loading... |
90 DISALLOW_COPY_AND_ASSIGN(NativeViewportAppDelegate); | 74 DISALLOW_COPY_AND_ASSIGN(NativeViewportAppDelegate); |
91 }; | 75 }; |
92 } | 76 } |
93 | 77 |
94 MojoResult MojoMain(MojoHandle shell_handle) { | 78 MojoResult MojoMain(MojoHandle shell_handle) { |
95 mojo::ApplicationRunnerChromium runner( | 79 mojo::ApplicationRunnerChromium runner( |
96 new native_viewport::NativeViewportAppDelegate); | 80 new native_viewport::NativeViewportAppDelegate); |
97 runner.set_message_loop_type(base::MessageLoop::TYPE_UI); | 81 runner.set_message_loop_type(base::MessageLoop::TYPE_UI); |
98 return runner.Run(shell_handle); | 82 return runner.Run(shell_handle); |
99 } | 83 } |
OLD | NEW |