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

Side by Side Diff: mojo/services/native_viewport/native_viewport_mac.mm

Issue 65883002: mojo_shell crashes on Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix android build 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 #import <AppKit/NSApplication.h> 7 #import <AppKit/NSApplication.h>
8 #import <AppKit/NSView.h> 8 #import <AppKit/NSView.h>
9 #import <AppKit/NSWindow.h> 9 #import <AppKit/NSWindow.h>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "ui/gfx/rect.h" 12 #include "ui/gfx/rect.h"
13 13
14 namespace mojo { 14 namespace mojo {
15 namespace services { 15 namespace services {
16 16
17 class NativeViewportMac : public NativeViewport { 17 class NativeViewportMac : public NativeViewport {
18 public: 18 public:
19 NativeViewportMac(NativeViewportDelegate* delegate) 19 NativeViewportMac(NativeViewportDelegate* delegate)
20 : delegate_(delegate), 20 : delegate_(delegate),
21 window_(nil), 21 window_(nil),
22 rect_(10, 10, 500, 500) { 22 rect_(10, 10, 500, 500) {
23 [NSApplication sharedApplication];
24
25 window_ = [[NSWindow alloc]
26 initWithContentRect:NSRectFromCGRect(rect_.ToCGRect())
27 styleMask:NSTitledWindowMask
28 backing:NSBackingStoreBuffered
29 defer:NO];
30 [window_ orderFront:nil];
31 delegate_->OnAcceleratedWidgetAvailable([window_ contentView]);
32 } 23 }
33 24
34 virtual ~NativeViewportMac() { 25 virtual ~NativeViewportMac() {
35 [window_ orderOut:nil]; 26 [window_ orderOut:nil];
36 [window_ close]; 27 [window_ close];
37 } 28 }
38 29
39 private: 30 private:
40 // Overridden from NativeViewport: 31 // Overridden from NativeViewport:
41 virtual gfx::Size GetSize() OVERRIDE { 32 virtual gfx::Size GetSize() OVERRIDE {
42 return rect_.size(); 33 return rect_.size();
43 } 34 }
44 35
36 virtual void Init() OVERRIDE {
37 [NSApplication sharedApplication];
38
39 window_ = [[NSWindow alloc]
40 initWithContentRect:NSRectFromCGRect(rect_.ToCGRect())
41 styleMask:NSTitledWindowMask
42 backing:NSBackingStoreBuffered
43 defer:NO];
44 [window_ orderFront:nil];
45 delegate_->OnAcceleratedWidgetAvailable([window_ contentView]);
46 }
47
45 virtual void Close() OVERRIDE { 48 virtual void Close() OVERRIDE {
46 // TODO(beng): perform this in response to NSWindow destruction. 49 // TODO(beng): perform this in response to NSWindow destruction.
47 delegate_->OnDestroyed(); 50 delegate_->OnDestroyed();
48 } 51 }
49 52
50 NativeViewportDelegate* delegate_; 53 NativeViewportDelegate* delegate_;
51 NSWindow* window_; 54 NSWindow* window_;
52 gfx::Rect rect_; 55 gfx::Rect rect_;
53 56
54 DISALLOW_COPY_AND_ASSIGN(NativeViewportMac); 57 DISALLOW_COPY_AND_ASSIGN(NativeViewportMac);
55 }; 58 };
56 59
57 // static 60 // static
58 scoped_ptr<NativeViewport> NativeViewport::Create( 61 scoped_ptr<NativeViewport> NativeViewport::Create(
59 shell::Context* context, 62 shell::Context* context,
60 NativeViewportDelegate* delegate) { 63 NativeViewportDelegate* delegate) {
61 return scoped_ptr<NativeViewport>(new NativeViewportMac(delegate)).Pass(); 64 return scoped_ptr<NativeViewport>(new NativeViewportMac(delegate)).Pass();
62 } 65 }
63 66
64 } // namespace services 67 } // namespace services
65 } // namespace mojo 68 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/native_viewport/native_viewport_controller.cc ('k') | mojo/services/native_viewport/native_viewport_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698