Home | History | Annotate | Download | only in notifications
      1 // Copyright (c) 2010 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 "chrome/browser/ui/cocoa/notifications/balloon_view_bridge.h"
      6 
      7 #include "chrome/browser/ui/cocoa/notifications/balloon_controller.h"
      8 #import "chrome/browser/ui/cocoa/notifications/balloon_view_host_mac.h"
      9 #include "ui/gfx/size.h"
     10 
     11 #import <Cocoa/Cocoa.h>
     12 
     13 BalloonViewBridge::BalloonViewBridge() :
     14     controller_(NULL) {
     15 }
     16 
     17 BalloonViewBridge::~BalloonViewBridge() {
     18 }
     19 
     20 void BalloonViewBridge::Close(bool by_user) {
     21   [controller_ closeBalloon:by_user];
     22 }
     23 
     24 gfx::Size BalloonViewBridge::GetSize() const {
     25   if (controller_)
     26     return gfx::Size([controller_ desiredTotalWidth],
     27                      [controller_ desiredTotalHeight]);
     28   else
     29     return gfx::Size();
     30 }
     31 
     32 void BalloonViewBridge::RepositionToBalloon() {
     33   [controller_ repositionToBalloon];
     34 }
     35 
     36 void BalloonViewBridge::Show(Balloon* balloon) {
     37   controller_ = [[BalloonController alloc] initWithBalloon:balloon];
     38   [controller_ setShouldCascadeWindows:NO];
     39   [controller_ showWindow:nil];
     40 }
     41 
     42 BalloonHost* BalloonViewBridge::GetHost() const {
     43   return [controller_ getHost];
     44 }
     45 
     46 void BalloonViewBridge::Update() {
     47   [controller_ updateContents];
     48 }
     49