| 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 | 23 |
| 24 namespace { |
| 25 |
| 24 // This is the number of pixels in the border image interior to the actual | 26 // This is the number of pixels in the border image interior to the actual |
| 25 // border. | 27 // border. |
| 26 const int kBorderInterior = 6; | 28 const int kBorderInterior = 6; |
| 27 | 29 |
| 30 } // namespace |
| 31 |
| 28 class OmniboxPopupContentsView::AutocompletePopupWidget | 32 class OmniboxPopupContentsView::AutocompletePopupWidget |
| 29 : public views::Widget, | 33 : public views::Widget, |
| 30 public base::SupportsWeakPtr<AutocompletePopupWidget> { | 34 public base::SupportsWeakPtr<AutocompletePopupWidget> { |
| 31 public: | 35 public: |
| 32 AutocompletePopupWidget() {} | 36 AutocompletePopupWidget() {} |
| 33 ~AutocompletePopupWidget() override {} | 37 ~AutocompletePopupWidget() override {} |
| 34 | 38 |
| 35 private: | 39 private: |
| 36 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWidget); | 40 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWidget); |
| 37 }; | 41 }; |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 } | 403 } |
| 400 | 404 |
| 401 OmniboxResultView* OmniboxPopupContentsView::CreateResultView( | 405 OmniboxResultView* OmniboxPopupContentsView::CreateResultView( |
| 402 int model_index, | 406 int model_index, |
| 403 const gfx::FontList& font_list) { | 407 const gfx::FontList& font_list) { |
| 404 return new OmniboxResultView(this, model_index, location_bar_view_, | 408 return new OmniboxResultView(this, model_index, location_bar_view_, |
| 405 font_list); | 409 font_list); |
| 406 } | 410 } |
| 407 | 411 |
| 408 //////////////////////////////////////////////////////////////////////////////// | 412 //////////////////////////////////////////////////////////////////////////////// |
| 409 // OmniboxPopupContentsView, views::View overrides, protected: | 413 // OmniboxPopupContentsView, views::View overrides, private: |
| 414 |
| 415 const char* OmniboxPopupContentsView::GetClassName() const { |
| 416 return "OmniboxPopupContentsView"; |
| 417 } |
| 410 | 418 |
| 411 void OmniboxPopupContentsView::OnPaint(gfx::Canvas* canvas) { | 419 void OmniboxPopupContentsView::OnPaint(gfx::Canvas* canvas) { |
| 412 gfx::Rect contents_bounds = GetContentsBounds(); | 420 gfx::Rect contents_bounds = GetContentsBounds(); |
| 413 contents_bounds.set_height( | 421 contents_bounds.set_height( |
| 414 contents_bounds.height() - bottom_shadow_->height() + kBorderInterior); | 422 contents_bounds.height() - bottom_shadow_->height() + kBorderInterior); |
| 415 | 423 |
| 416 gfx::Path path; | 424 gfx::Path path; |
| 417 MakeContentsPath(&path, contents_bounds); | 425 MakeContentsPath(&path, contents_bounds); |
| 418 canvas->Save(); | 426 canvas->Save(); |
| 419 canvas->sk_canvas()->clipPath(path, | 427 canvas->sk_canvas()->clipPath(path, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 size_t index = GetIndexForPoint(event.location()); | 507 size_t index = GetIndexForPoint(event.location()); |
| 500 if (!HasMatchAt(index)) | 508 if (!HasMatchAt(index)) |
| 501 return; | 509 return; |
| 502 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, | 510 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, |
| 503 GURL(), base::string16(), index); | 511 GURL(), base::string16(), index); |
| 504 } | 512 } |
| 505 | 513 |
| 506 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { | 514 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { |
| 507 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); | 515 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); |
| 508 } | 516 } |
| OLD | NEW |