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

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

Issue 6731036: Enabled pressing TAB to cycle through the Omnibox results. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 8 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" 9 #include "chrome/browser/autocomplete/autocomplete_edit_view.h"
10 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" 10 #include "chrome/browser/autocomplete/autocomplete_popup_model.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } 259 }
260 260
261 //////////////////////////////////////////////////////////////////////////////// 261 ////////////////////////////////////////////////////////////////////////////////
262 // AutocompletePopupContentsView, AutocompletePopupView overrides: 262 // AutocompletePopupContentsView, AutocompletePopupView overrides:
263 263
264 bool AutocompletePopupContentsView::IsOpen() const { 264 bool AutocompletePopupContentsView::IsOpen() const {
265 return (popup_ != NULL); 265 return (popup_ != NULL);
266 } 266 }
267 267
268 void AutocompletePopupContentsView::InvalidateLine(size_t line) { 268 void AutocompletePopupContentsView::InvalidateLine(size_t line) {
269 GetChildViewAt(static_cast<int>(line))->SchedulePaint(); 269 if (line < model_->result().size()) {
270 AutocompleteResultView* result_view =
271 static_cast<AutocompleteResultView*>(GetChildViewAt(
272 static_cast<int>(line)));
273
274 result_view->SetMatch(GetMatchAtIndex(line));
275 result_view->SchedulePaint();
276 }
270 } 277 }
271 278
272 void AutocompletePopupContentsView::UpdatePopupAppearance() { 279 void AutocompletePopupContentsView::UpdatePopupAppearance() {
273 if (model_->result().empty()) { 280 if (model_->result().empty()) {
274 // No matches, close any existing popup. 281 // No matches, close any existing popup.
275 if (popup_ != NULL) { 282 if (popup_ != NULL) {
276 size_animation_.Stop(); 283 size_animation_.Stop();
277 // NOTE: Do NOT use CloseNow() here, as we may be deep in a callstack 284 // NOTE: Do NOT use CloseNow() here, as we may be deep in a callstack
278 // triggered by the popup receiving a message (e.g. LBUTTONUP), and 285 // triggered by the popup receiving a message (e.g. LBUTTONUP), and
279 // destroying the popup would cause us to read garbage when we unwind back 286 // destroying the popup would cause us to read garbage when we unwind back
(...skipping 14 matching lines...) Expand all
294 for (size_t i = 0; i < model_->result().size(); ++i) { 301 for (size_t i = 0; i < model_->result().size(); ++i) {
295 AutocompleteResultView* result_view; 302 AutocompleteResultView* result_view;
296 if (i >= child_rv_count) { 303 if (i >= child_rv_count) {
297 result_view = 304 result_view =
298 CreateResultView(this, i, result_font_, result_bold_font_); 305 CreateResultView(this, i, result_font_, result_bold_font_);
299 AddChildViewAt(result_view, static_cast<int>(i)); 306 AddChildViewAt(result_view, static_cast<int>(i));
300 } else { 307 } else {
301 result_view = static_cast<AutocompleteResultView*>(GetChildViewAt(i)); 308 result_view = static_cast<AutocompleteResultView*>(GetChildViewAt(i));
302 result_view->SetVisible(true); 309 result_view->SetVisible(true);
303 } 310 }
304 result_view->set_match(GetMatchAtIndex(i)); 311 result_view->SetMatch(GetMatchAtIndex(i));
305 } 312 }
306 for (size_t i = model_->result().size(); i < child_rv_count; ++i) 313 for (size_t i = model_->result().size(); i < child_rv_count; ++i)
307 GetChildViewAt(i)->SetVisible(false); 314 GetChildViewAt(i)->SetVisible(false);
308 315
309 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); 316 PromoCounter* counter = model_->profile()->GetInstantPromoCounter();
310 if (!opt_in_view_ && counter && counter->ShouldShow(base::Time::Now())) { 317 if (!opt_in_view_ && counter && counter->ShouldShow(base::Time::Now())) {
311 opt_in_view_ = new InstantOptInView(this, result_bold_font_, result_font_); 318 opt_in_view_ = new InstantOptInView(this, result_bold_font_, result_font_);
312 AddChildView(opt_in_view_); 319 AddChildView(opt_in_view_);
313 } else if (opt_in_view_ && (!counter || 320 } else if (opt_in_view_ && (!counter ||
314 !counter->ShouldShow(base::Time::Now()))) { 321 !counter->ShouldShow(base::Time::Now()))) {
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 void AutocompletePopupContentsView::OpenIndex( 623 void AutocompletePopupContentsView::OpenIndex(
617 size_t index, 624 size_t index,
618 WindowOpenDisposition disposition) { 625 WindowOpenDisposition disposition) {
619 if (!HasMatchAt(index)) 626 if (!HasMatchAt(index))
620 return; 627 return;
621 628
622 const AutocompleteMatch& match = model_->result().match_at(index); 629 const AutocompleteMatch& match = model_->result().match_at(index);
623 // OpenURL() may close the popup, which will clear the result set and, by 630 // OpenURL() may close the popup, which will clear the result set and, by
624 // extension, |match| and its contents. So copy the relevant strings out to 631 // extension, |match| and its contents. So copy the relevant strings out to
625 // make sure they stay alive until the call completes. 632 // make sure they stay alive until the call completes.
633 string16 keyword;
634 if (match.has_keyword_hint())
635 keyword.assign(match.keyword);
Peter Kasting 2011/04/13 21:06:59 Nit: Eliminate the temp and do this with a ?: insi
636
626 const GURL url(match.destination_url); 637 const GURL url(match.destination_url);
627 string16 keyword;
628 const bool is_keyword_hint = model_->GetKeywordForMatch(match, &keyword);
629 edit_view_->OpenURL(url, disposition, match.transition, GURL(), index, 638 edit_view_->OpenURL(url, disposition, match.transition, GURL(), index,
630 is_keyword_hint ? string16() : keyword); 639 keyword);
631 } 640 }
632 641
633 size_t AutocompletePopupContentsView::GetIndexForPoint( 642 size_t AutocompletePopupContentsView::GetIndexForPoint(
634 const gfx::Point& point) { 643 const gfx::Point& point) {
635 if (!HitTest(point)) 644 if (!HitTest(point))
636 return AutocompletePopupModel::kNoMatch; 645 return AutocompletePopupModel::kNoMatch;
637 646
638 int nb_match = model_->result().size(); 647 int nb_match = model_->result().size();
639 DCHECK(nb_match <= child_count()); 648 DCHECK(nb_match <= child_count());
640 for (int i = 0; i < nb_match; ++i) { 649 for (int i = 0; i < nb_match; ++i) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 opt_in_view_ = NULL; 684 opt_in_view_ = NULL;
676 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); 685 PromoCounter* counter = model_->profile()->GetInstantPromoCounter();
677 DCHECK(counter); 686 DCHECK(counter);
678 counter->Hide(); 687 counter->Hide();
679 if (opt_in) { 688 if (opt_in) {
680 browser::ShowInstantConfirmDialogIfNecessary( 689 browser::ShowInstantConfirmDialogIfNecessary(
681 location_bar_->GetWindow()->GetNativeWindow(), model_->profile()); 690 location_bar_->GetWindow()->GetNativeWindow(), model_->profile());
682 } 691 }
683 UpdatePopupAppearance(); 692 UpdatePopupAppearance();
684 } 693 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698