| 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" |
| 11 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 11 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 13 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h" | 13 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h" |
| 14 #include "chrome/browser/ui/views/omnibox/touch_omnibox_popup_contents_view.h" | 14 #include "chrome/browser/ui/views/omnibox/touch_omnibox_popup_contents_view.h" |
| 15 #include "grit/ui_resources.h" | 15 #include "grit/ui_resources.h" |
| 16 #include "ui/base/theme_provider.h" | 16 #include "ui/base/theme_provider.h" |
| 17 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
| 18 #include "ui/gfx/image/image.h" | 18 #include "ui/gfx/image/image.h" |
| 19 #include "ui/gfx/path.h" | 19 #include "ui/gfx/path.h" |
| 20 #include "ui/views/controls/image_view.h" | 20 #include "ui/views/controls/image_view.h" |
| 21 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
| 22 #include "ui/views/window/non_client_view.h" | 22 #include "ui/views/window/non_client_view.h" |
| 23 | |
| 24 #if defined(USE_AURA) | |
| 25 #include "ui/wm/core/window_animations.h" | 23 #include "ui/wm/core/window_animations.h" |
| 26 #endif | |
| 27 | 24 |
| 28 // This is the number of pixels in the border image interior to the actual | 25 // This is the number of pixels in the border image interior to the actual |
| 29 // border. | 26 // border. |
| 30 const int kBorderInterior = 6; | 27 const int kBorderInterior = 6; |
| 31 | 28 |
| 32 class OmniboxPopupContentsView::AutocompletePopupWidget | 29 class OmniboxPopupContentsView::AutocompletePopupWidget |
| 33 : public views::Widget, | 30 : public views::Widget, |
| 34 public base::SupportsWeakPtr<AutocompletePopupWidget> { | 31 public base::SupportsWeakPtr<AutocompletePopupWidget> { |
| 35 public: | 32 public: |
| 36 AutocompletePopupWidget() {} | 33 AutocompletePopupWidget() {} |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 params.bounds = GetPopupBounds(); | 212 params.bounds = GetPopupBounds(); |
| 216 params.context = popup_parent; | 213 params.context = popup_parent; |
| 217 popup_->Init(params); | 214 popup_->Init(params); |
| 218 // Third-party software such as DigitalPersona identity verification can | 215 // Third-party software such as DigitalPersona identity verification can |
| 219 // hook the underlying window creation methods and use SendMessage to | 216 // hook the underlying window creation methods and use SendMessage to |
| 220 // synchronously change focus/activation, resulting in the popup being | 217 // synchronously change focus/activation, resulting in the popup being |
| 221 // destroyed by the time control returns here. Bail out in this case to | 218 // destroyed by the time control returns here. Bail out in this case to |
| 222 // avoid a NULL dereference. | 219 // avoid a NULL dereference. |
| 223 if (!popup_.get()) | 220 if (!popup_.get()) |
| 224 return; | 221 return; |
| 225 #if defined(USE_AURA) | |
| 226 wm::SetWindowVisibilityAnimationTransition( | 222 wm::SetWindowVisibilityAnimationTransition( |
| 227 popup_->GetNativeView(), wm::ANIMATE_NONE); | 223 popup_->GetNativeView(), wm::ANIMATE_NONE); |
| 228 #endif | |
| 229 popup_->SetContentsView(this); | 224 popup_->SetContentsView(this); |
| 230 popup_->StackAbove(omnibox_view_->GetRelativeWindowForPopup()); | 225 popup_->StackAbove(omnibox_view_->GetRelativeWindowForPopup()); |
| 231 if (!popup_.get()) { | 226 if (!popup_.get()) { |
| 232 // For some IMEs GetRelativeWindowForPopup triggers the omnibox to lose | 227 // For some IMEs GetRelativeWindowForPopup triggers the omnibox to lose |
| 233 // focus, thereby closing (and destroying) the popup. | 228 // focus, thereby closing (and destroying) the popup. |
| 234 // TODO(sky): this won't be needed once we close the omnibox on input | 229 // TODO(sky): this won't be needed once we close the omnibox on input |
| 235 // window showing. | 230 // window showing. |
| 236 return; | 231 return; |
| 237 } | 232 } |
| 238 popup_->ShowInactive(); | 233 popup_->ShowInactive(); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 size_t index = GetIndexForPoint(event.location()); | 499 size_t index = GetIndexForPoint(event.location()); |
| 505 if (!HasMatchAt(index)) | 500 if (!HasMatchAt(index)) |
| 506 return; | 501 return; |
| 507 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, | 502 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, |
| 508 GURL(), base::string16(), index); | 503 GURL(), base::string16(), index); |
| 509 } | 504 } |
| 510 | 505 |
| 511 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { | 506 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { |
| 512 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); | 507 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); |
| 513 } | 508 } |
| OLD | NEW |