summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authordavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-09 23:48:30 +0000
committerdavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-09 23:48:30 +0000
commit5c9e97acabd4cdab5adb20d2412a5766b3382856 (patch)
treeead11654548e0e110cf8c8dce962801d530d54f7 /chrome
parent7f01f83fd464fc13cbdb9d377493d1781decf363 (diff)
downloadchromium_src-5c9e97acabd4cdab5adb20d2412a5766b3382856.zip
chromium_src-5c9e97acabd4cdab5adb20d2412a5766b3382856.tar.gz
chromium_src-5c9e97acabd4cdab5adb20d2412a5766b3382856.tar.bz2
First cut at implementation of FindBar for views / gtk
Also had to implement change notification for TextField on views / gtk Review URL: http://codereview.chromium.org/200035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25819 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser.cc2
-rw-r--r--chrome/browser/find_bar_controller.cc2
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc2
-rw-r--r--chrome/browser/tab_contents/tab_contents.h2
-rw-r--r--chrome/browser/views/bookmark_manager_view.cc2
-rw-r--r--chrome/browser/views/find_bar_host.cc (renamed from chrome/browser/views/find_bar_win.cc)369
-rw-r--r--chrome/browser/views/find_bar_host.h (renamed from chrome/browser/views/find_bar_win.h)57
-rw-r--r--chrome/browser/views/find_bar_host_browsertest.cc (renamed from chrome/browser/views/find_bar_win_browsertest.cc)10
-rwxr-xr-xchrome/browser/views/find_bar_host_gtk.cc73
-rw-r--r--chrome/browser/views/find_bar_host_interactive_uitest.cc (renamed from chrome/browser/views/find_bar_win_interactive_uitest.cc)0
-rw-r--r--chrome/browser/views/find_bar_host_uitest.cc (renamed from chrome/browser/views/find_bar_win_uitest.cc)0
-rwxr-xr-xchrome/browser/views/find_bar_host_win.cc191
-rw-r--r--chrome/browser/views/find_bar_view.cc16
-rw-r--r--chrome/browser/views/find_bar_view.h8
-rw-r--r--chrome/browser/views/options/cookies_view.cc4
-rw-r--r--chrome/chrome.gyp25
16 files changed, 416 insertions, 347 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index bd4c031..7795172 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -308,7 +308,7 @@ void Browser::CreateBrowserWindow() {
window_->GetLocationBar()->ShowFirstRunBubble(show_OEM_bubble);
}
-#if !(defined(OS_LINUX) && defined(TOOLKIT_VIEWS))
+#if defined(TOOLKIT_VIEWS)
FindBar* find_bar = BrowserWindow::CreateFindBar(this);
find_bar_controller_.reset(new FindBarController(find_bar));
find_bar->SetFindBarController(find_bar_controller_.get());
diff --git a/chrome/browser/find_bar_controller.cc b/chrome/browser/find_bar_controller.cc
index 5c99628..17fb22c 100644
--- a/chrome/browser/find_bar_controller.cc
+++ b/chrome/browser/find_bar_controller.cc
@@ -103,7 +103,7 @@ void FindBarController::ChangeTabContents(TabContents* contents) {
}
////////////////////////////////////////////////////////////////////////////////
-// FindBarWin, NotificationObserver implementation:
+// FindBarHost, NotificationObserver implementation:
void FindBarController::Observe(NotificationType type,
const NotificationSource& source,
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 29ccbc4..0e1673a 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -839,7 +839,7 @@ void TabContents::PopupNotificationVisibilityChanged(bool visible) {
render_view_host()->PopupNotificationVisibilityChanged(visible);
}
-gfx::NativeView TabContents::GetContentNativeView() {
+gfx::NativeView TabContents::GetContentNativeView() const {
return view_->GetContentNativeView();
}
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index 3f0546b..334c465 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -378,7 +378,7 @@ class TabContents : public PageNavigator,
// the view directly.
// Returns the actual window that is focused when this TabContents is shown.
- gfx::NativeView GetContentNativeView();
+ gfx::NativeView GetContentNativeView() const;
// Returns the NativeView associated with this TabContents. Outside of
// automation in the context of the UI, this is required to be implemented.
diff --git a/chrome/browser/views/bookmark_manager_view.cc b/chrome/browser/views/bookmark_manager_view.cc
index 193cd4b..384a2ce 100644
--- a/chrome/browser/views/bookmark_manager_view.cc
+++ b/chrome/browser/views/bookmark_manager_view.cc
@@ -503,7 +503,7 @@ void BookmarkManagerView::ContentsChanged(views::Textfield* sender,
bool BookmarkManagerView::HandleKeystroke(
views::Textfield* sender,
const views::Textfield::Keystroke& key) {
- if (views::Textfield::IsKeystrokeEnter(key)) {
+ if (key.GetKeyboardCode() == base::VKEY_RETURN) {
PerformSearch();
search_tf_->SelectAll();
}
diff --git a/chrome/browser/views/find_bar_win.cc b/chrome/browser/views/find_bar_host.cc
index 51bfd63..2c25dd1 100644
--- a/chrome/browser/views/find_bar_win.cc
+++ b/chrome/browser/views/find_bar_host.cc
@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/views/find_bar_win.h"
+#include "chrome/browser/views/find_bar_host.h"
#include "app/slide_animation.h"
+#include "base/keyboard_codes.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/find_bar_controller.h"
@@ -19,71 +20,22 @@
#include "views/controls/scrollbar/native_scroll_bar.h"
#include "views/widget/root_view.h"
-#if defined(OS_WIN)
-#include "views/widget/widget_win.h"
-#else
-#include "views/widget/widget_gtk.h"
-#endif
-
// static
-bool FindBarWin::disable_animations_during_testing_ = false;
-
-// Host is the actual widget containing FindBarView.
-#if defined(OS_WIN)
-class FindBarWin::Host : public views::WidgetWin {
- public:
- explicit Host(FindBarWin* find_bar) : find_bar_(find_bar) {
- // Don't let WidgetWin manage our lifetime. We want our lifetime to
- // coincide with TabContents.
- set_delete_on_destroy(false);
- set_window_style(WS_CHILD | WS_CLIPCHILDREN);
- set_window_ex_style(WS_EX_TOPMOST);
- }
-
- void OnFinalMessage(HWND window) {
- find_bar_->OnFinalMessage();
- }
-
- private:
- FindBarWin* find_bar_;
-
- DISALLOW_COPY_AND_ASSIGN(Host);
-};
-#else
-class FindBarWin::Host : public views::WidgetGtk {
- public:
- explicit Host(FindBarWin* find_bar)
- : WidgetGtk(TYPE_CHILD),
- find_bar_(find_bar) {
- // Don't let WidgetWin manage our lifetime. We want our lifetime to
- // coincide with TabContents.
- set_delete_on_destroy(false);
- }
-
- void OnDestroy(GtkWidget* widget) {
- find_bar_->OnFinalMessage();
- }
-
- private:
- FindBarWin* find_bar_;
-
- DISALLOW_COPY_AND_ASSIGN(Host);
-};
-#endif
+bool FindBarHost::disable_animations_during_testing_ = false;
namespace browser {
// Declared in browser_dialogs.h so others don't have to depend on our header.
FindBar* CreateFindBar(BrowserView* browser_view) {
- return new FindBarWin(browser_view);
+ return new FindBarHost(browser_view);
}
} // namespace browser
////////////////////////////////////////////////////////////////////////////////
-// FindBarWin, public:
+// FindBarHost, public:
-FindBarWin::FindBarWin(BrowserView* browser_view)
+FindBarHost::FindBarHost(BrowserView* browser_view)
: browser_view_(browser_view),
find_dialog_animation_offset_(0),
esc_accel_target_registered_(false),
@@ -91,8 +43,8 @@ FindBarWin::FindBarWin(BrowserView* browser_view)
view_ = new FindBarView(this);
// Initialize the host.
- host_.reset(new Host(this));
- host_->Init(browser_view->GetWidget()->GetNativeView(), gfx::Rect());
+ host_.reset(CreateHost());
+ host_->Init(GetNativeView(browser_view), gfx::Rect());
host_->SetContentsView(view_);
// Start listening to focus changes, so we can register and unregister our
@@ -116,123 +68,10 @@ FindBarWin::FindBarWin(BrowserView* browser_view)
animation_.reset(new SlideAnimation(this));
}
-FindBarWin::~FindBarWin() {
-}
-
-// TODO(brettw) this should not be so complicated. The view should really be in
-// charge of these regions. CustomFrameWindow will do this for us. It will also
-// let us set a path for the window region which will avoid some logic here.
-void FindBarWin::UpdateWindowEdges(const gfx::Rect& new_pos) {
-#if defined(OS_WIN)
- // |w| is used to make it easier to create the part of the polygon that curves
- // the right side of the Find window. It essentially keeps track of the
- // x-pixel position of the right-most background image inside the view.
- // TODO(finnur): Let the view tell us how to draw the curves or convert
- // this to a CustomFrameWindow.
- int w = new_pos.width() - 6; // -6 positions us at the left edge of the
- // rightmost background image of the view.
-
- // This polygon array represents the outline of the background image for the
- // dialog. Basically, it encompasses only the visible pixels of the
- // concatenated find_dlg_LMR_bg images (where LMR = [left | middle | right]).
- static const POINT polygon[] = {
- {0, 0}, {0, 1}, {2, 3}, {2, 29}, {4, 31},
- {4, 32}, {w+0, 32},
- {w+0, 31}, {w+1, 31}, {w+3, 29}, {w+3, 3}, {w+6, 0}
- };
-
- // Find the largest x and y value in the polygon.
- int max_x = 0, max_y = 0;
- for (int i = 0; i < arraysize(polygon); i++) {
- max_x = std::max(max_x, static_cast<int>(polygon[i].x));
- max_y = std::max(max_y, static_cast<int>(polygon[i].y));
- }
-
- // We then create the polygon and use SetWindowRgn to force the window to draw
- // only within that area. This region may get reduced in size below.
- HRGN region = CreatePolygonRgn(polygon, arraysize(polygon), ALTERNATE);
-
- // Are we animating?
- if (find_dialog_animation_offset_ > 0) {
- // The animation happens in two steps: First, we clip the window and then in
- // GetDialogPosition we offset the window position so that it still looks
- // attached to the toolbar as it grows. We clip the window by creating a
- // rectangle region (that gradually increases as the animation progresses)
- // and find the intersection between the two regions using CombineRgn.
-
- // |y| shrinks as the animation progresses from the height of the view down
- // to 0 (and reverses when closing).
- int y = find_dialog_animation_offset_;
- // |y| shrinking means the animation (visible) region gets larger. In other
- // words: the rectangle grows upward (when the dialog is opening).
- HRGN animation_region = CreateRectRgn(0, y, max_x, max_y);
- // |region| will contain the intersected parts after calling this function:
- CombineRgn(region, animation_region, region, RGN_AND);
- DeleteObject(animation_region);
-
- // Next, we need to increase the region a little bit to account for the
- // curved edges that the view will draw to make it look like grows out of
- // the toolbar.
- POINT left_curve[] = {
- {0, y+0}, {0, y+1}, {2, y+3}, {2, y+0}, {0, y+0}
- };
- POINT right_curve[] = {
- {w+3, y+3}, {w+6, y+0}, {w+3, y+0}, {w+3, y+3}
- };
-
- // Combine the region for the curve on the left with our main region.
- HRGN r = CreatePolygonRgn(left_curve, arraysize(left_curve), ALTERNATE);
- CombineRgn(region, r, region, RGN_OR);
- DeleteObject(r);
-
- // Combine the region for the curve on the right with our main region.
- r = CreatePolygonRgn(right_curve, arraysize(right_curve), ALTERNATE);
- CombineRgn(region, r, region, RGN_OR);
- DeleteObject(r);
- }
-
- // Now see if we need to truncate the region because parts of it obscures
- // the main window border.
- gfx::Rect dialog_bounds;
- GetDialogBounds(&dialog_bounds);
-
- // Calculate how much our current position overlaps our boundaries. If we
- // overlap, it means we have too little space to draw the whole dialog and
- // we allow overwriting the scrollbar before we start truncating our dialog.
- //
- // TODO(brettw) this constant is evil. This is the amount of room we've added
- // to the window size, when we set the region, it can change the size.
- static const int kAddedWidth = 7;
- int difference = (new_pos.right() - kAddedWidth) -
- dialog_bounds.width() -
- views::NativeScrollBar::GetVerticalScrollBarWidth() +
- 1;
- if (difference > 0) {
- POINT exclude[4] = {0};
- exclude[0].x = max_x - difference; // Top left corner.
- exclude[0].y = 0;
-
- exclude[1].x = max_x; // Top right corner.
- exclude[1].y = 0;
-
- exclude[2].x = max_x; // Bottom right corner.
- exclude[2].y = max_y;
-
- exclude[3].x = max_x - difference; // Bottom left corner.
- exclude[3].y = max_y;
-
- // Subtract this region from the original region.
- HRGN exclude_rgn = CreatePolygonRgn(exclude, arraysize(exclude), ALTERNATE);
- int result = CombineRgn(region, region, exclude_rgn, RGN_DIFF);
- DeleteObject(exclude_rgn);
- }
-
- // The system now owns the region, so we do not delete it.
- host_->SetWindowRgn(region, TRUE); // TRUE = Redraw.
-#endif
+FindBarHost::~FindBarHost() {
}
-void FindBarWin::Show() {
+void FindBarHost::Show() {
if (disable_animations_during_testing_) {
animation_->Reset(1);
MoveWindowIfNecessary(gfx::Rect(), true);
@@ -242,15 +81,15 @@ void FindBarWin::Show() {
}
}
-void FindBarWin::SetFocusAndSelection() {
+void FindBarHost::SetFocusAndSelection() {
view_->SetFocusAndSelection();
}
-bool FindBarWin::IsAnimating() {
+bool FindBarHost::IsAnimating() {
return animation_->IsAnimating();
}
-void FindBarWin::Hide(bool animate) {
+void FindBarHost::Hide(bool animate) {
if (animate && !disable_animations_during_testing_) {
animation_->Reset(1.0);
animation_->Hide();
@@ -259,23 +98,23 @@ void FindBarWin::Hide(bool animate) {
}
}
-void FindBarWin::ClearResults(const FindNotificationDetails& results) {
+void FindBarHost::ClearResults(const FindNotificationDetails& results) {
view_->UpdateForResult(results, string16());
}
-void FindBarWin::StopAnimation() {
+void FindBarHost::StopAnimation() {
animation_->End();
}
-void FindBarWin::SetFindText(const string16& find_text) {
+void FindBarHost::SetFindText(const string16& find_text) {
view_->SetFindText(find_text);
}
-bool FindBarWin::IsFindBarVisible() {
+bool FindBarHost::IsFindBarVisible() {
return host_->IsVisible();
}
-void FindBarWin::MoveWindowIfNecessary(const gfx::Rect& selection_rect,
+void FindBarHost::MoveWindowIfNecessary(const gfx::Rect& selection_rect,
bool no_redraw) {
// We only move the window if one is active for the current TabContents. If we
// don't check this, then SetDialogPosition below will end up making the Find
@@ -292,46 +131,7 @@ void FindBarWin::MoveWindowIfNecessary(const gfx::Rect& selection_rect,
view_->SchedulePaint();
}
-#if defined(OS_WIN)
-bool FindBarWin::MaybeForwardKeystrokeToWebpage(
- UINT message, TCHAR key, UINT flags) {
- // We specifically ignore WM_CHAR. See http://crbug.com/10509.
- if (message != WM_KEYDOWN && message != WM_KEYUP)
- return false;
-
- switch (key) {
- case VK_HOME:
- case VK_END:
- // Ctrl+Home and Ctrl+End should be forwarded to the page.
- if (GetKeyState(VK_CONTROL) >= 0)
- return false; // Ctrl not pressed: Abort. Otherwise fall through.
- case VK_UP:
- case VK_DOWN:
- case VK_PRIOR: // Page up
- case VK_NEXT: // Page down
- break; // The keys above are the ones we want to forward to the page.
- default:
- return false;
- }
-
- TabContents* contents = find_bar_controller_->tab_contents();
- if (!contents)
- return false;
-
- RenderViewHost* render_view_host = contents->render_view_host();
-
- // Make sure we don't have a text field element interfering with keyboard
- // input. Otherwise Up and Down arrow key strokes get eaten. "Nom Nom Nom".
- render_view_host->ClearFocusedNode();
-
- HWND hwnd = contents->GetContentNativeView();
- render_view_host->ForwardKeyboardEvent(
- NativeWebKeyboardEvent(hwnd, message, key, 0));
- return true;
-}
-#endif
-
-void FindBarWin::OnFinalMessage() {
+void FindBarHost::OnFinalMessage() {
// TODO(beng): Destroy the RootView before destroying the Focus Manager will
// allow us to remove this method.
@@ -345,14 +145,14 @@ void FindBarWin::OnFinalMessage() {
focus_tracker_.reset(NULL);
};
-bool FindBarWin::IsVisible() {
+bool FindBarHost::IsVisible() {
return host_->IsVisible();
}
////////////////////////////////////////////////////////////////////////////////
-// FindBarWin, views::FocusChangeListener implementation:
+// FindBarHost, views::FocusChangeListener implementation:
-void FindBarWin::FocusWillChange(views::View* focused_before,
+void FindBarHost::FocusWillChange(views::View* focused_before,
views::View* focused_now) {
// First we need to determine if one or both of the views passed in are child
// views of our view.
@@ -378,7 +178,7 @@ void FindBarWin::FocusWillChange(views::View* focused_before,
////////////////////////////////////////////////////////////////////////////////
// FindBarWin, views::AcceleratorTarget implementation:
-bool FindBarWin::AcceleratorPressed(const views::Accelerator& accelerator) {
+bool FindBarHost::AcceleratorPressed(const views::Accelerator& accelerator) {
#if defined(OS_WIN)
DCHECK(accelerator.GetKeyCode() == VK_ESCAPE); // We only expect Escape key.
#endif
@@ -391,9 +191,9 @@ bool FindBarWin::AcceleratorPressed(const views::Accelerator& accelerator) {
}
////////////////////////////////////////////////////////////////////////////////
-// FindBarWin, AnimationDelegate implementation:
+// FindBarHost, AnimationDelegate implementation:
-void FindBarWin::AnimationProgressed(const Animation* animation) {
+void FindBarHost::AnimationProgressed(const Animation* animation) {
// First, we calculate how many pixels to slide the window.
gfx::Size pref_size = view_->GetPreferredSize();
find_dialog_animation_offset_ =
@@ -411,7 +211,7 @@ void FindBarWin::AnimationProgressed(const Animation* animation) {
view_->SchedulePaint();
}
-void FindBarWin::AnimationEnded(const Animation* animation) {
+void FindBarHost::AnimationEnded(const Animation* animation) {
// Place the find bar in its fully opened state.
find_dialog_animation_offset_ = 0;
@@ -423,7 +223,7 @@ void FindBarWin::AnimationEnded(const Animation* animation) {
}
}
-void FindBarWin::GetThemePosition(gfx::Rect* bounds) {
+void FindBarHost::GetThemePosition(gfx::Rect* bounds) {
*bounds = GetDialogPosition(gfx::Rect());
gfx::Rect toolbar_bounds = browser_view_->GetToolbarBounds();
gfx::Rect tab_strip_bounds = browser_view_->GetTabStripBounds();
@@ -433,7 +233,7 @@ void FindBarWin::GetThemePosition(gfx::Rect* bounds) {
////////////////////////////////////////////////////////////////////////////////
// FindBarTesting implementation:
-bool FindBarWin::GetFindBarWindowInfo(gfx::Point* position,
+bool FindBarHost::GetFindBarWindowInfo(gfx::Point* position,
bool* fully_visible) {
if (!find_bar_controller_ ||
#if defined(OS_WIN)
@@ -454,14 +254,14 @@ bool FindBarWin::GetFindBarWindowInfo(gfx::Point* position,
return true;
}
-void FindBarWin::GetDialogBounds(gfx::Rect* bounds) {
+void FindBarHost::GetDialogBounds(gfx::Rect* bounds) {
DCHECK(bounds);
// The BrowserView does Layout for the components that we care about
// positioning relative to, so we ask it to tell us where we should go.
*bounds = browser_view_->GetFindBarBoundingBox();
}
-gfx::Rect FindBarWin::GetDialogPosition(gfx::Rect avoid_overlapping_rect) {
+gfx::Rect FindBarHost::GetDialogPosition(gfx::Rect avoid_overlapping_rect) {
// Find the area we have to work with (after accounting for scrollbars, etc).
gfx::Rect dialog_bounds;
GetDialogBounds(&dialog_bounds);
@@ -486,16 +286,7 @@ gfx::Rect FindBarWin::GetDialogPosition(gfx::Rect avoid_overlapping_rect) {
// For comparison (with the Intersects function below) we need to account
// for the fact that we draw the Find dialog relative to the window,
// whereas the selection rect is relative to the page.
-#if defined(OS_WIN)
- RECT frame_rect = {0}, webcontents_rect = {0};
- ::GetWindowRect(host_->GetParent(), &frame_rect);
- ::GetWindowRect(
- find_bar_controller_->tab_contents()->view()->GetNativeView(),
- &webcontents_rect);
- avoid_overlapping_rect.Offset(0, webcontents_rect.top - frame_rect.top);
-#else
- NOTIMPLEMENTED();
-#endif
+ GetDialogPositionNative(&avoid_overlapping_rect);
}
gfx::Rect new_pos = FindBarController::GetLocationForFindbarView(
@@ -509,7 +300,7 @@ gfx::Rect FindBarWin::GetDialogPosition(gfx::Rect avoid_overlapping_rect) {
return new_pos;
}
-void FindBarWin::SetDialogPosition(const gfx::Rect& new_pos, bool no_redraw) {
+void FindBarHost::SetDialogPosition(const gfx::Rect& new_pos, bool no_redraw) {
if (new_pos.IsEmpty())
return;
@@ -518,25 +309,10 @@ void FindBarWin::SetDialogPosition(const gfx::Rect& new_pos, bool no_redraw) {
// of it it doesn't look like the window crumbles into the toolbar.
UpdateWindowEdges(new_pos);
-#if defined(OS_WIN)
- gfx::Rect window_rect;
- host_->GetBounds(&window_rect, true);
- DWORD swp_flags = SWP_NOOWNERZORDER;
- if (!window_rect.IsEmpty())
- swp_flags |= SWP_NOSIZE;
- if (no_redraw)
- swp_flags |= SWP_NOREDRAW;
- if (!host_->IsVisible())
- swp_flags |= SWP_SHOWWINDOW;
-
- ::SetWindowPos(host_->GetNativeView(), HWND_TOP, new_pos.x(), new_pos.y(),
- new_pos.width(), new_pos.height(), swp_flags);
-#else
- host_->SetBounds(new_pos);
-#endif
+ SetDialogPositionNative(new_pos, no_redraw);
}
-void FindBarWin::RestoreSavedFocus() {
+void FindBarHost::RestoreSavedFocus() {
if (focus_tracker_.get() == NULL) {
// TODO(brettw) Focus() should be on TabContentsView.
find_bar_controller_->tab_contents()->Focus();
@@ -545,33 +321,11 @@ void FindBarWin::RestoreSavedFocus() {
}
}
-FindBarTesting* FindBarWin::GetFindBarTesting() {
+FindBarTesting* FindBarHost::GetFindBarTesting() {
return this;
}
-void FindBarWin::RegisterEscAccelerator() {
-#if defined(OS_WIN)
- DCHECK(!esc_accel_target_registered_);
- views::Accelerator escape(VK_ESCAPE, false, false, false);
- focus_manager_->RegisterAccelerator(escape, this);
- esc_accel_target_registered_ = true;
-#else
- NOTIMPLEMENTED();
-#endif
-}
-
-void FindBarWin::UnregisterEscAccelerator() {
-#if defined(OS_WIN)
- DCHECK(esc_accel_target_registered_);
- views::Accelerator escape(VK_ESCAPE, false, false, false);
- focus_manager_->UnregisterAccelerator(escape, this);
- esc_accel_target_registered_ = false;
-#else
- NOTIMPLEMENTED();
-#endif
-}
-
-void FindBarWin::UpdateUIForFindResult(const FindNotificationDetails& result,
+void FindBarHost::UpdateUIForFindResult(const FindNotificationDetails& result,
const string16& find_text) {
view_->UpdateForResult(result, find_text);
@@ -585,10 +339,49 @@ void FindBarWin::UpdateUIForFindResult(const FindNotificationDetails& result,
focus_tracker_.reset(NULL);
}
-void FindBarWin::AudibleAlert() {
-#if defined(OS_WIN)
- MessageBeep(MB_OK);
-#else
- NOTIMPLEMENTED();
-#endif
+void FindBarHost::RegisterEscAccelerator() {
+ DCHECK(!esc_accel_target_registered_);
+ views::Accelerator escape(base::VKEY_ESCAPE, false, false, false);
+ focus_manager_->RegisterAccelerator(escape, this);
+ esc_accel_target_registered_ = true;
+}
+
+void FindBarHost::UnregisterEscAccelerator() {
+ DCHECK(esc_accel_target_registered_);
+ views::Accelerator escape(base::VKEY_ESCAPE, false, false, false);
+ focus_manager_->UnregisterAccelerator(escape, this);
+ esc_accel_target_registered_ = false;
+}
+
+bool FindBarHost::MaybeForwardKeystrokeToWebpage(
+ const views::Textfield::Keystroke& key_stroke) {
+ switch (key_stroke.GetKeyboardCode()) {
+ case base::VKEY_DOWN:
+ case base::VKEY_UP:
+ case base::VKEY_PRIOR:
+ case base::VKEY_NEXT:
+ break;
+ case base::VKEY_HOME:
+ case base::VKEY_END:
+ if (key_stroke.IsControlHeld())
+ break;
+ // Fall through.
+ default:
+ return false;
+ }
+
+ TabContents* contents = find_bar_controller_->tab_contents();
+ if (!contents)
+ return false;
+
+ RenderViewHost* render_view_host = contents->render_view_host();
+
+ // Make sure we don't have a text field element interfering with keyboard
+ // input. Otherwise Up and Down arrow key strokes get eaten. "Nom Nom Nom".
+ render_view_host->ClearFocusedNode();
+ NativeWebKeyboardEvent event = GetKeyboardEvent(contents, key_stroke);
+ render_view_host->ForwardKeyboardEvent(event);
+ return true;
}
+
+
diff --git a/chrome/browser/views/find_bar_win.h b/chrome/browser/views/find_bar_host.h
index 732fd36..97f1ded 100644
--- a/chrome/browser/views/find_bar_win.h
+++ b/chrome/browser/views/find_bar_host.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_VIEWS_FIND_BAR_WIN_H_
-#define CHROME_BROWSER_VIEWS_FIND_BAR_WIN_H_
+#ifndef CHROME_BROWSER_VIEWS_FIND_BAR_HOST_H_
+#define CHROME_BROWSER_VIEWS_FIND_BAR_HOST_H_
#include "app/animation.h"
#include "base/gfx/rect.h"
@@ -11,7 +11,9 @@
#include "base/scoped_ptr.h"
#include "chrome/browser/find_bar.h"
#include "chrome/browser/renderer_host/render_view_host_delegate.h"
+#include "views/controls/textfield/textfield.h"
#include "views/focus/focus_manager.h"
+#include "views/widget/widget.h"
class BrowserView;
class FindBarController;
@@ -25,41 +27,40 @@ class ExternalFocusTracker;
class View;
}
-// TODO(sky): rename this to FindBarViews.
////////////////////////////////////////////////////////////////////////////////
//
-// The FindBarWin implements the container window for the Windows find-in-page
-// functionality. It uses the FindBarWin implementation to draw its content and
-// is responsible for showing, hiding, closing, and moving the window if needed,
+// The FindBarHost implements the container window for the
+// find-in-page functionality. It uses the appropriate implementation from
+// find_bar_host_win.cc or find_bar_host_gtk.cc to draw its content and is
+// responsible for showing, hiding, closing, and moving the window if needed,
// for example if the window is obscuring the selection results. It also
-// receives notifications about the search results and communicates that to the
-// view.
+// receives notifications about the search results and communicates that to
+// the view.
//
-// There is one FindBarWin per BrowserView, and its state is updated whenever
-// the selected Tab is changed. The FindBarWin is created when the BrowserView
-// is attached to the frame's Widget for the first time.
+// There is one FindBarHost per BrowserView, and its state is updated
+// whenever the selected Tab is changed. The FindBarHost is created when
+// the BrowserView is attached to the frame's Widget for the first time.
//
////////////////////////////////////////////////////////////////////////////////
-class FindBarWin : public views::AcceleratorTarget,
+class FindBarHost : public views::AcceleratorTarget,
public views::FocusChangeListener,
public AnimationDelegate,
public FindBar,
public FindBarTesting {
public:
- explicit FindBarWin(BrowserView* browser_view);
- virtual ~FindBarWin();
+ explicit FindBarHost(BrowserView* browser_view);
+ virtual ~FindBarHost();
// Whether we are animating the position of the Find window.
bool IsAnimating();
-#if defined(OS_WIN)
// Forwards selected keystrokes to the renderer. This is useful to make sure
// that arrow keys and PageUp and PageDown result in scrolling, instead of
// being eaten because the FindBar has focus. Returns true if the keystroke
// was forwarded, false if not.
- bool MaybeForwardKeystrokeToWebpage(UINT message, TCHAR key, UINT flags);
-#endif
+ bool MaybeForwardKeystrokeToWebpage(
+ const views::Textfield::Keystroke& key_stroke);
void OnFinalMessage();
@@ -113,8 +114,6 @@ class FindBarWin : public views::AcceleratorTarget,
static bool disable_animations_during_testing_;
private:
- class Host;
-
// Retrieves the boundaries that the find bar has to work with within the
// Chrome frame window. The resulting rectangle will be a rectangle that
// overlaps the bottom of the Chrome toolbar by one pixel (so we can create
@@ -144,6 +143,19 @@ class FindBarWin : public views::AcceleratorTarget,
// also: SetFocusChangeListener().
void UnregisterEscAccelerator();
+ // Creates and returns the native Widget.
+ views::Widget* CreateHost();
+ // Allows implementation to tweak dialog position.
+ void SetDialogPositionNative(const gfx::Rect& new_pos, bool no_redraw);
+ // Allows implementation to tweak dialog position.
+ void GetDialogPositionNative(gfx::Rect* avoid_overlapping_rect);
+ // Returns the native view (is a child of the window widget in gtk).
+ gfx::NativeView GetNativeView(BrowserView* browser_view);
+ // Returns a keyboard event suitable for fowarding.
+ NativeWebKeyboardEvent GetKeyboardEvent(
+ const TabContents* contents,
+ const views::Textfield::Keystroke& key_stroke);
+
// The BrowserView that created us.
BrowserView* browser_view_;
@@ -172,9 +184,10 @@ class FindBarWin : public views::AcceleratorTarget,
// Host is the Widget implementation that is created and maintained by the
// find bar. It contains the FindBarView.
- scoped_ptr<Host> host_;
+ scoped_ptr<views::Widget> host_;
- DISALLOW_COPY_AND_ASSIGN(FindBarWin);
+ DISALLOW_COPY_AND_ASSIGN(FindBarHost);
};
-#endif // CHROME_BROWSER_VIEWS_FIND_BAR_WIN_H_
+#endif // CHROME_BROWSER_VIEWS_FIND_BAR_HOST_H_
+
diff --git a/chrome/browser/views/find_bar_win_browsertest.cc b/chrome/browser/views/find_bar_host_browsertest.cc
index 63847fc..703a401 100644
--- a/chrome/browser/views/find_bar_win_browsertest.cc
+++ b/chrome/browser/views/find_bar_host_browsertest.cc
@@ -10,7 +10,7 @@
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_contents_view.h"
-#include "chrome/browser/views/find_bar_win.h"
+#include "chrome/browser/views/find_bar_host.h"
#include "chrome/common/notification_service.h"
#include "chrome/test/in_process_browser_test.h"
#include "chrome/test/ui_test_utils.h"
@@ -436,7 +436,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
ui_test_utils::NavigateToURL(browser(), url);
// Open the Find window with animations disabled.
- FindBarWin::disable_animations_during_testing_ = true;
+ FindBarHost::disable_animations_during_testing_ = true;
browser()->ShowFindBar();
gfx::Point position;
@@ -470,7 +470,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
ui_test_utils::NavigateToURL(browser(), url);
// Open the Find window with animations disabled.
- FindBarWin::disable_animations_during_testing_ = true;
+ FindBarHost::disable_animations_during_testing_ = true;
browser()->ShowFindBar();
gfx::Point position;
@@ -512,7 +512,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
ui_test_utils::NavigateToURL(browser(), url);
// Open the Find window with animations disabled.
- FindBarWin::disable_animations_during_testing_ = true;
+ FindBarHost::disable_animations_during_testing_ = true;
browser()->ShowFindBar();
gfx::Point start_position;
@@ -622,7 +622,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, StayActive) {
ui_test_utils::NavigateToURL(browser(), url);
// Open the Find window with animations disabled.
- FindBarWin::disable_animations_during_testing_ = true;
+ FindBarHost::disable_animations_during_testing_ = true;
browser()->ShowFindBar();
// Simulate a user clearing the search string. Ideally, we should be
diff --git a/chrome/browser/views/find_bar_host_gtk.cc b/chrome/browser/views/find_bar_host_gtk.cc
new file mode 100755
index 0000000..6a0989d
--- /dev/null
+++ b/chrome/browser/views/find_bar_host_gtk.cc
@@ -0,0 +1,73 @@
+// Copyright (c) 2006-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/find_bar_host.h"
+
+#include <gdk/gdkkeysyms.h>
+
+#include "chrome/browser/find_bar_controller.h"
+#include "chrome/browser/renderer_host/render_view_host.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/views/frame/browser_view.h"
+#include "views/widget/widget_gtk.h"
+
+class FindBarHostWidget : public views::WidgetGtk {
+ public:
+ explicit FindBarHostWidget(FindBarHost* find_bar)
+ : WidgetGtk(TYPE_CHILD),
+ find_bar_(find_bar) {
+ // Don't let WidgetGtk manage our lifetime. We want our lifetime to
+ // coincide with TabContents.
+ set_delete_on_destroy(false);
+ }
+
+ void OnDestroy(GtkWidget* widget) {
+ find_bar_->OnFinalMessage();
+ }
+
+ private:
+ FindBarHost* find_bar_;
+
+ DISALLOW_COPY_AND_ASSIGN(FindBarHostWidget);
+};
+
+void FindBarHost::UpdateWindowEdges(const gfx::Rect& new_pos) {
+ // TODO(davemoore) move the windows implementation to CustomFrameWindow so we
+ // don't have to implement it for gtk
+ NOTIMPLEMENTED();
+}
+
+void FindBarHost::AudibleAlert() {
+ // TODO(davemoore) implement
+ NOTIMPLEMENTED();
+}
+
+views::Widget* FindBarHost::CreateHost() {
+ return new FindBarHostWidget(this);
+}
+
+void FindBarHost::SetDialogPositionNative(const gfx::Rect& new_pos,
+ bool no_redraw) {
+ host_->SetBounds(new_pos);
+ host_->Show();
+}
+
+void FindBarHost::GetDialogPositionNative(gfx::Rect* avoid_overlapping_rect) {
+ // TODO(davemoore) implement
+ NOTIMPLEMENTED();
+}
+
+
+gfx::NativeView FindBarHost::GetNativeView(BrowserView* browser_view) {
+ return static_cast<views::WidgetGtk*>(
+ browser_view->GetWidget())->window_contents();
+}
+
+
+NativeWebKeyboardEvent FindBarHost::GetKeyboardEvent(
+ const TabContents* contents,
+ const views::Textfield::Keystroke& key_stroke) {
+ return NativeWebKeyboardEvent(key_stroke.event());
+}
+
diff --git a/chrome/browser/views/find_bar_win_interactive_uitest.cc b/chrome/browser/views/find_bar_host_interactive_uitest.cc
index 75f10d5..75f10d5 100644
--- a/chrome/browser/views/find_bar_win_interactive_uitest.cc
+++ b/chrome/browser/views/find_bar_host_interactive_uitest.cc
diff --git a/chrome/browser/views/find_bar_win_uitest.cc b/chrome/browser/views/find_bar_host_uitest.cc
index 9a4ea78..9a4ea78 100644
--- a/chrome/browser/views/find_bar_win_uitest.cc
+++ b/chrome/browser/views/find_bar_host_uitest.cc
diff --git a/chrome/browser/views/find_bar_host_win.cc b/chrome/browser/views/find_bar_host_win.cc
new file mode 100755
index 0000000..74577b4
--- /dev/null
+++ b/chrome/browser/views/find_bar_host_win.cc
@@ -0,0 +1,191 @@
+// Copyright (c) 2006-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/find_bar_host.h"
+
+#include "chrome/browser/find_bar_controller.h"
+#include "chrome/browser/renderer_host/render_view_host.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/tab_contents/tab_contents_view.h"
+#include "chrome/browser/views/frame/browser_view.h"
+#include "views/controls/scrollbar/native_scroll_bar.h"
+#include "views/widget/widget_win.h"
+
+class FindBarHostWidget : public views::WidgetWin {
+ public:
+ explicit FindBarHostWidget(FindBarHost* find_bar) : find_bar_(find_bar) {
+ // Don't let WidgetWin manage our lifetime. We want our lifetime to
+ // coincide with TabContents.
+ set_delete_on_destroy(false);
+ set_window_style(WS_CHILD | WS_CLIPCHILDREN);
+ set_window_ex_style(WS_EX_TOPMOST);
+ }
+
+ void OnFinalMessage(HWND window) {
+ find_bar_->OnFinalMessage();
+ }
+
+ private:
+ FindBarHost* find_bar_;
+
+ DISALLOW_COPY_AND_ASSIGN(FindBarHostWidget);
+};
+
+// TODO(brettw) this should not be so complicated. The view should really be in
+// charge of these regions. CustomFrameWindow will do this for us. It will also
+// let us set a path for the window region which will avoid some logic here.
+void FindBarHost::UpdateWindowEdges(const gfx::Rect& new_pos) {
+ // |w| is used to make it easier to create the part of the polygon that curves
+ // the right side of the Find window. It essentially keeps track of the
+ // x-pixel position of the right-most background image inside the view.
+ // TODO(finnur): Let the view tell us how to draw the curves or convert
+ // this to a CustomFrameWindow.
+ int w = new_pos.width() - 6; // -6 positions us at the left edge of the
+ // rightmost background image of the view.
+
+ // This polygon array represents the outline of the background image for the
+ // dialog. Basically, it encompasses only the visible pixels of the
+ // concatenated find_dlg_LMR_bg images (where LMR = [left | middle | right]).
+ static const POINT polygon[] = {
+ {0, 0}, {0, 1}, {2, 3}, {2, 29}, {4, 31},
+ {4, 32}, {w+0, 32},
+ {w+0, 31}, {w+1, 31}, {w+3, 29}, {w+3, 3}, {w+6, 0}
+ };
+
+ // Find the largest x and y value in the polygon.
+ int max_x = 0, max_y = 0;
+ for (int i = 0; i < arraysize(polygon); i++) {
+ max_x = std::max(max_x, static_cast<int>(polygon[i].x));
+ max_y = std::max(max_y, static_cast<int>(polygon[i].y));
+ }
+
+ // We then create the polygon and use SetWindowRgn to force the window to draw
+ // only within that area. This region may get reduced in size below.
+ HRGN region = CreatePolygonRgn(polygon, arraysize(polygon), ALTERNATE);
+
+ // Are we animating?
+ if (find_dialog_animation_offset_ > 0) {
+ // The animation happens in two steps: First, we clip the window and then in
+ // GetDialogPosition we offset the window position so that it still looks
+ // attached to the toolbar as it grows. We clip the window by creating a
+ // rectangle region (that gradually increases as the animation progresses)
+ // and find the intersection between the two regions using CombineRgn.
+
+ // |y| shrinks as the animation progresses from the height of the view down
+ // to 0 (and reverses when closing).
+ int y = find_dialog_animation_offset_;
+ // |y| shrinking means the animation (visible) region gets larger. In other
+ // words: the rectangle grows upward (when the dialog is opening).
+ HRGN animation_region = CreateRectRgn(0, y, max_x, max_y);
+ // |region| will contain the intersected parts after calling this function:
+ CombineRgn(region, animation_region, region, RGN_AND);
+ DeleteObject(animation_region);
+
+ // Next, we need to increase the region a little bit to account for the
+ // curved edges that the view will draw to make it look like grows out of
+ // the toolbar.
+ POINT left_curve[] = {
+ {0, y+0}, {0, y+1}, {2, y+3}, {2, y+0}, {0, y+0}
+ };
+ POINT right_curve[] = {
+ {w+3, y+3}, {w+6, y+0}, {w+3, y+0}, {w+3, y+3}
+ };
+
+ // Combine the region for the curve on the left with our main region.
+ HRGN r = CreatePolygonRgn(left_curve, arraysize(left_curve), ALTERNATE);
+ CombineRgn(region, r, region, RGN_OR);
+ DeleteObject(r);
+
+ // Combine the region for the curve on the right with our main region.
+ r = CreatePolygonRgn(right_curve, arraysize(right_curve), ALTERNATE);
+ CombineRgn(region, r, region, RGN_OR);
+ DeleteObject(r);
+ }
+
+ // Now see if we need to truncate the region because parts of it obscures
+ // the main window border.
+ gfx::Rect dialog_bounds;
+ GetDialogBounds(&dialog_bounds);
+
+ // Calculate how much our current position overlaps our boundaries. If we
+ // overlap, it means we have too little space to draw the whole dialog and
+ // we allow overwriting the scrollbar before we start truncating our dialog.
+ //
+ // TODO(brettw) this constant is evil. This is the amount of room we've added
+ // to the window size, when we set the region, it can change the size.
+ static const int kAddedWidth = 7;
+ int difference = (new_pos.right() - kAddedWidth) -
+ dialog_bounds.width() -
+ views::NativeScrollBar::GetVerticalScrollBarWidth() +
+ 1;
+ if (difference > 0) {
+ POINT exclude[4] = {0};
+ exclude[0].x = max_x - difference; // Top left corner.
+ exclude[0].y = 0;
+
+ exclude[1].x = max_x; // Top right corner.
+ exclude[1].y = 0;
+
+ exclude[2].x = max_x; // Bottom right corner.
+ exclude[2].y = max_y;
+
+ exclude[3].x = max_x - difference; // Bottom left corner.
+ exclude[3].y = max_y;
+
+ // Subtract this region from the original region.
+ HRGN exclude_rgn = CreatePolygonRgn(exclude, arraysize(exclude), ALTERNATE);
+ int result = CombineRgn(region, region, exclude_rgn, RGN_DIFF);
+ DeleteObject(exclude_rgn);
+ }
+
+ // The system now owns the region, so we do not delete it.
+ ::SetWindowRgn(host_->GetNativeView(), region, TRUE); // TRUE = Redraw.
+}
+
+NativeWebKeyboardEvent FindBarHost::GetKeyboardEvent(
+ const TabContents* contents,
+ const views::Textfield::Keystroke& key_stroke) {
+ HWND hwnd = contents->GetContentNativeView();
+ return NativeWebKeyboardEvent(
+ hwnd, key_stroke.message(), key_stroke.key(), 0);
+}
+
+void FindBarHost::AudibleAlert() {
+ MessageBeep(MB_OK);
+}
+
+views::Widget* FindBarHost::CreateHost() {
+ return new FindBarHostWidget(this);
+}
+
+void FindBarHost::SetDialogPositionNative(const gfx::Rect& new_pos,
+ bool no_redraw) {
+ gfx::Rect window_rect;
+ host_->GetBounds(&window_rect, true);
+ DWORD swp_flags = SWP_NOOWNERZORDER;
+ if (!window_rect.IsEmpty())
+ swp_flags |= SWP_NOSIZE;
+ if (no_redraw)
+ swp_flags |= SWP_NOREDRAW;
+ if (!host_->IsVisible())
+ swp_flags |= SWP_SHOWWINDOW;
+
+ ::SetWindowPos(host_->GetNativeView(), HWND_TOP, new_pos.x(), new_pos.y(),
+ new_pos.width(), new_pos.height(), swp_flags);
+}
+
+void FindBarHost::GetDialogPositionNative(gfx::Rect* avoid_overlapping_rect) {
+ RECT frame_rect = {0}, webcontents_rect = {0};
+ ::GetWindowRect(
+ static_cast<views::WidgetWin*>(host_.get())->GetParent(), &frame_rect);
+ ::GetWindowRect(
+ find_bar_controller_->tab_contents()->view()->GetNativeView(),
+ &webcontents_rect);
+ avoid_overlapping_rect->Offset(0, webcontents_rect.top - frame_rect.top);
+}
+
+gfx::NativeView FindBarHost::GetNativeView(BrowserView* browser_view) {
+ return browser_view->GetWidget()->GetNativeView();
+}
+
diff --git a/chrome/browser/views/find_bar_view.cc b/chrome/browser/views/find_bar_view.cc
index 857869c..bd7e0bb 100644
--- a/chrome/browser/views/find_bar_view.cc
+++ b/chrome/browser/views/find_bar_view.cc
@@ -13,7 +13,7 @@
#include "chrome/browser/browser_theme_provider.h"
#include "chrome/browser/find_bar_controller.h"
#include "chrome/browser/tab_contents/tab_contents.h"
-#include "chrome/browser/views/find_bar_win.h"
+#include "chrome/browser/views/find_bar_host.h"
#include "chrome/browser/view_ids.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -76,7 +76,7 @@ static const int kDefaultCharWidth = 43;
////////////////////////////////////////////////////////////////////////////////
// FindBarView, public:
-FindBarView::FindBarView(FindBarWin* container)
+FindBarView::FindBarView(FindBarHost* container)
: container_(container),
find_text_(NULL),
match_count_text_(NULL),
@@ -467,24 +467,20 @@ bool FindBarView::HandleKeystroke(views::Textfield* sender,
if (!container_->IsVisible())
return false;
- // TODO(port): Handle this for other platforms.
- #if defined(OS_WIN)
- if (container_->MaybeForwardKeystrokeToWebpage(key.message, key.key,
- key.flags))
+ if (container_->MaybeForwardKeystrokeToWebpage(key))
return true; // Handled, we are done!
- if (views::Textfield::IsKeystrokeEnter(key)) {
+ if (key.GetKeyboardCode() == base::VKEY_RETURN) {
// Pressing Return/Enter starts the search (unless text box is empty).
- std::wstring find_string = find_text_->text();
+ string16 find_string = find_text_->text();
if (!find_string.empty()) {
// Search forwards for enter, backwards for shift-enter.
container_->GetFindBarController()->tab_contents()->StartFinding(
find_string,
- GetKeyState(VK_SHIFT) >= 0,
+ key.IsShiftHeld(),
false); // Not case sensitive.
}
}
- #endif
return false;
}
diff --git a/chrome/browser/views/find_bar_view.h b/chrome/browser/views/find_bar_view.h
index 885e788..184482e 100644
--- a/chrome/browser/views/find_bar_view.h
+++ b/chrome/browser/views/find_bar_view.h
@@ -11,7 +11,7 @@
#include "views/controls/button/button.h"
#include "views/controls/textfield/textfield.h"
-class FindBarWin;
+class FindBarHost;
namespace views {
class ImageButton;
@@ -24,7 +24,7 @@ class View;
//
// The FindInPageView is responsible for drawing the UI controls of the
// FindInPage window, the find text box, the 'Find' button and the 'Close'
-// button. It communicates the user search words to the FindBarWin.
+// button. It communicates the user search words to the FindBarHost.
//
////////////////////////////////////////////////////////////////////////////////
class FindBarView : public views::View,
@@ -38,7 +38,7 @@ class FindBarView : public views::View,
CLOSE_TAG, // The Close button (the 'X').
};
- explicit FindBarView(FindBarWin* container);
+ explicit FindBarView(FindBarHost* container);
virtual ~FindBarView();
// Sets the text displayed in the text box.
@@ -97,7 +97,7 @@ class FindBarView : public views::View,
// Manages the OS-specific view for the find bar and acts as an intermediary
// between us and the TabContentsView.
- FindBarWin* container_;
+ FindBarHost* container_;
// The controls in the window.
views::Textfield* find_text_;
diff --git a/chrome/browser/views/options/cookies_view.cc b/chrome/browser/views/options/cookies_view.cc
index b758483..655519a 100644
--- a/chrome/browser/views/options/cookies_view.cc
+++ b/chrome/browser/views/options/cookies_view.cc
@@ -408,9 +408,9 @@ void CookiesView::ContentsChanged(views::Textfield* sender,
bool CookiesView::HandleKeystroke(views::Textfield* sender,
const views::Textfield::Keystroke& key) {
- if (views::Textfield::IsKeystrokeEscape(key)) {
+ if (key.GetKeyboardCode() == base::VKEY_ESCAPE) {
ResetSearchQuery();
- } else if (views::Textfield::IsKeystrokeEnter(key)) {
+ } else if (key.GetKeyboardCode() == base::VKEY_RETURN) {
search_update_factory_.RevokeAll();
UpdateSearchResults();
}
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index f1298d6..2eace44 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -77,7 +77,7 @@
'browser/extensions/extension_tabs_apitest.cc',
'browser/extensions/extension_i18n_apitest.cc',
'browser/views/browser_views_accessibility_browsertest.cc',
- 'browser/views/find_bar_win_browsertest.cc',
+ 'browser/views/find_bar_host_browsertest.cc',
# TODO(jam): http://crbug.com/15101 These tests fail on Linux and Mac.
'browser/child_process_security_policy_browser_test.cc',
'browser/renderer_host/test/web_cache_manager_browsertest.cc',
@@ -1963,10 +1963,12 @@
'browser/views/extensions/extension_view.h',
'browser/views/external_protocol_dialog.cc',
'browser/views/external_protocol_dialog.h',
+ 'browser/views/find_bar_host.cc',
+ 'browser/views/find_bar_host.h',
+ 'browser/views/find_bar_host_gtk.cc',
+ 'browser/views/find_bar_host_win.cc',
'browser/views/find_bar_view.cc',
'browser/views/find_bar_view.h',
- 'browser/views/find_bar_win.cc',
- 'browser/views/find_bar_win.h',
'browser/views/first_run_bubble.cc',
'browser/views/first_run_bubble.h',
'browser/views/first_run_customize_view.cc',
@@ -2467,8 +2469,9 @@
['include', '^browser/views/extension_view.h'],
['include', '^browser/views/find_bar_view.cc'],
['include', '^browser/views/find_bar_view.h'],
- ['include', '^browser/views/find_bar_win.cc'],
- ['include', '^browser/views/find_bar_win.h'],
+ ['include', '^browser/views/find_bar_host_gtk.cc'],
+ ['include', '^browser/views/find_bar_host.cc'],
+ ['include', '^browser/views/find_bar_host.h'],
['include', '^browser/views/go_button.cc'],
['include', '^browser/views/go_button.h'],
['include', '^browser/views/toolbar_star_toggle.h'],
@@ -3786,7 +3789,7 @@
'browser/tab_contents/view_source_uitest.cc',
'browser/tab_restore_uitest.cc',
'browser/unload_uitest.cc',
- 'browser/views/find_bar_win_uitest.cc',
+ 'browser/views/find_bar_host_uitest.cc',
'common/logging_chrome_uitest.cc',
'common/pref_service_uitest.cc',
'test/automation/automation_proxy_uitest.cc',
@@ -3873,7 +3876,7 @@
'browser/extensions/extension_uitest.cc',
'browser/media_uitest.cc',
'browser/printing/printing_layout_uitest.cc',
- 'browser/views/find_bar_win_uitest.cc',
+ 'browser/views/find_bar_host_uitest.cc',
'common/logging_chrome_uitest.cc',
'test/ui/npapi_uitest.cc',
'test/ui/sandbox_uitests.cc',
@@ -4349,7 +4352,7 @@
'browser/safe_browsing/safe_browsing_blocking_page_unittest.cc',
'browser/search_engines/template_url_scraper_unittest.cc',
'browser/views/bookmark_editor_view_unittest.cc',
- 'browser/views/find_bar_win_unittest.cc',
+ 'browser/views/find_bar_host_unittest.cc',
'browser/views/keyword_editor_view_unittest.cc',
'common/chrome_plugin_unittest.cc',
'common/net/url_util_unittest.cc',
@@ -5208,7 +5211,7 @@
'browser/debugger/devtools_sanity_unittest.cc',
'browser/views/bookmark_bar_view_test.cc',
'browser/blocked_popup_container_interactive_uitest.cc',
- 'browser/views/find_bar_win_interactive_uitest.cc',
+ 'browser/views/find_bar_host_interactive_uitest.cc',
'browser/views/tabs/tab_dragging_test.cc',
'test/interactive_ui/npapi_interactive_test.cc',
'test/interactive_ui/view_event_test_base.cc',
@@ -5222,7 +5225,7 @@
'sources!': [
# TODO(port)
'browser/views/bookmark_bar_view_test.cc',
- 'browser/views/find_bar_win_interactive_uitest.cc',
+ 'browser/views/find_bar_host_interactive_uitest.cc',
'browser/views/tabs/tab_dragging_test.cc',
'test/interactive_ui/npapi_interactive_test.cc',
'test/interactive_ui/view_event_test_base.cc',
@@ -5247,7 +5250,7 @@
'browser/debugger/devtools_sanity_unittest.cc',
'browser/views/bookmark_bar_view_test.cc',
'browser/blocked_popup_container_interactive_uitest.cc',
- 'browser/views/find_bar_win_interactive_uitest.cc',
+ 'browser/views/find_bar_host_interactive_uitest.cc',
'browser/views/tabs/tab_dragging_test.cc',
'test/interactive_ui/npapi_interactive_test.cc',
'test/interactive_ui/view_event_test_base.cc',