| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/tab_contents/render_view_context_menu_gtk.h" | 5 #include "chrome/browser/tab_contents/render_view_context_menu_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
| 12 #include "chrome/browser/ui/gtk/gtk_util.h" | 12 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 13 #include "content/browser/renderer_host/render_widget_host_view.h" | 13 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 #include "content/public/common/context_menu_params.h" |
| 15 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/gfx/gtk_util.h" | 18 #include "ui/gfx/gtk_util.h" |
| 18 #include "webkit/glue/context_menu.h" | |
| 19 | 19 |
| 20 using content::WebContents; | 20 using content::WebContents; |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // A callback function for gtk_container_foreach(). This callback just checks | 24 // A callback function for gtk_container_foreach(). This callback just checks |
| 25 // the menu ID and set the given user data if it is same as the specified ID. | 25 // the menu ID and set the given user data if it is same as the specified ID. |
| 26 struct GtkWidgetAtParam { | 26 struct GtkWidgetAtParam { |
| 27 int index; | 27 int index; |
| 28 GtkWidget* widget; | 28 GtkWidget* widget; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 return subitem; | 68 return subitem; |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 return NULL; | 71 return NULL; |
| 72 } | 72 } |
| 73 | 73 |
| 74 } // namespace | 74 } // namespace |
| 75 | 75 |
| 76 RenderViewContextMenuGtk::RenderViewContextMenuGtk( | 76 RenderViewContextMenuGtk::RenderViewContextMenuGtk( |
| 77 WebContents* web_contents, | 77 WebContents* web_contents, |
| 78 const ContextMenuParams& params, | 78 const content::ContextMenuParams& params, |
| 79 RenderWidgetHostView* view) | 79 RenderWidgetHostView* view) |
| 80 : RenderViewContextMenu(web_contents, params) { | 80 : RenderViewContextMenu(web_contents, params) { |
| 81 GdkEventButton* event = view->GetLastMouseDown(); | 81 GdkEventButton* event = view->GetLastMouseDown(); |
| 82 triggering_event_time_ = event ? event->time : GDK_CURRENT_TIME; | 82 triggering_event_time_ = event ? event->time : GDK_CURRENT_TIME; |
| 83 } | 83 } |
| 84 | 84 |
| 85 RenderViewContextMenuGtk::~RenderViewContextMenuGtk() { | 85 RenderViewContextMenuGtk::~RenderViewContextMenuGtk() { |
| 86 } | 86 } |
| 87 | 87 |
| 88 void RenderViewContextMenuGtk::PlatformInit() { | 88 void RenderViewContextMenuGtk::PlatformInit() { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 return; | 139 return; |
| 140 | 140 |
| 141 // Enable (or disable) the menu item and updates its text. | 141 // Enable (or disable) the menu item and updates its text. |
| 142 gtk_widget_set_sensitive(item, enabled); | 142 gtk_widget_set_sensitive(item, enabled); |
| 143 if (hidden) | 143 if (hidden) |
| 144 gtk_widget_hide(item); | 144 gtk_widget_hide(item); |
| 145 else | 145 else |
| 146 gtk_widget_show(item); | 146 gtk_widget_show(item); |
| 147 gtk_menu_item_set_label(GTK_MENU_ITEM(item), UTF16ToUTF8(title).c_str()); | 147 gtk_menu_item_set_label(GTK_MENU_ITEM(item), UTF16ToUTF8(title).c_str()); |
| 148 } | 148 } |
| OLD | NEW |