[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / mojo / services / native_viewport / native_viewport_mac.mm
blob9d7301f6767fc7fbd817af3cf93d2493a0699733
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.
5 #include "mojo/services/native_viewport/native_viewport.h"
7 #import <AppKit/NSApplication.h>
8 #import <AppKit/NSView.h>
9 #import <AppKit/NSWindow.h>
11 #include "base/bind.h"
12 #include "ui/gfx/rect.h"
14 namespace mojo {
15 namespace services {
17 class NativeViewportMac : public NativeViewport {
18  public:
19   NativeViewportMac(NativeViewportDelegate* delegate)
20       : delegate_(delegate),
21         window_(nil) {
22   }
24   virtual ~NativeViewportMac() {
25     [window_ orderOut:nil];
26     [window_ close];
27   }
29  private:
30   // Overridden from NativeViewport:
31   virtual void Init(const gfx::Rect& bounds) OVERRIDE {
32     [NSApplication sharedApplication];
34     rect_ = bounds;
35     window_ = [[NSWindow alloc]
36                   initWithContentRect:NSRectFromCGRect(rect_.ToCGRect())
37                             styleMask:NSTitledWindowMask
38                               backing:NSBackingStoreBuffered
39                                 defer:NO];
40     delegate_->OnAcceleratedWidgetAvailable([window_ contentView]);
41     delegate_->OnBoundsChanged(rect_);
42   }
44   virtual void Show() OVERRIDE {
45     [window_ orderFront:nil];
46   }
48   virtual void Hide() OVERRIDE {
49     [window_ orderOut:nil];
50   }
52   virtual void Close() OVERRIDE {
53     // TODO(beng): perform this in response to NSWindow destruction.
54     delegate_->OnDestroyed();
55   }
57   virtual gfx::Size GetSize() OVERRIDE {
58     return rect_.size();
59   }
61   virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE {
62     NOTIMPLEMENTED();
63   }
65   virtual void SetCapture() OVERRIDE {
66     NOTIMPLEMENTED();
67   }
69   virtual void ReleaseCapture() OVERRIDE {
70     NOTIMPLEMENTED();
71   }
73   NativeViewportDelegate* delegate_;
74   NSWindow* window_;
75   gfx::Rect rect_;
77   DISALLOW_COPY_AND_ASSIGN(NativeViewportMac);
80 // static
81 scoped_ptr<NativeViewport> NativeViewport::Create(
82     shell::Context* context,
83     NativeViewportDelegate* delegate) {
84   return scoped_ptr<NativeViewport>(new NativeViewportMac(delegate)).Pass();
87 }  // namespace services
88 }  // namespace mojo