OLD | NEW |
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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 DISALLOW_COPY_AND_ASSIGN(InstantOptInView); | 222 DISALLOW_COPY_AND_ASSIGN(InstantOptInView); |
223 }; | 223 }; |
224 | 224 |
225 //////////////////////////////////////////////////////////////////////////////// | 225 //////////////////////////////////////////////////////////////////////////////// |
226 // AutocompletePopupContentsView, public: | 226 // AutocompletePopupContentsView, public: |
227 | 227 |
228 AutocompletePopupContentsView::AutocompletePopupContentsView( | 228 AutocompletePopupContentsView::AutocompletePopupContentsView( |
229 const gfx::Font& font, | 229 const gfx::Font& font, |
230 OmniboxView* omnibox_view, | 230 OmniboxView* omnibox_view, |
231 AutocompleteEditModel* edit_model, | 231 AutocompleteEditModel* edit_model, |
232 Profile* profile, | |
233 const views::View* location_bar) | 232 const views::View* location_bar) |
234 : model_(new AutocompletePopupModel(this, edit_model, profile)), | 233 : model_(new AutocompletePopupModel(this, edit_model)), |
235 opt_in_view_(NULL), | 234 opt_in_view_(NULL), |
236 omnibox_view_(omnibox_view), | 235 omnibox_view_(omnibox_view), |
| 236 profile_(edit_model->profile()), |
237 location_bar_(location_bar), | 237 location_bar_(location_bar), |
238 result_font_(font.DeriveFont(kEditFontAdjust)), | 238 result_font_(font.DeriveFont(kEditFontAdjust)), |
239 result_bold_font_(result_font_.DeriveFont(0, gfx::Font::BOLD)), | 239 result_bold_font_(result_font_.DeriveFont(0, gfx::Font::BOLD)), |
240 ignore_mouse_drag_(false), | 240 ignore_mouse_drag_(false), |
241 ALLOW_THIS_IN_INITIALIZER_LIST(size_animation_(this)) { | 241 ALLOW_THIS_IN_INITIALIZER_LIST(size_animation_(this)) { |
242 // The following little dance is required because set_border() requires a | 242 // The following little dance is required because set_border() requires a |
243 // pointer to a non-const object. | 243 // pointer to a non-const object. |
244 BubbleBorder* bubble_border = new BubbleBorder(BubbleBorder::NONE); | 244 BubbleBorder* bubble_border = new BubbleBorder(BubbleBorder::NONE); |
245 bubble_border_ = bubble_border; | 245 bubble_border_ = bubble_border; |
246 set_border(bubble_border); | 246 set_border(bubble_border); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 AddChildViewAt(result_view, static_cast<int>(i)); | 324 AddChildViewAt(result_view, static_cast<int>(i)); |
325 } else { | 325 } else { |
326 result_view = static_cast<AutocompleteResultView*>(child_at(i)); | 326 result_view = static_cast<AutocompleteResultView*>(child_at(i)); |
327 result_view->SetVisible(true); | 327 result_view->SetVisible(true); |
328 } | 328 } |
329 result_view->SetMatch(GetMatchAtIndex(i)); | 329 result_view->SetMatch(GetMatchAtIndex(i)); |
330 } | 330 } |
331 for (size_t i = model_->result().size(); i < child_rv_count; ++i) | 331 for (size_t i = model_->result().size(); i < child_rv_count; ++i) |
332 child_at(i)->SetVisible(false); | 332 child_at(i)->SetVisible(false); |
333 | 333 |
334 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); | 334 PromoCounter* counter = profile_->GetInstantPromoCounter(); |
335 if (!opt_in_view_ && counter && counter->ShouldShow(base::Time::Now())) { | 335 if (!opt_in_view_ && counter && counter->ShouldShow(base::Time::Now())) { |
336 opt_in_view_ = new InstantOptInView(this, result_bold_font_, result_font_); | 336 opt_in_view_ = new InstantOptInView(this, result_bold_font_, result_font_); |
337 AddChildView(opt_in_view_); | 337 AddChildView(opt_in_view_); |
338 } else if (opt_in_view_ && (!counter || | 338 } else if (opt_in_view_ && (!counter || |
339 !counter->ShouldShow(base::Time::Now()))) { | 339 !counter->ShouldShow(base::Time::Now()))) { |
340 delete opt_in_view_; | 340 delete opt_in_view_; |
341 opt_in_view_ = NULL; | 341 opt_in_view_ = NULL; |
342 } | 342 } |
343 | 343 |
344 gfx::Rect new_target_bounds = CalculateTargetBounds(CalculatePopupHeight()); | 344 gfx::Rect new_target_bounds = CalculateTargetBounds(CalculatePopupHeight()); |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 gfx::Point location_bar_origin(location_bar_bounds.origin()); | 687 gfx::Point location_bar_origin(location_bar_bounds.origin()); |
688 views::View::ConvertPointToScreen(location_bar_, &location_bar_origin); | 688 views::View::ConvertPointToScreen(location_bar_, &location_bar_origin); |
689 location_bar_bounds.set_origin(location_bar_origin); | 689 location_bar_bounds.set_origin(location_bar_origin); |
690 return bubble_border_->GetBounds( | 690 return bubble_border_->GetBounds( |
691 location_bar_bounds, gfx::Size(location_bar_bounds.width(), h)); | 691 location_bar_bounds, gfx::Size(location_bar_bounds.width(), h)); |
692 } | 692 } |
693 | 693 |
694 void AutocompletePopupContentsView::UserPressedOptIn(bool opt_in) { | 694 void AutocompletePopupContentsView::UserPressedOptIn(bool opt_in) { |
695 delete opt_in_view_; | 695 delete opt_in_view_; |
696 opt_in_view_ = NULL; | 696 opt_in_view_ = NULL; |
697 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); | 697 PromoCounter* counter = profile_->GetInstantPromoCounter(); |
698 DCHECK(counter); | 698 DCHECK(counter); |
699 counter->Hide(); | 699 counter->Hide(); |
700 if (opt_in) { | 700 if (opt_in) { |
701 browser::ShowInstantConfirmDialogIfNecessary( | 701 browser::ShowInstantConfirmDialogIfNecessary( |
702 location_bar_->GetWidget()->GetNativeWindow(), model_->profile()); | 702 location_bar_->GetWidget()->GetNativeWindow(), profile_); |
703 } | 703 } |
704 UpdatePopupAppearance(); | 704 UpdatePopupAppearance(); |
705 } | 705 } |
OLD | NEW |