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

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

Issue 65883002: mojo_shell crashes on Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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 "mojo/services/native_viewport/native_viewport.h" 5 #include "mojo/services/native_viewport/native_viewport.h"
6 6
7 #include "ui/events/event.h" 7 #include "ui/events/event.h"
8 #include "ui/gfx/win/window_impl.h" 8 #include "ui/gfx/win/window_impl.h"
9 9
10 namespace mojo { 10 namespace mojo {
11 namespace services { 11 namespace services {
12 12
13 class NativeViewportWin : public gfx::WindowImpl, 13 class NativeViewportWin : public gfx::WindowImpl,
14 public NativeViewport { 14 public NativeViewport {
15 public: 15 public:
16 explicit NativeViewportWin(NativeViewportDelegate* delegate) 16 explicit NativeViewportWin(NativeViewportDelegate* delegate)
17 : delegate_(delegate) { 17 : delegate_(delegate) {
18 Init(NULL, gfx::Rect(10, 10, 500, 500));
19 ShowWindow(hwnd(), SW_SHOWNORMAL);
20 SetWindowText(hwnd(), L"native_viewport::NativeViewportWin!");
21 } 18 }
22 virtual ~NativeViewportWin() { 19 virtual ~NativeViewportWin() {
23 if (IsWindow(hwnd())) 20 if (IsWindow(hwnd()))
24 DestroyWindow(hwnd()); 21 DestroyWindow(hwnd());
25 } 22 }
26 23
27 private: 24 private:
28 // Overridden from NativeViewport: 25 // Overridden from NativeViewport:
29 virtual gfx::Size GetSize() OVERRIDE { 26 virtual gfx::Size GetSize() OVERRIDE {
30 RECT cr; 27 RECT cr;
31 GetClientRect(hwnd(), &cr); 28 GetClientRect(hwnd(), &cr);
32 return gfx::Size(cr.right - cr.left, cr.bottom - cr.top); 29 return gfx::Size(cr.right - cr.left, cr.bottom - cr.top);
33 } 30 }
31
32 virtual void Open() OVERRIDE {
33 Init(NULL, gfx::Rect(10, 10, 500, 500));
34 ShowWindow(hwnd(), SW_SHOWNORMAL);
35 SetWindowText(hwnd(), L"native_viewport::NativeViewportWin!");
36 }
37
34 virtual void Close() OVERRIDE { 38 virtual void Close() OVERRIDE {
35 DestroyWindow(hwnd()); 39 DestroyWindow(hwnd());
36 } 40 }
37 41
38 BEGIN_MSG_MAP_EX(NativeViewportWin) 42 BEGIN_MSG_MAP_EX(NativeViewportWin)
39 MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange) 43 MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange)
40 44
41 MSG_WM_CREATE(OnCreate) 45 MSG_WM_CREATE(OnCreate)
42 MSG_WM_PAINT(OnPaint) 46 MSG_WM_PAINT(OnPaint)
43 MSG_WM_SIZE(OnSize) 47 MSG_WM_SIZE(OnSize)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 87
84 // static 88 // static
85 scoped_ptr<NativeViewport> NativeViewport::Create( 89 scoped_ptr<NativeViewport> NativeViewport::Create(
86 shell::Context* context, 90 shell::Context* context,
87 NativeViewportDelegate* delegate) { 91 NativeViewportDelegate* delegate) {
88 return scoped_ptr<NativeViewport>(new NativeViewportWin(delegate)).Pass(); 92 return scoped_ptr<NativeViewport>(new NativeViewportWin(delegate)).Pass();
89 } 93 }
90 94
91 } // namespace services 95 } // namespace services
92 } // namespace mojo 96 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698