diff options
Diffstat (limited to 'chrome/browser/tab_contents/render_view_context_menu_gtk.cc')
-rw-r--r-- | chrome/browser/tab_contents/render_view_context_menu_gtk.cc | 99 |
1 files changed, 10 insertions, 89 deletions
diff --git a/chrome/browser/tab_contents/render_view_context_menu_gtk.cc b/chrome/browser/tab_contents/render_view_context_menu_gtk.cc index f335e14..45dcf0ee 100644 --- a/chrome/browser/tab_contents/render_view_context_menu_gtk.cc +++ b/chrome/browser/tab_contents/render_view_context_menu_gtk.cc @@ -7,6 +7,7 @@ #include <gtk/gtk.h> #include "base/string_util.h" +#include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "webkit/glue/context_menu.h" @@ -16,49 +17,28 @@ RenderViewContextMenuGtk::RenderViewContextMenuGtk( const ContextMenuParams& params, guint32 triggering_event_time) : RenderViewContextMenu(web_contents, params), - making_submenu_(false), triggering_event_time_(triggering_event_time) { } RenderViewContextMenuGtk::~RenderViewContextMenuGtk() { } -void RenderViewContextMenuGtk::DoInit() { - DoneMakingMenu(&menu_); - gtk_menu_.reset(new MenuGtk(this, menu_.data())); +void RenderViewContextMenuGtk::PlatformInit() { + menu_gtk_.reset(new MenuGtk(this, &menu_model_)); - RenderWidgetHostViewGtk* rwhv = static_cast<RenderWidgetHostViewGtk*>( - source_tab_contents_->GetRenderWidgetHostView()); - if (rwhv) - rwhv->AppendInputMethodsContextMenu(gtk_menu_.get()); + if (params_.is_editable) { + RenderWidgetHostViewGtk* rwhv = static_cast<RenderWidgetHostViewGtk*>( + source_tab_contents_->GetRenderWidgetHostView()); + if (rwhv) + rwhv->AppendInputMethodsContextMenu(menu_gtk_.get()); + } } void RenderViewContextMenuGtk::Popup(const gfx::Point& point) { RenderWidgetHostView* rwhv = source_tab_contents_->GetRenderWidgetHostView(); if (rwhv) rwhv->ShowingContextMenu(true); - gtk_menu_->PopupAsContextAt(triggering_event_time_, point); -} - -bool RenderViewContextMenuGtk::IsCommandEnabled(int id) const { - return IsItemCommandEnabled(id); -} - -bool RenderViewContextMenuGtk::IsItemChecked(int id) const { - return ItemIsChecked(id); -} - -void RenderViewContextMenuGtk::ExecuteCommandById(int id) { - ExecuteItemCommand(id); -} - -std::string RenderViewContextMenuGtk::GetLabel(int id) const { - std::map<int, std::string>::const_iterator label = label_map_.find(id); - - if (label != label_map_.end()) - return label->second; - - return std::string(); + menu_gtk_->PopupAsContextAt(triggering_event_time_, point); } void RenderViewContextMenuGtk::StoppedShowing() { @@ -66,62 +46,3 @@ void RenderViewContextMenuGtk::StoppedShowing() { if (rwhv) rwhv->ShowingContextMenu(false); } - -void RenderViewContextMenuGtk::AppendMenuItem(int id) { - AppendItem(id, string16(), MENU_NORMAL); -} - -void RenderViewContextMenuGtk::AppendMenuItem(int id, - const string16& label) { - AppendItem(id, label, MENU_NORMAL); -} - -void RenderViewContextMenuGtk::AppendRadioMenuItem(int id, - const string16& label) { - AppendItem(id, label, MENU_RADIO); -} - -void RenderViewContextMenuGtk::AppendCheckboxMenuItem(int id, - const string16& label) { - AppendItem(id, label, MENU_CHECKBOX); -} - -void RenderViewContextMenuGtk::AppendSeparator() { - AppendItem(0, string16(), MENU_SEPARATOR); -} - -void RenderViewContextMenuGtk::StartSubMenu(int id, const string16& label) { - AppendItem(id, label, MENU_NORMAL); - making_submenu_ = true; -} - -void RenderViewContextMenuGtk::FinishSubMenu() { - DoneMakingMenu(&submenu_); - menu_[menu_.size() - 1].submenu = submenu_.data(); - making_submenu_ = false; -} - -void RenderViewContextMenuGtk::AppendItem( - int id, const string16& label, MenuItemType type) { - MenuCreateMaterial menu_create_material = { - type, id, 0, 0, NULL - }; - - if (label.empty()) - menu_create_material.label_id = id; - else - label_map_[id] = UTF16ToUTF8(label); - - std::vector<MenuCreateMaterial>* menu = - making_submenu_ ? &submenu_ : &menu_; - menu->push_back(menu_create_material); -} - -// static -void RenderViewContextMenuGtk::DoneMakingMenu( - std::vector<MenuCreateMaterial>* menu) { - static MenuCreateMaterial end_menu_item = { - MENU_END, 0, 0, 0, NULL - }; - menu->push_back(end_menu_item); -} |