Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc

Issue 10384007: First stab at touch optimized omnibox auto-complete per sgabriel's mocks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/autocomplete/autocomplete_popup_contents_view. h" 5 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view. h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <commctrl.h> 8 #include <commctrl.h>
9 #include <dwmapi.h> 9 #include <dwmapi.h>
10 #include <objidl.h> 10 #include <objidl.h>
11 #endif 11 #endif
12 12
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" 15 #include "chrome/browser/autocomplete/autocomplete_popup_model.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/themes/theme_service.h" 17 #include "chrome/browser/themes/theme_service.h"
18 #include "chrome/browser/ui/omnibox/omnibox_view.h" 18 #include "chrome/browser/ui/omnibox/omnibox_view.h"
19 #include "chrome/browser/ui/views/autocomplete/autocomplete_result_view.h" 19 #include "chrome/browser/ui/views/autocomplete/autocomplete_result_view.h"
20 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 20 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
21 #include "chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents _view.h"
21 #include "grit/chromium_strings.h" 22 #include "grit/chromium_strings.h"
22 #include "grit/generated_resources.h" 23 #include "grit/generated_resources.h"
23 #include "grit/theme_resources.h" 24 #include "grit/theme_resources.h"
24 #include "third_party/skia/include/core/SkShader.h" 25 #include "third_party/skia/include/core/SkShader.h"
26 #include "ui/base/layout.h"
Peter Kasting 2012/05/04 23:33:31 Nit: I think this goes below the next #include?
Jói 2012/05/07 16:26:18 Fixed here and checked other files to be sure ther
25 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
26 #include "ui/base/resource/resource_bundle.h" 28 #include "ui/base/resource/resource_bundle.h"
27 #include "ui/base/theme_provider.h" 29 #include "ui/base/theme_provider.h"
28 #include "ui/gfx/canvas.h" 30 #include "ui/gfx/canvas.h"
29 #include "ui/gfx/insets.h" 31 #include "ui/gfx/insets.h"
30 #include "ui/gfx/path.h" 32 #include "ui/gfx/path.h"
31 #include "ui/views/bubble/bubble_border.h" 33 #include "ui/views/bubble/bubble_border.h"
32 #include "ui/views/controls/button/text_button.h" 34 #include "ui/views/controls/button/text_button.h"
33 #include "ui/views/controls/label.h" 35 #include "ui/views/controls/label.h"
34 #include "ui/views/layout/grid_layout.h" 36 #include "ui/views/layout/grid_layout.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 AutocompletePopupWidget() {} 72 AutocompletePopupWidget() {}
71 virtual ~AutocompletePopupWidget() {} 73 virtual ~AutocompletePopupWidget() {}
72 74
73 private: 75 private:
74 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWidget); 76 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWidget);
75 }; 77 };
76 78
77 //////////////////////////////////////////////////////////////////////////////// 79 ////////////////////////////////////////////////////////////////////////////////
78 // AutocompletePopupContentsView, public: 80 // AutocompletePopupContentsView, public:
79 81
82 AutocompletePopupContentsView*
83 AutocompletePopupContentsView::CreateForEnvironment(
Peter Kasting 2012/05/04 23:33:31 Nit: Indent 4
Jói 2012/05/07 16:26:18 Done.
84 const gfx::Font& font,
85 OmniboxView* omnibox_view,
86 AutocompleteEditModel* edit_model,
87 views::View* location_bar) {
88 AutocompletePopupContentsView* view = NULL;
89 switch (ui::GetDisplayLayout()) {
Peter Kasting 2012/05/04 23:33:31 Nit: Use if/else rather than switch
Jói 2012/05/07 16:26:18 Done.
90 case ui::LAYOUT_TOUCH:
91 view = new TouchAutocompletePopupContentsView(
92 font, omnibox_view, edit_model, location_bar);
93 break;
94
95 default:
96 view = new AutocompletePopupContentsView(
97 font, omnibox_view, edit_model, location_bar);
98 }
99
100 view->Init();
101 return view;
102 }
103
80 AutocompletePopupContentsView::AutocompletePopupContentsView( 104 AutocompletePopupContentsView::AutocompletePopupContentsView(
81 const gfx::Font& font, 105 const gfx::Font& font,
82 OmniboxView* omnibox_view, 106 OmniboxView* omnibox_view,
83 AutocompleteEditModel* edit_model, 107 AutocompleteEditModel* edit_model,
84 views::View* location_bar) 108 views::View* location_bar)
85 : model_(new AutocompletePopupModel(this, edit_model)), 109 : model_(new AutocompletePopupModel(this, edit_model)),
86 omnibox_view_(omnibox_view), 110 omnibox_view_(omnibox_view),
87 profile_(edit_model->profile()), 111 profile_(edit_model->profile()),
88 location_bar_(location_bar), 112 location_bar_(location_bar),
89 result_font_(font.DeriveFont(kEditFontAdjust)), 113 result_font_(font.DeriveFont(kEditFontAdjust)),
90 result_bold_font_(result_font_.DeriveFont(0, gfx::Font::BOLD)), 114 result_bold_font_(result_font_.DeriveFont(0, gfx::Font::BOLD)),
91 ignore_mouse_drag_(false), 115 ignore_mouse_drag_(false),
92 ALLOW_THIS_IN_INITIALIZER_LIST(size_animation_(this)) { 116 ALLOW_THIS_IN_INITIALIZER_LIST(size_animation_(this)) {
93 // The following little dance is required because set_border() requires a 117 // The following little dance is required because set_border() requires a
94 // pointer to a non-const object. 118 // pointer to a non-const object.
95 views::BubbleBorder* bubble_border = 119 views::BubbleBorder* bubble_border =
96 new views::BubbleBorder(views::BubbleBorder::NONE, 120 new views::BubbleBorder(views::BubbleBorder::NONE,
97 views::BubbleBorder::NO_SHADOW); 121 views::BubbleBorder::NO_SHADOW);
98 bubble_border_ = bubble_border; 122 bubble_border_ = bubble_border;
99 set_border(bubble_border); 123 set_border(bubble_border);
100 // The contents is owned by the LocationBarView. 124 // The contents is owned by the LocationBarView.
101 set_parent_owned(false); 125 set_parent_owned(false);
126 }
102 127
128 void AutocompletePopupContentsView::Init() {
129 // This can't be done in the constructor as at that point we aren't
130 // necessarily our final class yet, and we may have subclasses
131 // overriding CreateResultView.
103 for (size_t i = 0; i < AutocompleteResult::kMaxMatches; ++i) { 132 for (size_t i = 0; i < AutocompleteResult::kMaxMatches; ++i) {
104 AutocompleteResultView* result_view = 133 AutocompleteResultView* result_view =
105 CreateResultView(this, i, result_font_, result_bold_font_); 134 CreateResultView(this, i, result_font_, result_bold_font_);
106 result_view->SetVisible(false); 135 result_view->SetVisible(false);
107 AddChildViewAt(result_view, static_cast<int>(i)); 136 AddChildViewAt(result_view, static_cast<int>(i));
108 } 137 }
109 } 138 }
110 139
111 AutocompletePopupContentsView::~AutocompletePopupContentsView() { 140 AutocompletePopupContentsView::~AutocompletePopupContentsView() {
112 // We don't need to do anything with |popup_| here. The OS either has already 141 // We don't need to do anything with |popup_| here. The OS either has already
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 // bubble appear at the same height as the Star bubble. 559 // bubble appear at the same height as the Star bubble.
531 location_bar_bounds.Inset(LocationBarView::kNormalHorizontalEdgeThickness, 560 location_bar_bounds.Inset(LocationBarView::kNormalHorizontalEdgeThickness,
532 0); 561 0);
533 } 562 }
534 gfx::Point location_bar_origin(location_bar_bounds.origin()); 563 gfx::Point location_bar_origin(location_bar_bounds.origin());
535 views::View::ConvertPointToScreen(location_bar_, &location_bar_origin); 564 views::View::ConvertPointToScreen(location_bar_, &location_bar_origin);
536 location_bar_bounds.set_origin(location_bar_origin); 565 location_bar_bounds.set_origin(location_bar_origin);
537 return bubble_border_->GetBounds( 566 return bubble_border_->GetBounds(
538 location_bar_bounds, gfx::Size(location_bar_bounds.width(), h)); 567 location_bar_bounds, gfx::Size(location_bar_bounds.width(), h));
539 } 568 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698