summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/devtools/devtools_dock_tile_mac.mm
blob: b79ba1f9f51c0c2c03e9938b30cd4cf1e279e445 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/browser/devtools/devtools_dock_tile.h"

#import <Cocoa/Cocoa.h>

// static
void DevToolsDockTile::Update(const std::string& label, gfx::Image image) {
  NSDockTile* dockTile = [[NSApplication sharedApplication] dockTile];
  if (!image.IsEmpty()) {
    NSRect imageFrame = NSMakeRect(0, 0, 0, 0);
    base::scoped_nsobject<NSImageView> imageView(
        [[NSImageView alloc] initWithFrame:imageFrame]);
    NSImage* nsImage = image.ToNSImage();
    [imageView setImage:nsImage];
    [dockTile setContentView:imageView];
  }
  [dockTile setBadgeLabel:base::SysUTF8ToNSString(label)];
  [dockTile display];
}