1// Copyright 2014 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#import "chrome/browser/ui/cocoa/bubble_combobox.h"
6
7#include "ui/base/models/combobox_model.h"
8#include "base/strings/sys_string_conversions.h"
9
10@implementation BubbleCombobox
11
12- (id)initWithFrame:(NSRect)frame
13          pullsDown:(BOOL)pullsDown
14              model:(ui::ComboboxModel*)model {
15  if ((self = [super initWithFrame:frame pullsDown:pullsDown])) {
16    [self setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
17    [self setBordered:YES];
18    [[self cell] setControlSize:NSSmallControlSize];
19
20    for (int i = 0; i < model->GetItemCount(); ++i) {
21      if (model->IsItemSeparatorAt(i))
22        [[self menu] addItem:[NSMenuItem separatorItem]];
23      else
24        [self addItemWithTitle:base::SysUTF16ToNSString(model->GetItemAt(i))];
25    }
26
27    [self selectItemAtIndex:model->GetDefaultIndex()];
28  }
29  return self;
30}
31
32@end
33