Home | History | Annotate | Download | only in tab_contents
      1 // Copyright (c) 2011 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/tab_contents/render_view_context_menu_gtk.h"
      6 
      7 #include <gtk/gtk.h>
      8 
      9 #include "base/string_util.h"
     10 #include "chrome/app/chrome_command_ids.h"
     11 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
     12 #include "content/browser/tab_contents/tab_contents.h"
     13 #include "webkit/glue/context_menu.h"
     14 
     15 RenderViewContextMenuGtk::RenderViewContextMenuGtk(
     16     TabContents* web_contents,
     17     const ContextMenuParams& params,
     18     guint32 triggering_event_time)
     19     : RenderViewContextMenu(web_contents, params),
     20       triggering_event_time_(triggering_event_time) {
     21 }
     22 
     23 RenderViewContextMenuGtk::~RenderViewContextMenuGtk() {
     24 }
     25 
     26 void RenderViewContextMenuGtk::PlatformInit() {
     27   menu_gtk_.reset(new MenuGtk(this, &menu_model_));
     28 
     29   if (params_.is_editable) {
     30     RenderWidgetHostViewGtk* rwhv = static_cast<RenderWidgetHostViewGtk*>(
     31         source_tab_contents_->GetRenderWidgetHostView());
     32     if (rwhv)
     33       rwhv->AppendInputMethodsContextMenu(menu_gtk_.get());
     34   }
     35 }
     36 
     37 bool RenderViewContextMenuGtk::GetAcceleratorForCommandId(
     38     int command_id,
     39     ui::Accelerator* accelerator) {
     40   return false;
     41 }
     42 
     43 void RenderViewContextMenuGtk::Popup(const gfx::Point& point) {
     44   menu_gtk_->PopupAsContext(point, triggering_event_time_);
     45 }
     46 
     47 bool RenderViewContextMenuGtk::AlwaysShowIconForCmd(int command_id) const {
     48   return command_id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST &&
     49       command_id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST;
     50 }
     51