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

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

Issue 7806015: Adds some debugging code to figure out why we crash when showing the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add setting value Created 9 years, 3 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
« no previous file with comments | « chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/auto_reset.h"
7 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
8 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" 10 #include "chrome/browser/autocomplete/autocomplete_popup_model.h"
10 #include "chrome/browser/instant/instant_confirm_dialog.h" 11 #include "chrome/browser/instant/instant_confirm_dialog.h"
11 #include "chrome/browser/instant/promo_counter.h" 12 #include "chrome/browser/instant/promo_counter.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/omnibox/omnibox_view.h" 14 #include "chrome/browser/ui/omnibox/omnibox_view.h"
14 #include "chrome/browser/ui/views/autocomplete/autocomplete_result_view.h" 15 #include "chrome/browser/ui/views/autocomplete/autocomplete_result_view.h"
15 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 16 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
16 #include "grit/chromium_strings.h" 17 #include "grit/chromium_strings.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 return toplevel; 132 return toplevel;
132 #endif 133 #endif
133 } 134 }
134 135
135 } // namespace 136 } // namespace
136 137
137 class AutocompletePopupContentsView::AutocompletePopupWidget 138 class AutocompletePopupContentsView::AutocompletePopupWidget
138 : public views::Widget, 139 : public views::Widget,
139 public base::SupportsWeakPtr<AutocompletePopupWidget> { 140 public base::SupportsWeakPtr<AutocompletePopupWidget> {
140 public: 141 public:
141 AutocompletePopupWidget() {} 142 AutocompletePopupWidget() : check_on_destroy_(false) {}
142 virtual ~AutocompletePopupWidget() {} 143 virtual ~AutocompletePopupWidget() {
144 CHECK(!check_on_destroy_);
145 }
143 146
144 private: 147 private:
145 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWidget); 148 // TODO(sky): remove once we figure out 92497.
149 friend class AutocompletePopupContentsView;
150
151 bool check_on_destroy_;
152
153 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWidget);
146 }; 154 };
147 155
148 class AutocompletePopupContentsView::InstantOptInView 156 class AutocompletePopupContentsView::InstantOptInView
149 : public views::View, 157 : public views::View,
150 public views::ButtonListener { 158 public views::ButtonListener {
151 public: 159 public:
152 InstantOptInView(AutocompletePopupContentsView* contents_view, 160 InstantOptInView(AutocompletePopupContentsView* contents_view,
153 const gfx::Font& label_font, 161 const gfx::Font& label_font,
154 const gfx::Font& button_font) 162 const gfx::Font& button_font)
155 : contents_view_(contents_view), 163 : contents_view_(contents_view),
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 AutocompleteEditModel* edit_model, 239 AutocompleteEditModel* edit_model,
232 views::View* location_bar) 240 views::View* location_bar)
233 : model_(new AutocompletePopupModel(this, edit_model)), 241 : model_(new AutocompletePopupModel(this, edit_model)),
234 opt_in_view_(NULL), 242 opt_in_view_(NULL),
235 omnibox_view_(omnibox_view), 243 omnibox_view_(omnibox_view),
236 profile_(edit_model->profile()), 244 profile_(edit_model->profile()),
237 location_bar_(location_bar), 245 location_bar_(location_bar),
238 result_font_(font.DeriveFont(kEditFontAdjust)), 246 result_font_(font.DeriveFont(kEditFontAdjust)),
239 result_bold_font_(result_font_.DeriveFont(0, gfx::Font::BOLD)), 247 result_bold_font_(result_font_.DeriveFont(0, gfx::Font::BOLD)),
240 ignore_mouse_drag_(false), 248 ignore_mouse_drag_(false),
241 ALLOW_THIS_IN_INITIALIZER_LIST(size_animation_(this)) { 249 ALLOW_THIS_IN_INITIALIZER_LIST(size_animation_(this)),
250 in_move_above_(false) {
242 // The following little dance is required because set_border() requires a 251 // The following little dance is required because set_border() requires a
243 // pointer to a non-const object. 252 // pointer to a non-const object.
244 views::BubbleBorder* bubble_border = 253 views::BubbleBorder* bubble_border =
245 new views::BubbleBorder(views::BubbleBorder::NONE); 254 new views::BubbleBorder(views::BubbleBorder::NONE);
246 bubble_border_ = bubble_border; 255 bubble_border_ = bubble_border;
247 set_border(bubble_border); 256 set_border(bubble_border);
248 // The contents is owned by the LocationBarView. 257 // The contents is owned by the LocationBarView.
249 set_parent_owned(false); 258 set_parent_owned(false);
250 } 259 }
251 260
252 AutocompletePopupContentsView::~AutocompletePopupContentsView() { 261 AutocompletePopupContentsView::~AutocompletePopupContentsView() {
262 CHECK(!in_move_above_);
253 // We don't need to do anything with |popup_| here. The OS either has already 263 // We don't need to do anything with |popup_| here. The OS either has already
254 // closed the window, in which case it's been deleted, or it will soon, in 264 // closed the window, in which case it's been deleted, or it will soon, in
255 // which case there's nothing we need to do. 265 // which case there's nothing we need to do.
256 } 266 }
257 267
258 gfx::Rect AutocompletePopupContentsView::GetPopupBounds() const { 268 gfx::Rect AutocompletePopupContentsView::GetPopupBounds() const {
259 if (!size_animation_.is_animating()) 269 if (!size_animation_.is_animating())
260 return target_bounds_; 270 return target_bounds_;
261 271
262 gfx::Rect current_frame_bounds = start_bounds_; 272 gfx::Rect current_frame_bounds = start_bounds_;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 307
298 void AutocompletePopupContentsView::UpdatePopupAppearance() { 308 void AutocompletePopupContentsView::UpdatePopupAppearance() {
299 if (model_->result().empty()) { 309 if (model_->result().empty()) {
300 // No matches, close any existing popup. 310 // No matches, close any existing popup.
301 if (popup_ != NULL) { 311 if (popup_ != NULL) {
302 size_animation_.Stop(); 312 size_animation_.Stop();
303 // NOTE: Do NOT use CloseNow() here, as we may be deep in a callstack 313 // NOTE: Do NOT use CloseNow() here, as we may be deep in a callstack
304 // triggered by the popup receiving a message (e.g. LBUTTONUP), and 314 // triggered by the popup receiving a message (e.g. LBUTTONUP), and
305 // destroying the popup would cause us to read garbage when we unwind back 315 // destroying the popup would cause us to read garbage when we unwind back
306 // to that level. 316 // to that level.
317 CHECK(!in_move_above_);
307 popup_->Close(); // This will eventually delete the popup. 318 popup_->Close(); // This will eventually delete the popup.
308 popup_.reset(); 319 popup_.reset();
309 } 320 }
310 return; 321 return;
311 } 322 }
312 323
313 // Update the match cached by each row, in the process of doing so make sure 324 // Update the match cached by each row, in the process of doing so make sure
314 // we have enough row views. 325 // we have enough row views.
315 size_t child_rv_count = child_count(); 326 size_t child_rv_count = child_count();
316 if (opt_in_view_) { 327 if (opt_in_view_) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 if (popup_ == NULL) { 366 if (popup_ == NULL) {
356 // If the popup is currently closed, we need to create it. 367 // If the popup is currently closed, we need to create it.
357 popup_ = (new AutocompletePopupWidget)->AsWeakPtr(); 368 popup_ = (new AutocompletePopupWidget)->AsWeakPtr();
358 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); 369 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
359 params.can_activate = false; 370 params.can_activate = false;
360 params.transparent = true; 371 params.transparent = true;
361 params.parent_widget = location_bar_->GetWidget(); 372 params.parent_widget = location_bar_->GetWidget();
362 params.bounds = GetPopupBounds(); 373 params.bounds = GetPopupBounds();
363 popup_->Init(params); 374 popup_->Init(params);
364 popup_->SetContentsView(this); 375 popup_->SetContentsView(this);
365 popup_->MoveAbove( 376 {
366 GetRelativeWindowForPopup(omnibox_view_->GetNativeView())); 377 AutoReset<bool> in_move_above_reset(&in_move_above_, true);
378 AutoReset<bool> check_on_destroy_reset(&popup_->check_on_destroy_, true);
379 popup_->MoveAbove(
380 GetRelativeWindowForPopup(omnibox_view_->GetNativeView()));
381 }
367 popup_->Show(); 382 popup_->Show();
368 } else { 383 } else {
369 // Animate the popup shrinking, but don't animate growing larger since that 384 // Animate the popup shrinking, but don't animate growing larger since that
370 // would make the popup feel less responsive. 385 // would make the popup feel less responsive.
371 start_bounds_ = GetWidget()->GetWindowScreenBounds(); 386 start_bounds_ = GetWidget()->GetWindowScreenBounds();
372 if (target_bounds_.height() < start_bounds_.height()) 387 if (target_bounds_.height() < start_bounds_.height())
373 size_animation_.Show(); 388 size_animation_.Show();
374 else 389 else
375 start_bounds_ = target_bounds_; 390 start_bounds_ = target_bounds_;
376 popup_->SetBounds(GetPopupBounds()); 391 popup_->SetBounds(GetPopupBounds());
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 opt_in_view_ = NULL; 712 opt_in_view_ = NULL;
698 PromoCounter* counter = profile_->GetInstantPromoCounter(); 713 PromoCounter* counter = profile_->GetInstantPromoCounter();
699 DCHECK(counter); 714 DCHECK(counter);
700 counter->Hide(); 715 counter->Hide();
701 if (opt_in) { 716 if (opt_in) {
702 browser::ShowInstantConfirmDialogIfNecessary( 717 browser::ShowInstantConfirmDialogIfNecessary(
703 location_bar_->GetWidget()->GetNativeWindow(), profile_); 718 location_bar_->GetWidget()->GetNativeWindow(), profile_);
704 } 719 }
705 UpdatePopupAppearance(); 720 UpdatePopupAppearance();
706 } 721 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698