Chromium Code Reviews| 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 13 matching lines...) Expand all Loading... | |
| 24 #include "ui/views/controls/image_view.h" | 24 #include "ui/views/controls/image_view.h" |
| 25 #include "ui/views/resources/grit/views_resources.h" | 25 #include "ui/views/resources/grit/views_resources.h" |
| 26 #include "ui/views/view_targeter.h" | 26 #include "ui/views/view_targeter.h" |
| 27 #include "ui/views/widget/widget.h" | 27 #include "ui/views/widget/widget.h" |
| 28 #include "ui/views/window/non_client_view.h" | 28 #include "ui/views/window/non_client_view.h" |
| 29 | 29 |
| 30 class OmniboxPopupContentsView::AutocompletePopupWidget | 30 class OmniboxPopupContentsView::AutocompletePopupWidget |
| 31 : public views::Widget, | 31 : public views::Widget, |
| 32 public base::SupportsWeakPtr<AutocompletePopupWidget> { | 32 public base::SupportsWeakPtr<AutocompletePopupWidget> { |
| 33 public: | 33 public: |
| 34 AutocompletePopupWidget() {} | 34 explicit AutocompletePopupWidget(views::Widget* popup_parent) |
| 35 : popup_parent_(popup_parent) {} | |
| 35 ~AutocompletePopupWidget() override {} | 36 ~AutocompletePopupWidget() override {} |
| 36 | 37 |
| 38 const ui::NativeTheme* GetNativeTheme() const override { | |
| 39 return popup_parent_->GetNativeTheme(); | |
| 40 } | |
| 41 | |
| 37 private: | 42 private: |
| 43 // The transient parent of this popup. | |
| 44 views::Widget* popup_parent_; | |
|
Peter Kasting
2015/11/14 02:46:08
Nit: Just call this |parent_| since "popup" is alr
Evan Stade
2015/11/16 19:36:33
this change reverted
| |
| 45 | |
| 38 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWidget); | 46 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWidget); |
| 39 }; | 47 }; |
| 40 | 48 |
| 41 //////////////////////////////////////////////////////////////////////////////// | 49 //////////////////////////////////////////////////////////////////////////////// |
| 42 // OmniboxPopupContentsView, public: | 50 // OmniboxPopupContentsView, public: |
| 43 | 51 |
| 44 OmniboxPopupView* OmniboxPopupContentsView::Create( | 52 OmniboxPopupView* OmniboxPopupContentsView::Create( |
| 45 const gfx::FontList& font_list, | 53 const gfx::FontList& font_list, |
| 46 OmniboxView* omnibox_view, | 54 OmniboxView* omnibox_view, |
| 47 OmniboxEditModel* edit_model, | 55 OmniboxEditModel* edit_model, |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 // rapidly we could get "stuck" trying repeatedly to animate shrinking by the | 238 // rapidly we could get "stuck" trying repeatedly to animate shrinking by the |
| 231 // last few pixels to get to one visible result. | 239 // last few pixels to get to one visible result. |
| 232 if (new_target_bounds.height() != target_bounds_.height()) | 240 if (new_target_bounds.height() != target_bounds_.height()) |
| 233 size_animation_.Reset(); | 241 size_animation_.Reset(); |
| 234 target_bounds_ = new_target_bounds; | 242 target_bounds_ = new_target_bounds; |
| 235 | 243 |
| 236 if (popup_ == NULL) { | 244 if (popup_ == NULL) { |
| 237 views::Widget* popup_parent = location_bar_view_->GetWidget(); | 245 views::Widget* popup_parent = location_bar_view_->GetWidget(); |
| 238 | 246 |
| 239 // If the popup is currently closed, we need to create it. | 247 // If the popup is currently closed, we need to create it. |
| 240 popup_ = (new AutocompletePopupWidget)->AsWeakPtr(); | 248 popup_ = (new AutocompletePopupWidget(popup_parent))->AsWeakPtr(); |
| 241 | 249 |
| 242 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 250 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
| 243 #if defined(OS_WIN) | 251 #if defined(OS_WIN) |
| 244 // On Windows use the software compositor to ensure that we don't block | 252 // On Windows use the software compositor to ensure that we don't block |
| 245 // the UI thread blocking issue during command buffer creation. We can | 253 // the UI thread blocking issue during command buffer creation. We can |
| 246 // revert this change once http://crbug.com/125248 is fixed. | 254 // revert this change once http://crbug.com/125248 is fixed. |
| 247 params.force_software_compositing = true; | 255 params.force_software_compositing = true; |
| 248 #endif | 256 #endif |
| 249 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 257 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 250 params.parent = popup_parent->GetNativeView(); | 258 params.parent = popup_parent->GetNativeView(); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 size_t index = GetIndexForPoint(event.location()); | 533 size_t index = GetIndexForPoint(event.location()); |
| 526 if (!HasMatchAt(index)) | 534 if (!HasMatchAt(index)) |
| 527 return; | 535 return; |
| 528 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, | 536 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, |
| 529 GURL(), base::string16(), index); | 537 GURL(), base::string16(), index); |
| 530 } | 538 } |
| 531 | 539 |
| 532 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { | 540 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { |
| 533 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); | 541 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); |
| 534 } | 542 } |
| OLD | NEW |