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

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 AutocompleteResultView* result_view =
270 static_cast<AutocompleteResultView*>(GetChildViewAt(
271 static_cast<int>(line)));
272
273 result_view->SetMatch(GetMatchAtIndex(line));
274 result_view->SchedulePaint();
270 } 275 }
271 276
272 void AutocompletePopupContentsView::UpdatePopupAppearance() { 277 void AutocompletePopupContentsView::UpdatePopupAppearance() {
273 if (model_->result().empty()) { 278 if (model_->result().empty()) {
274 // No matches, close any existing popup. 279 // No matches, close any existing popup.
275 if (popup_ != NULL) { 280 if (popup_ != NULL) {
276 size_animation_.Stop(); 281 size_animation_.Stop();
277 // NOTE: Do NOT use CloseNow() here, as we may be deep in a callstack 282 // 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 283 // 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 284 // 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) { 299 for (size_t i = 0; i < model_->result().size(); ++i) {
295 AutocompleteResultView* result_view; 300 AutocompleteResultView* result_view;
296 if (i >= child_rv_count) { 301 if (i >= child_rv_count) {
297 result_view = 302 result_view =
298 CreateResultView(this, i, result_font_, result_bold_font_); 303 CreateResultView(this, i, result_font_, result_bold_font_);
299 AddChildViewAt(result_view, static_cast<int>(i)); 304 AddChildViewAt(result_view, static_cast<int>(i));
300 } else { 305 } else {
301 result_view = static_cast<AutocompleteResultView*>(GetChildViewAt(i)); 306 result_view = static_cast<AutocompleteResultView*>(GetChildViewAt(i));
302 result_view->SetVisible(true); 307 result_view->SetVisible(true);
303 } 308 }
304 result_view->set_match(GetMatchAtIndex(i)); 309 result_view->SetMatch(GetMatchAtIndex(i));
305 } 310 }
306 for (size_t i = model_->result().size(); i < child_rv_count; ++i) 311 for (size_t i = model_->result().size(); i < child_rv_count; ++i)
307 GetChildViewAt(i)->SetVisible(false); 312 GetChildViewAt(i)->SetVisible(false);
308 313
309 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); 314 PromoCounter* counter = model_->profile()->GetInstantPromoCounter();
310 if (!opt_in_view_ && counter && counter->ShouldShow(base::Time::Now())) { 315 if (!opt_in_view_ && counter && counter->ShouldShow(base::Time::Now())) {
311 opt_in_view_ = new InstantOptInView(this, result_bold_font_, result_font_); 316 opt_in_view_ = new InstantOptInView(this, result_bold_font_, result_font_);
312 AddChildView(opt_in_view_); 317 AddChildView(opt_in_view_);
313 } else if (opt_in_view_ && (!counter || 318 } else if (opt_in_view_ && (!counter ||
314 !counter->ShouldShow(base::Time::Now()))) { 319 !counter->ShouldShow(base::Time::Now()))) {
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 void AutocompletePopupContentsView::OpenIndex( 621 void AutocompletePopupContentsView::OpenIndex(
617 size_t index, 622 size_t index,
618 WindowOpenDisposition disposition) { 623 WindowOpenDisposition disposition) {
619 if (!HasMatchAt(index)) 624 if (!HasMatchAt(index))
620 return; 625 return;
621 626
622 const AutocompleteMatch& match = model_->result().match_at(index); 627 const AutocompleteMatch& match = model_->result().match_at(index);
623 // OpenURL() may close the popup, which will clear the result set and, by 628 // 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 629 // extension, |match| and its contents. So copy the relevant strings out to
625 // make sure they stay alive until the call completes. 630 // make sure they stay alive until the call completes.
631 string16 keyword;
632 bool is_keyword_hint = false;
633
634 if (match.keyword.get()) {
635 keyword = match.keyword->text;
636 is_keyword_hint = match.keyword->is_keyword_hint;
637 }
626 const GURL url(match.destination_url); 638 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, 639 edit_view_->OpenURL(url, disposition, match.transition, GURL(), index,
630 is_keyword_hint ? string16() : keyword); 640 is_keyword_hint ? string16() : keyword);
631 } 641 }
632 642
633 size_t AutocompletePopupContentsView::GetIndexForPoint( 643 size_t AutocompletePopupContentsView::GetIndexForPoint(
634 const gfx::Point& point) { 644 const gfx::Point& point) {
635 if (!HitTest(point)) 645 if (!HitTest(point))
636 return AutocompletePopupModel::kNoMatch; 646 return AutocompletePopupModel::kNoMatch;
637 647
638 int nb_match = model_->result().size(); 648 int nb_match = model_->result().size();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 opt_in_view_ = NULL; 685 opt_in_view_ = NULL;
676 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); 686 PromoCounter* counter = model_->profile()->GetInstantPromoCounter();
677 DCHECK(counter); 687 DCHECK(counter);
678 counter->Hide(); 688 counter->Hide();
679 if (opt_in) { 689 if (opt_in) {
680 browser::ShowInstantConfirmDialogIfNecessary( 690 browser::ShowInstantConfirmDialogIfNecessary(
681 location_bar_->GetWindow()->GetNativeWindow(), model_->profile()); 691 location_bar_->GetWindow()->GetNativeWindow(), model_->profile());
682 } 692 }
683 UpdatePopupAppearance(); 693 UpdatePopupAppearance();
684 } 694 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698