summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-11 16:27:25 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-11 16:27:25 +0000
commitc02ecb834297e41993b0546fb57156ec2ab2563f (patch)
treea393d011cfd1ba6181e789b547a7b6ccfb54a8ee
parent1ecd85c2e2d586d18647748c5caed0fa3284b2e3 (diff)
downloadchromium_src-c02ecb834297e41993b0546fb57156ec2ab2563f.zip
chromium_src-c02ecb834297e41993b0546fb57156ec2ab2563f.tar.gz
chromium_src-c02ecb834297e41993b0546fb57156ec2ab2563f.tar.bz2
Lands http://codereview.chromium.org/2878087 for Alex:
Remove menu_gtk from the link for TOOLKIT_VIEWS builds. BUG=none TEST=manually, both with TOOLKIT_VIEWS=1 and TOOLKIT_VIEWS=0 Review URL: http://codereview.chromium.org/3130005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55733 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/gtk/task_manager_gtk.cc42
-rw-r--r--chrome/browser/gtk/task_manager_gtk.h10
-rw-r--r--chrome/browser/renderer_host/gtk_im_context_wrapper.cc6
-rw-r--r--chrome/browser/renderer_host/gtk_im_context_wrapper.h6
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_gtk.cc2
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_gtk.h4
-rw-r--r--chrome/chrome_browser.gypi2
7 files changed, 68 insertions, 4 deletions
diff --git a/chrome/browser/gtk/task_manager_gtk.cc b/chrome/browser/gtk/task_manager_gtk.cc
index faffd1c..f3e5987 100644
--- a/chrome/browser/gtk/task_manager_gtk.cc
+++ b/chrome/browser/gtk/task_manager_gtk.cc
@@ -23,7 +23,6 @@
#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/browser/gtk/gtk_tree.h"
#include "chrome/browser/gtk/gtk_util.h"
-#include "chrome/browser/gtk/menu_gtk.h"
#include "chrome/browser/memory_purger.h"
#include "chrome/browser/pref_service.h"
#include "chrome/common/chrome_switches.h"
@@ -33,6 +32,12 @@
#include "grit/chromium_strings.h"
#include "third_party/skia/include/core/SkBitmap.h"
+#if defined(TOOLKIT_VIEWS)
+#include "views/controls/menu/menu_2.h"
+#else
+#include "chrome/browser/gtk/menu_gtk.h"
+#endif
+
namespace {
// The task manager window default size.
@@ -212,18 +217,32 @@ class TaskManagerGtk::ContextMenuController
menu_model_->AddCheckItemWithStringId(
i, TaskManagerColumnIDToResourceID(i));
}
+#if defined(TOOLKIT_VIEWS)
+ menu_.reset(new views::Menu2(menu_model_.get()));
+#else
menu_.reset(new MenuGtk(NULL, menu_model_.get()));
+#endif
}
virtual ~ContextMenuController() {}
+#if defined(TOOLKIT_VIEWS)
+ void RunMenu(const gfx::Point& point) {
+ menu_->RunContextMenuAt(point);
+ }
+#else
void RunMenu() {
menu_->PopupAsContext(gtk_get_current_event_time());
}
+#endif
void Cancel() {
task_manager_ = NULL;
+#if defined(TOOLKIT_VIEWS)
+ menu_->CancelMenu();
+#else
menu_->Cancel();
+#endif
}
private:
@@ -260,7 +279,11 @@ class TaskManagerGtk::ContextMenuController
// The model and view for the right click context menu.
scoped_ptr<menus::SimpleMenuModel> menu_model_;
+#if defined(TOOLKIT_VIEWS)
+ scoped_ptr<views::Menu2> menu_;
+#else
scoped_ptr<MenuGtk> menu_;
+#endif
// The TaskManager the context menu was brought up for. Set to NULL when the
// menu is canceled.
@@ -710,12 +733,21 @@ void TaskManagerGtk::KillSelectedProcesses() {
g_list_free(paths);
}
+#if defined(TOOLKIT_VIEWS)
+void TaskManagerGtk::ShowContextMenu(const gfx::Point& point) {
+ if (!menu_controller_.get())
+ menu_controller_.reset(new ContextMenuController(this));
+
+ menu_controller_->RunMenu(point);
+}
+#else
void TaskManagerGtk::ShowContextMenu() {
if (!menu_controller_.get())
menu_controller_.reset(new ContextMenuController(this));
menu_controller_->RunMenu();
}
+#endif
void TaskManagerGtk::ActivateFocusedTab() {
GtkTreeSelection* selection = gtk_tree_view_get_selection(
@@ -889,8 +921,14 @@ gboolean TaskManagerGtk::OnButtonPressEvent(GtkWidget* widget,
gboolean TaskManagerGtk::OnButtonReleaseEvent(GtkWidget* widget,
GdkEventButton* event) {
- if (event->button == 3)
+ if (event->button == 3) {
+#if defined(TOOLKIT_VIEWS)
+ gfx::Point pt(event->x_root, event->y_root);
+ ShowContextMenu(pt);
+#else
ShowContextMenu();
+#endif
+ }
return FALSE;
}
diff --git a/chrome/browser/gtk/task_manager_gtk.h b/chrome/browser/gtk/task_manager_gtk.h
index 51d706e4..985e9a4 100644
--- a/chrome/browser/gtk/task_manager_gtk.h
+++ b/chrome/browser/gtk/task_manager_gtk.h
@@ -15,6 +15,12 @@
#include "chrome/browser/task_manager.h"
#include "grit/generated_resources.h"
+#if defined(TOOLKIT_VIEWS)
+namespace gfx {
+class Point;
+}
+#endif
+
class TaskManagerGtk : public TaskManagerModelObserver {
public:
TaskManagerGtk();
@@ -60,7 +66,11 @@ class TaskManagerGtk : public TaskManagerModelObserver {
void KillSelectedProcesses();
// Opens the context menu used to select the task manager columns.
+#if defined(TOOLKIT_VIEWS)
+ void ShowContextMenu(const gfx::Point& point);
+#else
void ShowContextMenu();
+#endif
// Activates the tab associated with the focused row.
void ActivateFocusedTab();
diff --git a/chrome/browser/renderer_host/gtk_im_context_wrapper.cc b/chrome/browser/renderer_host/gtk_im_context_wrapper.cc
index 4ac138b..e83345b 100644
--- a/chrome/browser/renderer_host/gtk_im_context_wrapper.cc
+++ b/chrome/browser/renderer_host/gtk_im_context_wrapper.cc
@@ -16,7 +16,9 @@
#include "base/third_party/icu/icu_utf.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/gtk/gtk_util.h"
+#if !defined(TOOLKIT_VIEWS)
#include "chrome/browser/gtk/menu_gtk.h"
+#endif
#include "chrome/browser/renderer_host/render_widget_host.h"
#include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
#include "chrome/common/native_web_keyboard_event.h"
@@ -247,6 +249,9 @@ void GtkIMContextWrapper::OnFocusOut() {
host_view_->GetRenderWidgetHost()->SetInputMethodActive(false);
}
+#if !defined(TOOLKIT_VIEWS)
+// Not defined for views because the views context menu doesn't
+// implement input methods yet.
void GtkIMContextWrapper::AppendInputMethodsContextMenu(MenuGtk* menu) {
gboolean show_input_method_menu = TRUE;
@@ -265,6 +270,7 @@ void GtkIMContextWrapper::AppendInputMethodsContextMenu(MenuGtk* menu) {
menu->AppendSeparator();
menu->AppendMenuItem(IDC_INPUT_METHODS_MENU, menuitem);
}
+#endif
void GtkIMContextWrapper::CancelComposition() {
if (!is_enabled_)
diff --git a/chrome/browser/renderer_host/gtk_im_context_wrapper.h b/chrome/browser/renderer_host/gtk_im_context_wrapper.h
index 5d81968..1e4c980 100644
--- a/chrome/browser/renderer_host/gtk_im_context_wrapper.h
+++ b/chrome/browser/renderer_host/gtk_im_context_wrapper.h
@@ -20,7 +20,9 @@ namespace gfx {
class Rect;
}
+#if !defined(TOOLKIT_VIEWS)
class MenuGtk;
+#endif
class RenderWidgetHostViewGtk;
struct NativeWebKeyboardEvent;
typedef struct _GtkIMContext GtkIMContext;
@@ -50,7 +52,11 @@ class GtkIMContextWrapper {
void OnFocusIn();
void OnFocusOut();
+#if !defined(TOOLKIT_VIEWS)
+ // Not defined for views because the views context menu doesn't
+ // implement input methods yet.
void AppendInputMethodsContextMenu(MenuGtk* menu);
+#endif
void CancelComposition();
diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc
index c040770..556e654 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc
@@ -748,9 +748,11 @@ void RenderWidgetHostViewGtk::ShowingContextMenu(bool showing) {
is_showing_context_menu_ = showing;
}
+#if !defined(TOOLKIT_VIEWS)
void RenderWidgetHostViewGtk::AppendInputMethodsContextMenu(MenuGtk* menu) {
im_context_->AppendInputMethodsContextMenu(menu);
}
+#endif
bool RenderWidgetHostViewGtk::NeedsInputGrab() {
return popup_type_ == WebKit::WebPopupTypeSelect;
diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.h b/chrome/browser/renderer_host/render_widget_host_view_gtk.h
index 14c992b..ead14ae 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_gtk.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.h
@@ -24,7 +24,9 @@ class RenderWidgetHost;
class GpuViewHost;
class GtkIMContextWrapper;
class GtkKeyBindingsHandler;
+#if !defined(TOOLKIT_VIEWS)
class MenuGtk;
+#endif
struct NativeWebKeyboardEvent;
#if defined(OS_CHROMEOS)
@@ -97,9 +99,11 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostView {
// RenderWidgetHost::ForwardEditCommandsForNextKeyEvent().
void ForwardKeyboardEvent(const NativeWebKeyboardEvent& event);
+#if !defined(TOOLKIT_VIEWS)
// Appends the input methods context menu to the specified |menu| object as a
// submenu.
void AppendInputMethodsContextMenu(MenuGtk* menu);
+#endif
private:
friend class RenderWidgetHostViewGtkWidget;
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 2347018..4186a2d 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3565,8 +3565,6 @@
['include', '^browser/gtk/keyword_editor_view.h'],
['include', '^browser/gtk/list_store_favicon_loader.cc'],
['include', '^browser/gtk/list_store_favicon_loader.h'],
- ['include', '^browser/gtk/menu_gtk.cc'],
- ['include', '^browser/gtk/menu_gtk.h'],
['include', '^browser/gtk/meta_frames.cc'],
['include', '^browser/gtk/meta_frames.h'],
['include', '^browser/gtk/nine_box.cc'],