summaryrefslogtreecommitdiff
path: root/chromium/content/renderer/menu_item_builder.cc
blob: 2b44144ebad896d0d637427cec29a803135defa9 (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
25
26
27
28
29
30
31
// Copyright 2013 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 "content/renderer/menu_item_builder.h"

#include <stddef.h>

#include "base/i18n/rtl.h"
#include "content/public/common/menu_item.h"

namespace content {

MenuItem MenuItemBuilder::Build(const blink::WebMenuItemInfo& item) {
  MenuItem result;

  result.label = item.label.Utf16();
  result.tool_tip = item.tool_tip.Utf16();
  result.type = static_cast<MenuItem::Type>(item.type);
  result.action = item.action;
  result.rtl = (item.text_direction == base::i18n::RIGHT_TO_LEFT);
  result.has_directional_override = item.has_text_direction_override;
  result.enabled = item.enabled;
  result.checked = item.checked;
  for (size_t i = 0; i < item.sub_menu_items.size(); ++i)
    result.submenu.push_back(MenuItemBuilder::Build(item.sub_menu_items[i]));

  return result;
}

}  // namespace content