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