summaryrefslogtreecommitdiffstats
path: root/mojo/services/native_viewport/native_viewport_impl.cc
diff options
context:
space:
mode:
authorabarth <abarth@chromium.org>2014-09-25 18:12:17 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-26 01:12:24 +0000
commitcff892f9c3062ddd2ac7e3c2385a5fb63be0b886 (patch)
treeb43cb6e63832dc100cf776406a546a639c2382c6 /mojo/services/native_viewport/native_viewport_impl.cc
parent9c49ac15c14a1040752e310aec6826c17ac29830 (diff)
downloadchromium_src-cff892f9c3062ddd2ac7e3c2385a5fb63be0b886.zip
chromium_src-cff892f9c3062ddd2ac7e3c2385a5fb63be0b886.tar.gz
chromium_src-cff892f9c3062ddd2ac7e3c2385a5fb63be0b886.tar.bz2
Add a headless configuration to Mojo's native viewport service
Rather than talking to X11, in headless mode, the native viewport service just drops requests on the floor. This configuration is useful for writing integration tests for the Mojo system that don't need to interact with X11. R=jamesr@chromium.org Review URL: https://codereview.chromium.org/606883002 Cr-Commit-Position: refs/heads/master@{#296846}
Diffstat (limited to 'mojo/services/native_viewport/native_viewport_impl.cc')
-rw-r--r--mojo/services/native_viewport/native_viewport_impl.cc13
1 files changed, 10 insertions, 3 deletions
diff --git a/mojo/services/native_viewport/native_viewport_impl.cc b/mojo/services/native_viewport/native_viewport_impl.cc
index a0ab999..4fce13f 100644
--- a/mojo/services/native_viewport/native_viewport_impl.cc
+++ b/mojo/services/native_viewport/native_viewport_impl.cc
@@ -11,6 +11,7 @@
#include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/public/cpp/application/application_impl.h"
#include "mojo/public/cpp/application/interface_factory.h"
+#include "mojo/services/native_viewport/platform_viewport_headless.h"
#include "mojo/services/native_viewport/viewport_surface.h"
#include "mojo/services/public/cpp/geometry/geometry_type_converters.h"
#include "mojo/services/public/cpp/input_events/input_events_type_converters.h"
@@ -28,8 +29,11 @@ bool IsRateLimitedEventType(ui::Event* event) {
} // namespace
-NativeViewportImpl::NativeViewportImpl(ApplicationImpl* app)
- : widget_id_(0u), waiting_for_event_ack_(false), weak_factory_(this) {
+NativeViewportImpl::NativeViewportImpl(ApplicationImpl* app, bool is_headless)
+ : is_headless_(is_headless),
+ widget_id_(0u),
+ waiting_for_event_ack_(false),
+ weak_factory_(this) {
app->ConnectToService("mojo:mojo_surfaces_service", &surfaces_service_);
// TODO(jamesr): Should be mojo_gpu_service
app->ConnectToService("mojo:mojo_native_viewport_service", &gpu_service_);
@@ -42,7 +46,10 @@ NativeViewportImpl::~NativeViewportImpl() {
}
void NativeViewportImpl::Create(SizePtr bounds) {
- platform_viewport_ = PlatformViewport::Create(this);
+ if (is_headless_)
+ platform_viewport_ = PlatformViewportHeadless::Create(this);
+ else
+ platform_viewport_ = PlatformViewport::Create(this);
gfx::Rect rect = gfx::Rect(bounds.To<gfx::Size>());
platform_viewport_->Init(rect);
OnBoundsChanged(rect);