Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(607)

Side by Side Diff: chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc

Issue 7015051: Re-land: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view. h" 5 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view. h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" 9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h"
10 #include "chrome/browser/instant/instant_confirm_dialog.h" 10 #include "chrome/browser/instant/instant_confirm_dialog.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 gfx::Insets insets(h, w, h, w); 110 gfx::Insets insets(h, w, h, w);
111 return views::Painter::CreateImagePainter(*image, insets, true); 111 return views::Painter::CreateImagePainter(*image, insets, true);
112 } 112 }
113 113
114 scoped_ptr<views::Painter> border_painter_; 114 scoped_ptr<views::Painter> border_painter_;
115 scoped_ptr<views::Painter> border_pushed_painter_; 115 scoped_ptr<views::Painter> border_pushed_painter_;
116 116
117 DISALLOW_COPY_AND_ASSIGN(OptInButtonBorder); 117 DISALLOW_COPY_AND_ASSIGN(OptInButtonBorder);
118 }; 118 };
119 119
120 gfx::NativeView GetRelativeWindowForPopup(gfx::NativeView edit_native_view) {
121 #if defined(OS_WIN)
122 // When an IME is attached to the rich-edit control, retrieve its window
123 // handle and show this popup window under the IME windows.
124 // Otherwise, show this popup window under top-most windows.
125 // TODO(hbono): http://b/1111369 if we exclude this popup window from the
126 // display area of IME windows, this workaround becomes unnecessary.
127 HWND ime_window = ImmGetDefaultIMEWnd(edit_native_view);
128 return ime_window ? ime_window : HWND_NOTOPMOST;
129 #elif defined(TOOLKIT_USES_GTK)
130 GtkWidget* toplevel = gtk_widget_get_toplevel(edit_native_view);
131 DCHECK(GTK_WIDGET_TOPLEVEL(toplevel));
132 return toplevel;
133 #endif
134 }
135
120 } // namespace 136 } // namespace
121 137
138 class AutocompletePopupContentsView::AutocompletePopupWidget
139 : public views::Widget,
140 public base::SupportsWeakPtr<AutocompletePopupWidget> {
141 public:
142 AutocompletePopupWidget() {}
143 virtual ~AutocompletePopupWidget() {}
144
145 private:
146 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWidget);
147 };
148
122 class AutocompletePopupContentsView::InstantOptInView 149 class AutocompletePopupContentsView::InstantOptInView
123 : public views::View, 150 : public views::View,
124 public views::ButtonListener { 151 public views::ButtonListener {
125 public: 152 public:
126 InstantOptInView(AutocompletePopupContentsView* contents_view, 153 InstantOptInView(AutocompletePopupContentsView* contents_view,
127 const gfx::Font& label_font, 154 const gfx::Font& label_font,
128 const gfx::Font& button_font) 155 const gfx::Font& button_font)
129 : contents_view_(contents_view), 156 : contents_view_(contents_view),
130 bg_painter_(views::Painter::CreateVerticalGradient( 157 bg_painter_(views::Painter::CreateVerticalGradient(
131 SkColorSetRGB(255, 242, 183), 158 SkColorSetRGB(255, 242, 183),
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 // If we're animating and our target height changes, reset the animation. 348 // If we're animating and our target height changes, reset the animation.
322 // NOTE: If we just reset blindly on _every_ update, then when the user types 349 // NOTE: If we just reset blindly on _every_ update, then when the user types
323 // rapidly we could get "stuck" trying repeatedly to animate shrinking by the 350 // rapidly we could get "stuck" trying repeatedly to animate shrinking by the
324 // last few pixels to get to one visible result. 351 // last few pixels to get to one visible result.
325 if (new_target_bounds.height() != target_bounds_.height()) 352 if (new_target_bounds.height() != target_bounds_.height())
326 size_animation_.Reset(); 353 size_animation_.Reset();
327 target_bounds_ = new_target_bounds; 354 target_bounds_ = new_target_bounds;
328 355
329 if (popup_ == NULL) { 356 if (popup_ == NULL) {
330 // If the popup is currently closed, we need to create it. 357 // If the popup is currently closed, we need to create it.
331 popup_ = (new AutocompletePopupClass)->AsWeakPtr(); 358 popup_ = (new AutocompletePopupWidget)->AsWeakPtr();
332 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); 359 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
333 params.can_activate = false; 360 params.can_activate = false;
334 params.transparent = true; 361 params.transparent = true;
335 params.parent = location_bar_->GetWidget()->GetNativeView(); 362 params.parent = location_bar_->GetWidget()->GetNativeView();
336 params.bounds = GetPopupBounds(); 363 params.bounds = GetPopupBounds();
337 popup_->GetWidget()->Init(params); 364 popup_->Init(params);
338 popup_->SetContentsView(this); 365 popup_->SetContentsView(this);
339 popup_->MoveAbove(popup_->GetRelativeWindowForPopup( 366 popup_->MoveAbove(
340 omnibox_view_->GetNativeView())); 367 GetRelativeWindowForPopup(omnibox_view_->GetNativeView()));
341 popup_->Show(); 368 popup_->Show();
342 } else { 369 } else {
343 // Animate the popup shrinking, but don't animate growing larger since that 370 // Animate the popup shrinking, but don't animate growing larger since that
344 // would make the popup feel less responsive. 371 // would make the popup feel less responsive.
345 start_bounds_ = GetWidget()->GetWindowScreenBounds(); 372 start_bounds_ = GetWidget()->GetWindowScreenBounds();
346 if (target_bounds_.height() < start_bounds_.height()) 373 if (target_bounds_.height() < start_bounds_.height())
347 size_animation_.Show(); 374 size_animation_.Show();
348 else 375 else
349 start_bounds_ = target_bounds_; 376 start_bounds_ = target_bounds_;
350 popup_->SetBounds(GetPopupBounds()); 377 popup_->SetBounds(GetPopupBounds());
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 opt_in_view_ = NULL; 702 opt_in_view_ = NULL;
676 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); 703 PromoCounter* counter = model_->profile()->GetInstantPromoCounter();
677 DCHECK(counter); 704 DCHECK(counter);
678 counter->Hide(); 705 counter->Hide();
679 if (opt_in) { 706 if (opt_in) {
680 browser::ShowInstantConfirmDialogIfNecessary( 707 browser::ShowInstantConfirmDialogIfNecessary(
681 location_bar_->GetWindow()->GetNativeWindow(), model_->profile()); 708 location_bar_->GetWindow()->GetNativeWindow(), model_->profile());
682 } 709 }
683 UpdatePopupAppearance(); 710 UpdatePopupAppearance();
684 } 711 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698