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

Side by Side Diff: mojo/services/native_viewport/native_viewport_controller.cc

Issue 51373002: NativeViewport (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nl Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 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
5 #include "mojo/services/native_viewport/native_viewport_controller.h"
6
7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/stringprintf.h"
9 #include "mojo/services/native_viewport/native_viewport.h"
10 #include "ui/events/event.h"
11
12 namespace mojo {
13 namespace services {
14
15 NativeViewportController::NativeViewportController(Handle pipe)
16 : pipe_(pipe) {
17 native_viewport_ = NativeViewport::Create(this);
18 }
19 NativeViewportController::~NativeViewportController() {
20 }
21
22 void NativeViewportController::Close() {
23 DCHECK(native_viewport_);
24 native_viewport_->Close();
25 }
26
27 bool NativeViewportController::OnEvent(ui::Event* event) {
28 ui::LocatedEvent* located = static_cast<ui::LocatedEvent*>(event);
29 SendString(base::StringPrintf("Event @ %d,%d",
30 located->location().x(),
31 located->location().y()));
32 return false;
33 }
34
35 void NativeViewportController::OnResized(const gfx::Size& size) {
36 SendString(base::StringPrintf("Sized to: %d x %d",
37 size.width(),
38 size.height()));
39 }
40
41 void NativeViewportController::OnDestroyed() {
42 base::MessageLoop::current()->Quit();
43 }
44
45 void NativeViewportController::SendString(const std::string& string) {
46 WriteMessage(pipe_, string.c_str(), string.size()+1, NULL, 0,
47 MOJO_WRITE_MESSAGE_FLAG_NONE);
48 }
49
50 } // namespace services
51 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/native_viewport/native_viewport_controller.h ('k') | mojo/services/native_viewport/native_viewport_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698