| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "chrome/browser/search/search.h" | 9 #include "chrome/browser/search/search.h" |
| 10 #include "chrome/browser/themes/theme_properties.h" | 10 #include "chrome/browser/themes/theme_properties.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 186 |
| 187 // If we're animating and our target height changes, reset the animation. | 187 // If we're animating and our target height changes, reset the animation. |
| 188 // NOTE: If we just reset blindly on _every_ update, then when the user types | 188 // NOTE: If we just reset blindly on _every_ update, then when the user types |
| 189 // rapidly we could get "stuck" trying repeatedly to animate shrinking by the | 189 // rapidly we could get "stuck" trying repeatedly to animate shrinking by the |
| 190 // last few pixels to get to one visible result. | 190 // last few pixels to get to one visible result. |
| 191 if (new_target_bounds.height() != target_bounds_.height()) | 191 if (new_target_bounds.height() != target_bounds_.height()) |
| 192 size_animation_.Reset(); | 192 size_animation_.Reset(); |
| 193 target_bounds_ = new_target_bounds; | 193 target_bounds_ = new_target_bounds; |
| 194 | 194 |
| 195 if (popup_ == NULL) { | 195 if (popup_ == NULL) { |
| 196 gfx::NativeView popup_parent = | 196 views::Widget* popup_parent = location_bar_view_->GetWidget(); |
| 197 location_bar_view_->GetWidget()->GetNativeView(); | |
| 198 | 197 |
| 199 // If the popup is currently closed, we need to create it. | 198 // If the popup is currently closed, we need to create it. |
| 200 popup_ = (new AutocompletePopupWidget)->AsWeakPtr(); | 199 popup_ = (new AutocompletePopupWidget)->AsWeakPtr(); |
| 201 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 200 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
| 202 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 201 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 203 params.parent = popup_parent; | 202 params.parent = popup_parent->GetNativeView(); |
| 204 params.bounds = GetPopupBounds(); | 203 params.bounds = GetPopupBounds(); |
| 205 params.context = popup_parent; | 204 params.context = popup_parent->GetNativeWindow(); |
| 206 popup_->Init(params); | 205 popup_->Init(params); |
| 207 // Third-party software such as DigitalPersona identity verification can | 206 // Third-party software such as DigitalPersona identity verification can |
| 208 // hook the underlying window creation methods and use SendMessage to | 207 // hook the underlying window creation methods and use SendMessage to |
| 209 // synchronously change focus/activation, resulting in the popup being | 208 // synchronously change focus/activation, resulting in the popup being |
| 210 // destroyed by the time control returns here. Bail out in this case to | 209 // destroyed by the time control returns here. Bail out in this case to |
| 211 // avoid a NULL dereference. | 210 // avoid a NULL dereference. |
| 212 if (!popup_.get()) | 211 if (!popup_.get()) |
| 213 return; | 212 return; |
| 214 wm::SetWindowVisibilityAnimationTransition( | 213 wm::SetWindowVisibilityAnimationTransition( |
| 215 popup_->GetNativeView(), wm::ANIMATE_NONE); | 214 popup_->GetNativeView(), wm::ANIMATE_NONE); |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 size_t index = GetIndexForPoint(event.location()); | 491 size_t index = GetIndexForPoint(event.location()); |
| 493 if (!HasMatchAt(index)) | 492 if (!HasMatchAt(index)) |
| 494 return; | 493 return; |
| 495 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, | 494 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, |
| 496 GURL(), base::string16(), index); | 495 GURL(), base::string16(), index); |
| 497 } | 496 } |
| 498 | 497 |
| 499 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { | 498 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { |
| 500 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); | 499 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); |
| 501 } | 500 } |
| OLD | NEW |