OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/omnibox/omnibox_popup_contents_view.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" |
6 | 6 |
7 #include "chrome/browser/search/search.h" | 7 #include "chrome/browser/search/search.h" |
8 #include "chrome/browser/themes/theme_properties.h" | 8 #include "chrome/browser/themes/theme_properties.h" |
9 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 9 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 // This is the number of pixels in the border image interior to the actual | 34 // This is the number of pixels in the border image interior to the actual |
35 // border. | 35 // border. |
36 const int kBorderInterior = 6; | 36 const int kBorderInterior = 6; |
37 | 37 |
38 } // namespace | 38 } // namespace |
39 | 39 |
40 class OmniboxPopupContentsView::AutocompletePopupWidget | 40 class OmniboxPopupContentsView::AutocompletePopupWidget |
41 : public views::Widget, | 41 : public views::Widget, |
42 public base::SupportsWeakPtr<AutocompletePopupWidget> { | 42 public base::SupportsWeakPtr<AutocompletePopupWidget> { |
43 public: | 43 public: |
44 AutocompletePopupWidget() {} | 44 AutocompletePopupWidget() : crash_if_destroyed_(false) {} |
45 virtual ~AutocompletePopupWidget() {} | 45 virtual ~AutocompletePopupWidget() { |
| 46 CHECK(!crash_if_destroyed_); |
| 47 } |
| 48 |
| 49 void set_crash_if_destroyed(bool value) { crash_if_destroyed_ = value; } |
46 | 50 |
47 private: | 51 private: |
| 52 // For debugging a crash. |
| 53 // TODO(sky): nuke this when we figure out 275794. |
| 54 bool crash_if_destroyed_; |
| 55 |
48 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWidget); | 56 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWidget); |
49 }; | 57 }; |
50 | 58 |
51 //////////////////////////////////////////////////////////////////////////////// | 59 //////////////////////////////////////////////////////////////////////////////// |
52 // OmniboxPopupContentsView, public: | 60 // OmniboxPopupContentsView, public: |
53 | 61 |
54 OmniboxPopupView* OmniboxPopupContentsView::Create( | 62 OmniboxPopupView* OmniboxPopupContentsView::Create( |
55 const gfx::FontList& font_list, | 63 const gfx::FontList& font_list, |
56 OmniboxView* omnibox_view, | 64 OmniboxView* omnibox_view, |
57 OmniboxEditModel* edit_model, | 65 OmniboxEditModel* edit_model, |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 location_bar_view_->GetWidget()->GetNativeView(); | 216 location_bar_view_->GetWidget()->GetNativeView(); |
209 | 217 |
210 // If the popup is currently closed, we need to create it. | 218 // If the popup is currently closed, we need to create it. |
211 popup_ = (new AutocompletePopupWidget)->AsWeakPtr(); | 219 popup_ = (new AutocompletePopupWidget)->AsWeakPtr(); |
212 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 220 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
213 params.can_activate = false; | 221 params.can_activate = false; |
214 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 222 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
215 params.parent = popup_parent; | 223 params.parent = popup_parent; |
216 params.bounds = GetPopupBounds(); | 224 params.bounds = GetPopupBounds(); |
217 params.context = popup_parent; | 225 params.context = popup_parent; |
| 226 popup_->set_crash_if_destroyed(true); |
218 popup_->Init(params); | 227 popup_->Init(params); |
| 228 popup_->set_crash_if_destroyed(false); |
219 #if defined(USE_AURA) | 229 #if defined(USE_AURA) |
220 views::corewm::SetWindowVisibilityAnimationType( | 230 views::corewm::SetWindowVisibilityAnimationType( |
221 popup_->GetNativeView(), | 231 popup_->GetNativeView(), |
222 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL); | 232 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL); |
223 #if defined(OS_CHROMEOS) | 233 #if defined(OS_CHROMEOS) |
224 // No animation for autocomplete popup appearance. | 234 // No animation for autocomplete popup appearance. |
225 views::corewm::SetWindowVisibilityAnimationTransition( | 235 views::corewm::SetWindowVisibilityAnimationTransition( |
226 popup_->GetNativeView(), views::corewm::ANIMATE_HIDE); | 236 popup_->GetNativeView(), views::corewm::ANIMATE_HIDE); |
227 #endif | 237 #endif |
228 #endif | 238 #endif |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 // OpenMatch() may close the popup, which will clear the result set and, by | 519 // OpenMatch() may close the popup, which will clear the result set and, by |
510 // extension, |match| and its contents. So copy the relevant match out to | 520 // extension, |match| and its contents. So copy the relevant match out to |
511 // make sure it stays alive until the call completes. | 521 // make sure it stays alive until the call completes. |
512 AutocompleteMatch match = model_->result().match_at(index); | 522 AutocompleteMatch match = model_->result().match_at(index); |
513 omnibox_view_->OpenMatch(match, disposition, GURL(), index); | 523 omnibox_view_->OpenMatch(match, disposition, GURL(), index); |
514 } | 524 } |
515 | 525 |
516 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { | 526 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { |
517 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); | 527 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); |
518 } | 528 } |
OLD | NEW |