summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-07 22:13:46 +0000
committerjennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-07 22:13:46 +0000
commit3510d44297fd73a97a3f204c01cfdc17d9431c3b (patch)
tree022e8d40826fc117a167641dd9becc364774f36f
parent6c8930fe82ed413d6546861ef7f47d1001959d77 (diff)
downloadchromium_src-3510d44297fd73a97a3f204c01cfdc17d9431c3b.zip
chromium_src-3510d44297fd73a97a3f204c01cfdc17d9431c3b.tar.gz
chromium_src-3510d44297fd73a97a3f204c01cfdc17d9431c3b.tar.bz2
Refactor the AutoCompletePopupView to get rid of gtk/gdk related code.
BUG=97837 TEST=NONE Review URL: http://codereview.chromium.org/8162010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104576 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_unittest.cc3
-rw-r--r--chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h1
-rw-r--r--chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm6
-rw-r--r--chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc6
-rw-r--r--chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h1
-rw-r--r--chrome/browser/ui/omnibox/omnibox_view.h6
-rw-r--r--chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc28
-rw-r--r--chrome/browser/ui/views/omnibox/omnibox_view_views.cc12
-rw-r--r--chrome/browser/ui/views/omnibox/omnibox_view_views.h1
-rw-r--r--chrome/browser/ui/views/omnibox/omnibox_view_win.cc17
-rw-r--r--chrome/browser/ui/views/omnibox/omnibox_view_win.h5
11 files changed, 58 insertions, 28 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_unittest.cc b/chrome/browser/autocomplete/autocomplete_edit_unittest.cc
index 95f40f3..307fe39 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_unittest.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_unittest.cc
@@ -52,7 +52,8 @@ class TestingOmniboxView : public OmniboxView {
virtual void OnRevertTemporaryText() {}
virtual void OnBeforePossibleChange() {}
virtual bool OnAfterPossibleChange() { return false; }
- virtual gfx::NativeView GetNativeView() const { return 0; }
+ virtual gfx::NativeView GetNativeView() const { return NULL; }
+ virtual gfx::NativeView GetRelativeWindowForPopup() const { return NULL; }
virtual CommandUpdater* GetCommandUpdater() { return NULL; }
virtual void SetInstantSuggestion(const string16& input,
bool animate_to_complete) {}
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h
index c0d3418f..80c2ce1 100644
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h
@@ -83,6 +83,7 @@ class OmniboxViewMac : public OmniboxView,
virtual void OnBeforePossibleChange() OVERRIDE;
virtual bool OnAfterPossibleChange() OVERRIDE;
virtual gfx::NativeView GetNativeView() const OVERRIDE;
+ virtual gfx::NativeView GetRelativeWindowForPopup() const OVERRIDE;
virtual CommandUpdater* GetCommandUpdater() OVERRIDE;
virtual void SetInstantSuggestion(const string16& input,
bool animate_to_complete) OVERRIDE;
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
index 80cf436..162ec85 100644
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
@@ -706,6 +706,12 @@ gfx::NativeView OmniboxViewMac::GetNativeView() const {
return field_;
}
+gfx::NativeView OmniboxViewMac::GetRelativeWindowForPopup() const {
+ // Not used on mac.
+ NOTREACHED();
+ return NULL;
+}
+
CommandUpdater* OmniboxViewMac::GetCommandUpdater() {
return command_updater_;
}
diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc
index 6b4c6d5..3e7fd27 100644
--- a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc
+++ b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc
@@ -754,6 +754,12 @@ gfx::NativeView OmniboxViewGtk::GetNativeView() const {
return alignment_.get();
}
+gfx::NativeView OmniboxViewGtk::GetRelativeWindowForPopup() const {
+ GtkWidget* toplevel = gtk_widget_get_toplevel(GetNativeView());
+ DCHECK(GTK_WIDGET_TOPLEVEL(toplevel));
+ return toplevel;
+}
+
CommandUpdater* OmniboxViewGtk::GetCommandUpdater() {
return command_updater_;
}
diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h
index ccc7efa..9f866f1 100644
--- a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h
+++ b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h
@@ -139,6 +139,7 @@ class OmniboxViewGtk : public OmniboxView,
virtual void OnBeforePossibleChange() OVERRIDE;
virtual bool OnAfterPossibleChange() OVERRIDE;
virtual gfx::NativeView GetNativeView() const OVERRIDE;
+ virtual gfx::NativeView GetRelativeWindowForPopup() const OVERRIDE;
virtual CommandUpdater* GetCommandUpdater() OVERRIDE;
virtual void SetInstantSuggestion(const string16& suggestion,
bool animate_to_complete) OVERRIDE;
diff --git a/chrome/browser/ui/omnibox/omnibox_view.h b/chrome/browser/ui/omnibox/omnibox_view.h
index f7f367e..a07b148 100644
--- a/chrome/browser/ui/omnibox/omnibox_view.h
+++ b/chrome/browser/ui/omnibox/omnibox_view.h
@@ -159,6 +159,12 @@ class OmniboxView {
// Returns the gfx::NativeView of the edit view.
virtual gfx::NativeView GetNativeView() const = 0;
+ // Gets the relative window for the pop up window of AutocompletePopupView.
+ // The pop up window will be shown under the relative window. When an IME
+ // is attached to the rich edit control, the IME window is the relative
+ // window. Otherwise, the top-most window is the relative window.
+ virtual gfx::NativeView GetRelativeWindowForPopup() const = 0;
+
// Returns the command updater for this view.
virtual CommandUpdater* GetCommandUpdater() = 0;
diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
index 6da0bce..07b3786 100644
--- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
+++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
@@ -45,10 +45,6 @@
#endif
#endif
-#if defined(TOOLKIT_USES_GTK)
-#include "ui/gfx/skia_utils_gtk.h"
-#endif
-
namespace {
const SkAlpha kGlassPopupAlpha = 240;
@@ -119,27 +115,6 @@ class OptInButtonBorder : public views::Border {
DISALLOW_COPY_AND_ASSIGN(OptInButtonBorder);
};
-
-gfx::NativeView GetRelativeWindowForPopup(gfx::NativeView edit_native_view) {
-#if defined(USE_AURA)
- // TODO(beng):
- NOTIMPLEMENTED();
- return NULL;
-#elif defined(OS_WIN)
- // When an IME is attached to the rich-edit control, retrieve its window
- // handle and show this popup window under the IME windows.
- // Otherwise, show this popup window under top-most windows.
- // TODO(hbono): http://b/1111369 if we exclude this popup window from the
- // display area of IME windows, this workaround becomes unnecessary.
- HWND ime_window = ImmGetDefaultIMEWnd(edit_native_view);
- return ime_window ? ime_window : HWND_NOTOPMOST;
-#elif defined(TOOLKIT_USES_GTK)
- GtkWidget* toplevel = gtk_widget_get_toplevel(edit_native_view);
- DCHECK(GTK_WIDGET_TOPLEVEL(toplevel));
- return toplevel;
-#endif
-}
-
} // namespace
class AutocompletePopupContentsView::AutocompletePopupWidget
@@ -370,8 +345,7 @@ void AutocompletePopupContentsView::UpdatePopupAppearance() {
params.bounds = GetPopupBounds();
popup_->Init(params);
popup_->SetContentsView(this);
- popup_->MoveAbove(
- GetRelativeWindowForPopup(omnibox_view_->GetNativeView()));
+ popup_->MoveAbove(omnibox_view_->GetRelativeWindowForPopup());
if (!popup_.get()) {
// For some IMEs GetRelativeWindowForPopup triggers the omnibox to lose
// focus, thereby closing (and destroying) the popup.
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
index d118642..30b0631 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -37,6 +37,10 @@
#include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h"
#endif
+#if defined(OS_WIN)
+#include "chrome/browser/ui/views/omnibox/omnibox_view_win.h"
+#endif
+
namespace {
// Textfield for autocomplete that intercepts events that are necessary
@@ -562,6 +566,14 @@ gfx::NativeView OmniboxViewViews::GetNativeView() const {
return GetWidget()->GetNativeView();
}
+gfx::NativeView OmniboxViewViews::GetRelativeWindowForPopup() const {
+#if defined(OS_WIN) && !defined(USE_AURA)
+ return OmniboxViewWin::GetRelativeWindowForNativeView(GetNativeView());
+#else
+ return GetWidget()->GetTopLevelWidget()->GetNativeView();
+#endif
+}
+
CommandUpdater* OmniboxViewViews::GetCommandUpdater() {
return command_updater_;
}
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.h b/chrome/browser/ui/views/omnibox/omnibox_view_views.h
index a63ef89..b6543ee 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.h
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.h
@@ -115,6 +115,7 @@ class OmniboxViewViews : public views::View,
virtual void OnBeforePossibleChange() OVERRIDE;
virtual bool OnAfterPossibleChange() OVERRIDE;
virtual gfx::NativeView GetNativeView() const OVERRIDE;
+ virtual gfx::NativeView GetRelativeWindowForPopup() const OVERRIDE;
virtual CommandUpdater* GetCommandUpdater() OVERRIDE;
virtual void SetInstantSuggestion(const string16& input,
bool animate_to_complete) OVERRIDE;
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
index 3f3777b..ae13c7b 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
@@ -907,6 +907,23 @@ gfx::NativeView OmniboxViewWin::GetNativeView() const {
return m_hWnd;
}
+// static
+gfx::NativeView OmniboxViewWin::GetRelativeWindowForNativeView(
+ gfx::NativeView edit_native_view) {
+ // When an IME is attached to the rich-edit control, retrieve its window
+ // handle, and the popup window of AutocompletePopupView will be shown
+ // under the IME windows.
+ // Otherwise, the popup window will be shown under top-most windows.
+ // TODO(hbono): http://b/1111369 if we exclude this popup window from the
+ // display area of IME windows, this workaround becomes unnecessary.
+ HWND ime_window = ImmGetDefaultIMEWnd(edit_native_view);
+ return ime_window ? ime_window : HWND_NOTOPMOST;
+}
+
+gfx::NativeView OmniboxViewWin::GetRelativeWindowForPopup() const {
+ return GetRelativeWindowForNativeView(GetNativeView());
+}
+
CommandUpdater* OmniboxViewWin::GetCommandUpdater() {
return command_updater_;
}
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.h b/chrome/browser/ui/views/omnibox/omnibox_view_win.h
index 7542173..e1dc740 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_win.h
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.h
@@ -70,6 +70,10 @@ class OmniboxViewWin
views::View* location_bar);
~OmniboxViewWin();
+ // Gets the relative window for the specified native view.
+ static gfx::NativeView GetRelativeWindowForNativeView(
+ gfx::NativeView edit_native_view);
+
views::View* parent_view() const;
// Returns the width in pixels needed to display the text from one character
@@ -132,6 +136,7 @@ class OmniboxViewWin
virtual void OnBeforePossibleChange() OVERRIDE;
virtual bool OnAfterPossibleChange() OVERRIDE;
virtual gfx::NativeView GetNativeView() const OVERRIDE;
+ virtual gfx::NativeView GetRelativeWindowForPopup() const OVERRIDE;
virtual CommandUpdater* GetCommandUpdater() OVERRIDE;
virtual void SetInstantSuggestion(const string16& suggestion,
bool animate_to_complete) OVERRIDE;