summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/autocomplete
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-10 20:43:19 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-10 20:43:19 +0000
commit1274bdad58253fe4137d29db4975291cf46bcb94 (patch)
tree50d1b0180e45ce0ee287df4ee3a473a6aa2000d2 /chrome/browser/views/autocomplete
parent8711df994152f2dc72dd7f45da8779d73fe1e558 (diff)
downloadchromium_src-1274bdad58253fe4137d29db4975291cf46bcb94.zip
chromium_src-1274bdad58253fe4137d29db4975291cf46bcb94.tar.gz
chromium_src-1274bdad58253fe4137d29db4975291cf46bcb94.tar.bz2
Allow a different omnibox popup to be enabled via the command line (--enable-omnibox2).
This will allow a views-based omnibox popup conforming to the new spec (stub provided) to be brought up without disturbing ToT UX. Also adds new images from Nicholas. Review URL: http://codereview.chromium.org/67035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13538 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/autocomplete')
-rw-r--r--chrome/browser/views/autocomplete/autocomplete_popup_win.cc88
-rw-r--r--chrome/browser/views/autocomplete/autocomplete_popup_win.h44
2 files changed, 132 insertions, 0 deletions
diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_win.cc b/chrome/browser/views/autocomplete/autocomplete_popup_win.cc
new file mode 100644
index 0000000..96290e9
--- /dev/null
+++ b/chrome/browser/views/autocomplete/autocomplete_popup_win.cc
@@ -0,0 +1,88 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+
+#include "chrome/browser/views/autocomplete/autocomplete_popup_win.h"
+
+#include "chrome/browser/autocomplete/autocomplete_edit_view_win.h"
+#include "chrome/browser/autocomplete/autocomplete_popup_model.h"
+#include "chrome/common/win_util.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// AutocompletePopupWin, public:
+
+AutocompletePopupWin::AutocompletePopupWin(const ChromeFont& font,
+ AutocompleteEditViewWin* edit_view,
+ AutocompleteEditModel* edit_model,
+ Profile* profile)
+ : model_(new AutocompletePopupModel(this, edit_model, profile)),
+ edit_view_(edit_view) {
+ set_delete_on_destroy(false);
+ set_window_style(WS_POPUP | WS_CLIPCHILDREN);
+ set_window_ex_style(WS_EX_TOOLWINDOW);
+}
+
+AutocompletePopupWin::~AutocompletePopupWin() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// AutocompletePopupWin, AutocompletePopupView overrides:
+
+bool AutocompletePopupWin::IsOpen() const {
+ return false;
+}
+
+void AutocompletePopupWin::InvalidateLine(size_t line) {
+}
+
+void AutocompletePopupWin::UpdatePopupAppearance() {
+ const AutocompleteResult& result = model_->result();
+ if (result.empty()) {
+ // No matches, close any existing popup.
+ if (::IsWindow(GetNativeView()))
+ Hide();
+ return;
+ }
+
+ gfx::Rect popup_bounds = GetPopupScreenBounds();
+ if (!::IsWindow(GetNativeView())) {
+ // Create the popup
+ HWND parent_hwnd = edit_view_->parent_view()->GetWidget()->GetNativeView();
+ Init(parent_hwnd, popup_bounds, false);
+ Show();
+ } else {
+ // Move the popup
+ int flags = 0;
+ if (!IsVisible())
+ flags |= SWP_SHOWWINDOW;
+ win_util::SetChildBounds(GetNativeView(), NULL, NULL, popup_bounds, 0,
+ flags);
+ }
+}
+
+void AutocompletePopupWin::OnHoverEnabledOrDisabled(bool disabled) {
+}
+
+void AutocompletePopupWin::PaintUpdatesNow() {
+}
+
+AutocompletePopupModel* AutocompletePopupWin::GetModel() {
+ return model_.get();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// AutocompletePopupWin, private:
+
+gfx::Rect AutocompletePopupWin::GetPopupScreenBounds() const {
+ gfx::Point popup_origin;
+ views::View::ConvertPointToScreen(edit_view_->parent_view(), &popup_origin);
+
+ gfx::Rect popup_bounds(popup_origin,
+ edit_view_->parent_view()->bounds().size());
+
+ // The popup starts at the bottom of the edit.
+ popup_bounds.set_y(popup_bounds.bottom());
+ popup_bounds.set_height(100);
+ return popup_bounds;
+}
+
diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_win.h b/chrome/browser/views/autocomplete/autocomplete_popup_win.h
new file mode 100644
index 0000000..9c8be43
--- /dev/null
+++ b/chrome/browser/views/autocomplete/autocomplete_popup_win.h
@@ -0,0 +1,44 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+
+#ifndef CHROME_BROWSER_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_WIN_H_
+#define CHROME_BROWSER_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_WIN_H_
+
+#include "chrome/browser/autocomplete/autocomplete_popup_view.h"
+#include "chrome/views/widget/widget_win.h"
+
+class AutocompleteEditModel;
+class AutocompleteEditViewWin;
+class Profile;
+
+class AutocompletePopupWin : public views::WidgetWin,
+ public AutocompletePopupView {
+ public:
+ AutocompletePopupWin(const ChromeFont& font,
+ AutocompleteEditViewWin* edit_view,
+ AutocompleteEditModel* edit_model,
+ Profile* profile);
+ virtual ~AutocompletePopupWin();
+
+ // Overridden from AutocompletePopupView:
+ virtual bool IsOpen() const;
+ virtual void InvalidateLine(size_t line);
+ virtual void UpdatePopupAppearance();
+ virtual void OnHoverEnabledOrDisabled(bool disabled);
+ virtual void PaintUpdatesNow();
+ virtual AutocompletePopupModel* GetModel();
+
+ private:
+ // Returns the bounds the popup should be created or shown at, in screen
+ // coordinates.
+ gfx::Rect GetPopupScreenBounds() const;
+
+ scoped_ptr<AutocompletePopupModel> model_;
+
+ AutocompleteEditViewWin* edit_view_;
+
+ DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWin);
+};
+
+#endif // #ifndef CHROME_BROWSER_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_WIN_H_