diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-10 20:43:19 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-10 20:43:19 +0000 |
commit | 1274bdad58253fe4137d29db4975291cf46bcb94 (patch) | |
tree | 50d1b0180e45ce0ee287df4ee3a473a6aa2000d2 /chrome | |
parent | 8711df994152f2dc72dd7f45da8779d73fe1e558 (diff) | |
download | chromium_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')
-rw-r--r-- | chrome/app/theme/o2-globe.png | bin | 0 -> 536 bytes | |||
-rw-r--r-- | chrome/app/theme/o2-history.png | bin | 0 -> 400 bytes | |||
-rw-r--r-- | chrome/app/theme/o2-more.png | bin | 0 -> 320 bytes | |||
-rw-r--r-- | chrome/app/theme/o2-search.png | bin | 0 -> 340 bytes | |||
-rw-r--r-- | chrome/app/theme/o2-star.png | bin | 0 -> 489 bytes | |||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_win.cc | 24 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_win.h | 4 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_popup_view.h | 19 | ||||
-rwxr-xr-x | chrome/browser/autocomplete/autocomplete_popup_view_win.cc | 14 | ||||
-rwxr-xr-x | chrome/browser/autocomplete/autocomplete_popup_view_win.h | 2 | ||||
-rw-r--r-- | chrome/browser/views/autocomplete/autocomplete_popup_win.cc | 88 | ||||
-rw-r--r-- | chrome/browser/views/autocomplete/autocomplete_popup_win.h | 44 | ||||
-rw-r--r-- | chrome/browser/views/browser_views.vcproj | 12 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 9 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 2 |
15 files changed, 202 insertions, 16 deletions
diff --git a/chrome/app/theme/o2-globe.png b/chrome/app/theme/o2-globe.png Binary files differnew file mode 100644 index 0000000..0fc4331 --- /dev/null +++ b/chrome/app/theme/o2-globe.png diff --git a/chrome/app/theme/o2-history.png b/chrome/app/theme/o2-history.png Binary files differnew file mode 100644 index 0000000..72af696 --- /dev/null +++ b/chrome/app/theme/o2-history.png diff --git a/chrome/app/theme/o2-more.png b/chrome/app/theme/o2-more.png Binary files differnew file mode 100644 index 0000000..61dfd29 --- /dev/null +++ b/chrome/app/theme/o2-more.png diff --git a/chrome/app/theme/o2-search.png b/chrome/app/theme/o2-search.png Binary files differnew file mode 100644 index 0000000..441001e --- /dev/null +++ b/chrome/app/theme/o2-search.png diff --git a/chrome/app/theme/o2-star.png b/chrome/app/theme/o2-star.png Binary files differnew file mode 100644 index 0000000..5919bb7b --- /dev/null +++ b/chrome/app/theme/o2-star.png diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc index 0d63f0d..ee9d18a 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc @@ -400,8 +400,9 @@ AutocompleteEditViewWin::AutocompleteEditViewWin( CommandUpdater* command_updater, bool popup_window_mode) : model_(new AutocompleteEditModel(this, controller, profile)), - popup_view_(new AutocompletePopupViewWin(font, this, model_.get(), - profile)), + popup_view_(AutocompletePopupView::CreatePopupView(font, this, + model_.get(), + profile)), controller_(controller), parent_view_(parent_view), toolbar_model_(toolbar_model), @@ -419,7 +420,7 @@ AutocompleteEditViewWin::AutocompleteEditViewWin( drop_highlight_position_(-1), background_color_(0), scheme_security_level_(ToolbarModel::NORMAL) { - model_->set_popup_model(popup_view_->model()); + model_->set_popup_model(popup_view_->GetModel()); saved_selection_for_focus_change_.cpMin = -1; @@ -720,7 +721,7 @@ void AutocompleteEditViewWin::UpdatePopup() { } void AutocompleteEditViewWin::ClosePopup() { - popup_view_->model()->StopAutocomplete(); + popup_view_->GetModel()->StopAutocomplete(); } IAccessible* AutocompleteEditViewWin::GetIAccessible() { @@ -1687,12 +1688,15 @@ bool AutocompleteEditViewWin::OnKeyDownOnlyWritable(TCHAR key, OnBeforePossibleChange(); Cut(); OnAfterPossibleChange(); - } else if (popup_view_->model()->IsOpen()) { - // This is a bit overloaded, but we hijack Shift-Delete in this - // case to delete the current item from the pop-up. We prefer cutting - // to this when possible since that's the behavior more people expect - // from Shift-Delete, and it's more commonly useful. - popup_view_->model()->TryDeletingCurrentItem(); + } else { + AutocompletePopupModel* popup_model = popup_view_->GetModel(); + if (popup_model->IsOpen()) { + // This is a bit overloaded, but we hijack Shift-Delete in this + // case to delete the current item from the pop-up. We prefer + // cutting to this when possible since that's the behavior more + // people expect from Shift-Delete, and it's more commonly useful. + popup_model->TryDeletingCurrentItem(); + } } } return true; diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.h b/chrome/browser/autocomplete/autocomplete_edit_view_win.h index 6165f78..85ea856 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.h +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.h @@ -32,7 +32,7 @@ class View; class AutocompleteEditController; class AutocompleteEditModel; class AutocompleteEditView; -class AutocompletePopupViewWin; +class AutocompletePopupView; // Provides the implementation of an edit control with a drop-down // autocomplete box. The box itself is implemented in autocomplete_popup.cc @@ -355,7 +355,7 @@ class AutocompleteEditViewWin scoped_ptr<AutocompleteEditModel> model_; - scoped_ptr<AutocompletePopupViewWin> popup_view_; + scoped_ptr<AutocompletePopupView> popup_view_; AutocompleteEditController* controller_; diff --git a/chrome/browser/autocomplete/autocomplete_popup_view.h b/chrome/browser/autocomplete/autocomplete_popup_view.h index 7c3db76..9690ac0 100644 --- a/chrome/browser/autocomplete/autocomplete_popup_view.h +++ b/chrome/browser/autocomplete/autocomplete_popup_view.h @@ -15,6 +15,12 @@ class AutocompleteEditView; class AutocompletePopupModel; class ChromeFont; +#if defined(OS_WIN) +class AutocompleteEditViewWin; +class AutocompleteEditModel; +class Profile; +#endif + class AutocompletePopupView { public: virtual ~AutocompletePopupView() { } @@ -34,6 +40,19 @@ class AutocompletePopupView { // Paint any pending updates. virtual void PaintUpdatesNow() = 0; + + // Returns the popup's model. + virtual AutocompletePopupModel* GetModel() = 0; + +#if defined(OS_WIN) + // Create a popup view implementation. It may make sense for this to become + // platform independent eventually. + static AutocompletePopupView* CreatePopupView( + const ChromeFont& font, + AutocompleteEditViewWin* edit_view, + AutocompleteEditModel* edit_model, + Profile* profile); +#endif }; #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_VIEW_H_ diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_win.cc b/chrome/browser/autocomplete/autocomplete_popup_view_win.cc index 9549389..578edbb 100755 --- a/chrome/browser/autocomplete/autocomplete_popup_view_win.cc +++ b/chrome/browser/autocomplete/autocomplete_popup_view_win.cc @@ -11,6 +11,7 @@ #include <atlmisc.h> #include <cmath> +#include "base/command_line.h" #include "base/string_util.h" #include "base/win_util.h" #include "chrome/browser/autocomplete/autocomplete.h" @@ -21,7 +22,9 @@ #include "chrome/browser/profile.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_model.h" +#include "chrome/browser/views/autocomplete/autocomplete_popup_win.h" #include "chrome/browser/views/location_bar_view.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/gfx/chrome_font.h" #include "chrome/common/l10n_util.h" @@ -674,3 +677,14 @@ void AutocompletePopupViewWin::DrawStar(HDC dc, int x, int y) const { canvas.getTopPlatformDevice().drawToHDC( dc, mirroring_context_->GetLeft(x, x + star_->width()), y, NULL); } + +// static +AutocompletePopupView* AutocompletePopupView::CreatePopupView( + const ChromeFont& font, + AutocompleteEditViewWin* edit_view, + AutocompleteEditModel* edit_model, + Profile* profile) { + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableOmnibox2)) + return new AutocompletePopupWin(font, edit_view, edit_model, profile); + return new AutocompletePopupViewWin(font, edit_view, edit_model, profile); +} diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_win.h b/chrome/browser/autocomplete/autocomplete_popup_view_win.h index 18c6449..afcc353 100755 --- a/chrome/browser/autocomplete/autocomplete_popup_view_win.h +++ b/chrome/browser/autocomplete/autocomplete_popup_view_win.h @@ -68,7 +68,7 @@ class AutocompletePopupViewWin virtual void PaintUpdatesNow() { UpdateWindow(); } - AutocompletePopupModel* model() { return model_.get(); } + virtual AutocompletePopupModel* GetModel() { return model_.get(); } private: class MirroringContext; 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_ diff --git a/chrome/browser/views/browser_views.vcproj b/chrome/browser/views/browser_views.vcproj index 0e433e9..8bd3c08 100644 --- a/chrome/browser/views/browser_views.vcproj +++ b/chrome/browser/views/browser_views.vcproj @@ -353,6 +353,18 @@ > </File> </Filter> + <Filter + Name="Autocomplete" + > + <File + RelativePath=".\autocomplete\autocomplete_popup_win.cc" + > + </File> + <File + RelativePath=".\autocomplete\autocomplete_popup_win.h" + > + </File> + </Filter> <File RelativePath=".\about_chrome_view.cc" > diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index e5573ca..a7691742 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -404,12 +404,15 @@ const wchar_t kEnableWebWorkers[] = L"enable-web-workers"; const wchar_t kWebWorkerProcessPerCore[] = L"web-worker-process-per-core"; // Enables experimental views under gtk. -const wchar_t kViewsGtk[] = L"views-gtk"; +const wchar_t kViewsGtk[] = L"views-gtk"; // Enables the bookmark menu. -const wchar_t kBookmarkMenu[] = L"bookmark-menu"; +const wchar_t kBookmarkMenu[] = L"bookmark-menu"; // Enables StatsTable, logging statistics to a global named shared memory table. -const wchar_t kEnableStatsTable[] = L"enable-stats-table"; +const wchar_t kEnableStatsTable[] = L"enable-stats-table"; + +// Enables the Omnibox2 popup and functionality. +const wchar_t kEnableOmnibox2[] = L"enable-omnibox2"; } // namespace switches diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 4b94a45..bd77523 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -163,6 +163,8 @@ extern const wchar_t kViewsGtk[]; extern const wchar_t kBookmarkMenu[]; extern const wchar_t kEnableStatsTable[]; +extern const wchar_t kEnableOmnibox2[]; + } // namespace switches #endif // CHROME_COMMON_CHROME_SWITCHES_H__ |