OLD | NEW |
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/i18n/bidi_line_iterator.h" | 8 #include "base/i18n/bidi_line_iterator.h" |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 color_utils::AlphaBlend(colors[i][TEXT], colors[i][BACKGROUND], 128); | 101 color_utils::AlphaBlend(colors[i][TEXT], colors[i][BACKGROUND], 128); |
102 colors[i][URL] = color_utils::GetReadableColor(SkColorSetRGB(0, 128, 0), | 102 colors[i][URL] = color_utils::GetReadableColor(SkColorSetRGB(0, 128, 0), |
103 colors[i][BACKGROUND]); | 103 colors[i][BACKGROUND]); |
104 } | 104 } |
105 initialized = true; | 105 initialized = true; |
106 } | 106 } |
107 | 107 |
108 return colors[state][kind]; | 108 return colors[state][kind]; |
109 } | 109 } |
110 | 110 |
111 const wchar_t kEllipsis[] = L"\x2026"; | 111 const char16 kEllipsis[] = { 0x2026 }; |
112 | 112 |
113 const SkAlpha kGlassPopupAlpha = 240; | 113 const SkAlpha kGlassPopupAlpha = 240; |
114 const SkAlpha kOpaquePopupAlpha = 255; | 114 const SkAlpha kOpaquePopupAlpha = 255; |
115 // The minimum distance between the top and bottom of the icon and the top or | 115 // The minimum distance between the top and bottom of the icon and the top or |
116 // bottom of the row. "Minimum" is used because the vertical padding may be | 116 // bottom of the row. "Minimum" is used because the vertical padding may be |
117 // larger, depending on the size of the text. | 117 // larger, depending on the size of the text. |
118 const int kIconVerticalPadding = 2; | 118 const int kIconVerticalPadding = 2; |
119 // The minimum distance between the top and bottom of the text and the top or | 119 // The minimum distance between the top and bottom of the text and the top or |
120 // bottom of the row. See comment about the use of "minimum" for | 120 // bottom of the row. See comment about the use of "minimum" for |
121 // kIconVerticalPadding. | 121 // kIconVerticalPadding. |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 virtual gfx::Size GetPreferredSize(); | 286 virtual gfx::Size GetPreferredSize(); |
287 | 287 |
288 // Returns the preferred height for a single row. | 288 // Returns the preferred height for a single row. |
289 static int GetPreferredHeight(const gfx::Font& font, | 289 static int GetPreferredHeight(const gfx::Font& font, |
290 const gfx::Font& bold_font); | 290 const gfx::Font& bold_font); |
291 | 291 |
292 private: | 292 private: |
293 // Precalculated data used to draw the portion of a match classification that | 293 // Precalculated data used to draw the portion of a match classification that |
294 // fits entirely within one run. | 294 // fits entirely within one run. |
295 struct ClassificationData { | 295 struct ClassificationData { |
296 std::wstring text; | 296 string16 text; |
297 const gfx::Font* font; | 297 const gfx::Font* font; |
298 SkColor color; | 298 SkColor color; |
299 int pixel_width; | 299 int pixel_width; |
300 }; | 300 }; |
301 typedef std::vector<ClassificationData> Classifications; | 301 typedef std::vector<ClassificationData> Classifications; |
302 | 302 |
303 // Precalculated data used to draw a complete visual run within the match. | 303 // Precalculated data used to draw a complete visual run within the match. |
304 // This will include all or part of at leasdt one, and possibly several, | 304 // This will include all or part of at leasdt one, and possibly several, |
305 // classifications. | 305 // classifications. |
306 struct RunData { | 306 struct RunData { |
(...skipping 13 matching lines...) Expand all Loading... |
320 | 320 |
321 ResultViewState GetState() const; | 321 ResultViewState GetState() const; |
322 | 322 |
323 const SkBitmap* GetIcon() const; | 323 const SkBitmap* GetIcon() const; |
324 | 324 |
325 // Draws the specified |text| into the canvas, using highlighting provided by | 325 // Draws the specified |text| into the canvas, using highlighting provided by |
326 // |classifications|. If |force_dim| is true, ACMatchClassification::DIM is | 326 // |classifications|. If |force_dim| is true, ACMatchClassification::DIM is |
327 // added to all of the classifications. Returns the x position to the right | 327 // added to all of the classifications. Returns the x position to the right |
328 // of the string. | 328 // of the string. |
329 int DrawString(gfx::Canvas* canvas, | 329 int DrawString(gfx::Canvas* canvas, |
330 const std::wstring& text, | 330 const string16& text, |
331 const ACMatchClassifications& classifications, | 331 const ACMatchClassifications& classifications, |
332 bool force_dim, | 332 bool force_dim, |
333 int x, | 333 int x, |
334 int y); | 334 int y); |
335 | 335 |
336 // Elides |runs| to fit in |remaining_width|. The runs in |runs| should be in | 336 // Elides |runs| to fit in |remaining_width|. The runs in |runs| should be in |
337 // logical order. | 337 // logical order. |
338 // | 338 // |
339 // When we need to elide a run, the ellipsis will be placed at the end of that | 339 // When we need to elide a run, the ellipsis will be placed at the end of that |
340 // run. This means that if we elide a run whose visual direction is opposite | 340 // run. This means that if we elide a run whose visual direction is opposite |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 | 415 |
416 AutocompleteResultView::AutocompleteResultView( | 416 AutocompleteResultView::AutocompleteResultView( |
417 AutocompleteResultViewModel* model, | 417 AutocompleteResultViewModel* model, |
418 int model_index, | 418 int model_index, |
419 const gfx::Font& font, | 419 const gfx::Font& font, |
420 const gfx::Font& bold_font) | 420 const gfx::Font& bold_font) |
421 : model_(model), | 421 : model_(model), |
422 model_index_(model_index), | 422 model_index_(model_index), |
423 normal_font_(font), | 423 normal_font_(font), |
424 bold_font_(bold_font), | 424 bold_font_(bold_font), |
425 ellipsis_width_(font.GetStringWidth(WideToUTF16(kEllipsis))), | 425 ellipsis_width_(font.GetStringWidth(string16(kEllipsis))), |
426 mirroring_context_(new MirroringContext()), | 426 mirroring_context_(new MirroringContext()), |
427 match_(NULL, 0, false, AutocompleteMatch::URL_WHAT_YOU_TYPED) { | 427 match_(NULL, 0, false, AutocompleteMatch::URL_WHAT_YOU_TYPED) { |
428 CHECK(model_index >= 0); | 428 CHECK(model_index >= 0); |
429 if (icon_size_ == 0) { | 429 if (icon_size_ == 0) { |
430 icon_size_ = ResourceBundle::GetSharedInstance().GetBitmapNamed( | 430 icon_size_ = ResourceBundle::GetSharedInstance().GetBitmapNamed( |
431 AutocompleteMatch::TypeToIcon(AutocompleteMatch::URL_WHAT_YOU_TYPED))-> | 431 AutocompleteMatch::TypeToIcon(AutocompleteMatch::URL_WHAT_YOU_TYPED))-> |
432 width(); | 432 width(); |
433 } | 433 } |
434 } | 434 } |
435 | 435 |
(...skipping 15 matching lines...) Expand all Loading... |
451 x = DrawString(canvas, match_.contents, match_.contents_class, false, x, | 451 x = DrawString(canvas, match_.contents, match_.contents_class, false, x, |
452 text_bounds_.y()); | 452 text_bounds_.y()); |
453 | 453 |
454 // Paint the description. | 454 // Paint the description. |
455 // TODO(pkasting): Because we paint in multiple separate pieces, we can wind | 455 // TODO(pkasting): Because we paint in multiple separate pieces, we can wind |
456 // up with no space even for an ellipsis for one or both of these pieces. | 456 // up with no space even for an ellipsis for one or both of these pieces. |
457 // Instead, we should paint the entire match as a single long string. This | 457 // Instead, we should paint the entire match as a single long string. This |
458 // would also let us use a more properly-localizable string than we get with | 458 // would also let us use a more properly-localizable string than we get with |
459 // just the IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR. | 459 // just the IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR. |
460 if (!match_.description.empty()) { | 460 if (!match_.description.empty()) { |
461 std::wstring separator = UTF16ToWide(l10n_util::GetStringUTF16( | 461 string16 separator = |
462 IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR)); | 462 l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR); |
463 ACMatchClassifications classifications; | 463 ACMatchClassifications classifications; |
464 classifications.push_back( | 464 classifications.push_back( |
465 ACMatchClassification(0, ACMatchClassification::NONE)); | 465 ACMatchClassification(0, ACMatchClassification::NONE)); |
466 x = DrawString(canvas, separator, classifications, true, x, | 466 x = DrawString(canvas, separator, classifications, true, x, |
467 text_bounds_.y()); | 467 text_bounds_.y()); |
468 | 468 |
469 DrawString(canvas, match_.description, match_.description_class, true, x, | 469 DrawString(canvas, match_.description, match_.description_class, true, x, |
470 text_bounds_.y()); | 470 text_bounds_.y()); |
471 } | 471 } |
472 } | 472 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 case IDR_OMNIBOX_SEARCH: icon = IDR_OMNIBOX_SEARCH_SELECTED; break; | 527 case IDR_OMNIBOX_SEARCH: icon = IDR_OMNIBOX_SEARCH_SELECTED; break; |
528 case IDR_OMNIBOX_STAR: icon = IDR_OMNIBOX_STAR_SELECTED; break; | 528 case IDR_OMNIBOX_STAR: icon = IDR_OMNIBOX_STAR_SELECTED; break; |
529 default: NOTREACHED(); break; | 529 default: NOTREACHED(); break; |
530 } | 530 } |
531 } | 531 } |
532 return ResourceBundle::GetSharedInstance().GetBitmapNamed(icon); | 532 return ResourceBundle::GetSharedInstance().GetBitmapNamed(icon); |
533 } | 533 } |
534 | 534 |
535 int AutocompleteResultView::DrawString( | 535 int AutocompleteResultView::DrawString( |
536 gfx::Canvas* canvas, | 536 gfx::Canvas* canvas, |
537 const std::wstring& text, | 537 const string16& text, |
538 const ACMatchClassifications& classifications, | 538 const ACMatchClassifications& classifications, |
539 bool force_dim, | 539 bool force_dim, |
540 int x, | 540 int x, |
541 int y) { | 541 int y) { |
542 if (text.empty()) | 542 if (text.empty()) |
543 return x; | 543 return x; |
544 | 544 |
545 // Check whether or not this text is a URL. URLs are always displayed LTR | 545 // Check whether or not this text is a URL. URLs are always displayed LTR |
546 // regardless of locale. | 546 // regardless of locale. |
547 bool is_url = true; | 547 bool is_url = true; |
548 for (ACMatchClassifications::const_iterator i(classifications.begin()); | 548 for (ACMatchClassifications::const_iterator i(classifications.begin()); |
549 i != classifications.end(); ++i) { | 549 i != classifications.end(); ++i) { |
550 if (!(i->style & ACMatchClassification::URL)) { | 550 if (!(i->style & ACMatchClassification::URL)) { |
551 is_url = false; | 551 is_url = false; |
552 break; | 552 break; |
553 } | 553 } |
554 } | 554 } |
555 | 555 |
556 // Split the text into visual runs. We do this first so that we don't need to | 556 // Split the text into visual runs. We do this first so that we don't need to |
557 // worry about whether our eliding might change the visual display in | 557 // worry about whether our eliding might change the visual display in |
558 // unintended ways, e.g. by removing directional markings or by adding an | 558 // unintended ways, e.g. by removing directional markings or by adding an |
559 // ellipsis that's not enclosed in appropriate markings. | 559 // ellipsis that's not enclosed in appropriate markings. |
560 base::i18n::BiDiLineIterator bidi_line; | 560 base::i18n::BiDiLineIterator bidi_line; |
561 if (!bidi_line.Open(WideToUTF16Hack(text), base::i18n::IsRTL(), is_url)) | 561 if (!bidi_line.Open(text, base::i18n::IsRTL(), is_url)) |
562 return x; | 562 return x; |
563 const int num_runs = bidi_line.CountRuns(); | 563 const int num_runs = bidi_line.CountRuns(); |
564 Runs runs; | 564 Runs runs; |
565 for (int run = 0; run < num_runs; ++run) { | 565 for (int run = 0; run < num_runs; ++run) { |
566 int run_start_int = 0, run_length_int = 0; | 566 int run_start_int = 0, run_length_int = 0; |
567 // The index we pass to GetVisualRun corresponds to the position of the run | 567 // The index we pass to GetVisualRun corresponds to the position of the run |
568 // in the displayed text. For example, the string "Google in HEBREW" (where | 568 // in the displayed text. For example, the string "Google in HEBREW" (where |
569 // HEBREW is text in the Hebrew language) has two runs: "Google in " which | 569 // HEBREW is text in the Hebrew language) has two runs: "Google in " which |
570 // is an LTR run, and "HEBREW" which is an RTL run. In an LTR context, the | 570 // is an LTR run, and "HEBREW" which is an RTL run. In an LTR context, the |
571 // run "Google in " has the index 0 (since it is the leftmost run | 571 // run "Google in " has the index 0 (since it is the leftmost run |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 const bool use_bold_font = !!(style & ACMatchClassification::MATCH); | 606 const bool use_bold_font = !!(style & ACMatchClassification::MATCH); |
607 current_data->font = &(use_bold_font ? bold_font_ : normal_font_); | 607 current_data->font = &(use_bold_font ? bold_font_ : normal_font_); |
608 const ResultViewState state = GetState(); | 608 const ResultViewState state = GetState(); |
609 if (style & ACMatchClassification::URL) | 609 if (style & ACMatchClassification::URL) |
610 current_data->color = GetColor(state, URL); | 610 current_data->color = GetColor(state, URL); |
611 else if (style & ACMatchClassification::DIM) | 611 else if (style & ACMatchClassification::DIM) |
612 current_data->color = GetColor(state, DIMMED_TEXT); | 612 current_data->color = GetColor(state, DIMMED_TEXT); |
613 else | 613 else |
614 current_data->color = GetColor(state, force_dim ? DIMMED_TEXT : TEXT); | 614 current_data->color = GetColor(state, force_dim ? DIMMED_TEXT : TEXT); |
615 current_data->pixel_width = | 615 current_data->pixel_width = |
616 current_data->font->GetStringWidth( | 616 current_data->font->GetStringWidth(current_data->text); |
617 WideToUTF16Hack(current_data->text)); | |
618 current_run->pixel_width += current_data->pixel_width; | 617 current_run->pixel_width += current_data->pixel_width; |
619 } | 618 } |
620 DCHECK(!current_run->classifications.empty()); | 619 DCHECK(!current_run->classifications.empty()); |
621 } | 620 } |
622 DCHECK(!runs.empty()); | 621 DCHECK(!runs.empty()); |
623 | 622 |
624 // Sort into logical order so we can elide logically. | 623 // Sort into logical order so we can elide logically. |
625 std::sort(runs.begin(), runs.end(), &SortRunsLogically); | 624 std::sort(runs.begin(), runs.end(), &SortRunsLogically); |
626 | 625 |
627 // Now determine what to elide, if anything. Several subtle points: | 626 // Now determine what to elide, if anything. Several subtle points: |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 const bool reverse_visible_order = (i->is_rtl != base::i18n::IsRTL()); | 662 const bool reverse_visible_order = (i->is_rtl != base::i18n::IsRTL()); |
664 int flags = gfx::Canvas::NO_ELLIPSIS; // We've already elided. | 663 int flags = gfx::Canvas::NO_ELLIPSIS; // We've already elided. |
665 if (reverse_visible_order) { | 664 if (reverse_visible_order) { |
666 std::reverse(i->classifications.begin(), i->classifications.end()); | 665 std::reverse(i->classifications.begin(), i->classifications.end()); |
667 if (i->is_rtl) | 666 if (i->is_rtl) |
668 flags |= gfx::Canvas::FORCE_RTL_DIRECTIONALITY; | 667 flags |= gfx::Canvas::FORCE_RTL_DIRECTIONALITY; |
669 } | 668 } |
670 for (Classifications::const_iterator j(i->classifications.begin()); | 669 for (Classifications::const_iterator j(i->classifications.begin()); |
671 j != i->classifications.end(); ++j) { | 670 j != i->classifications.end(); ++j) { |
672 int left = mirroring_context_->mirrored_left_coord(x, x + j->pixel_width); | 671 int left = mirroring_context_->mirrored_left_coord(x, x + j->pixel_width); |
673 canvas->DrawStringInt(WideToUTF16Hack(j->text), *j->font, j->color, left, | 672 canvas->DrawStringInt(j->text, *j->font, j->color, left, |
674 y, j->pixel_width, j->font->GetHeight(), flags); | 673 y, j->pixel_width, j->font->GetHeight(), flags); |
675 x += j->pixel_width; | 674 x += j->pixel_width; |
676 } | 675 } |
677 } | 676 } |
678 | 677 |
679 return x; | 678 return x; |
680 } | 679 } |
681 | 680 |
682 void AutocompleteResultView::Elide(Runs* runs, int remaining_width) const { | 681 void AutocompleteResultView::Elide(Runs* runs, int remaining_width) const { |
683 // The complexity of this function is due to edge cases like the following: | 682 // The complexity of this function is due to edge cases like the following: |
(...skipping 18 matching lines...) Expand all Loading... |
702 j->text += kEllipsis; | 701 j->text += kEllipsis; |
703 | 702 |
704 // We also add this classification's width (sans ellipsis) back to the | 703 // We also add this classification's width (sans ellipsis) back to the |
705 // available width since we want to consider the available space we'll | 704 // available width since we want to consider the available space we'll |
706 // have when we draw this classification. | 705 // have when we draw this classification. |
707 remaining_width += j->pixel_width; | 706 remaining_width += j->pixel_width; |
708 } | 707 } |
709 first_classification = false; | 708 first_classification = false; |
710 | 709 |
711 // Can we fit at least an ellipsis? | 710 // Can we fit at least an ellipsis? |
712 std::wstring elided_text(UTF16ToWideHack( | 711 string16 elided_text = |
713 ui::ElideText(WideToUTF16Hack(j->text), *j->font, remaining_width, | 712 ui::ElideText(j->text, *j->font, remaining_width, false); |
714 false))); | |
715 Classifications::reverse_iterator prior_classification(j); | 713 Classifications::reverse_iterator prior_classification(j); |
716 ++prior_classification; | 714 ++prior_classification; |
717 const bool on_first_classification = | 715 const bool on_first_classification = |
718 (prior_classification == i->classifications.rend()); | 716 (prior_classification == i->classifications.rend()); |
719 if (elided_text.empty() && (remaining_width >= ellipsis_width_) && | 717 if (elided_text.empty() && (remaining_width >= ellipsis_width_) && |
720 on_first_classification) { | 718 on_first_classification) { |
721 // Edge case: This classification is bold, we can't fit a bold ellipsis | 719 // Edge case: This classification is bold, we can't fit a bold ellipsis |
722 // but we can fit a normal one, and this is the first classification in | 720 // but we can fit a normal one, and this is the first classification in |
723 // the run. We should display a lone normal ellipsis, because appending | 721 // the run. We should display a lone normal ellipsis, because appending |
724 // one to the end of the previous run might put it in the wrong visual | 722 // one to the end of the previous run might put it in the wrong visual |
725 // location (if the previous run is reversed from the normal visual | 723 // location (if the previous run is reversed from the normal visual |
726 // order). | 724 // order). |
727 // NOTE: If this isn't the first classification in the run, we don't | 725 // NOTE: If this isn't the first classification in the run, we don't |
728 // need to bother with this; see note below. | 726 // need to bother with this; see note below. |
729 elided_text = kEllipsis; | 727 elided_text = kEllipsis; |
730 } | 728 } |
731 if (!elided_text.empty()) { | 729 if (!elided_text.empty()) { |
732 // Success. Elide this classification and stop. | 730 // Success. Elide this classification and stop. |
733 j->text = elided_text; | 731 j->text = elided_text; |
734 | 732 |
735 // If we could only fit an ellipsis, then only make it bold if there was | 733 // If we could only fit an ellipsis, then only make it bold if there was |
736 // an immediate prior classification in this run that was also bold, or | 734 // an immediate prior classification in this run that was also bold, or |
737 // it will look orphaned. | 735 // it will look orphaned. |
738 if ((elided_text.length() == 1) && | 736 if ((elided_text.length() == 1) && |
739 (on_first_classification || | 737 (on_first_classification || |
740 (prior_classification->font == &normal_font_))) | 738 (prior_classification->font == &normal_font_))) |
741 j->font = &normal_font_; | 739 j->font = &normal_font_; |
742 | 740 |
743 j->pixel_width = j->font->GetStringWidth(WideToUTF16Hack(elided_text)); | 741 j->pixel_width = j->font->GetStringWidth(elided_text); |
744 | 742 |
745 // Erase any other classifications that come after the elided one. | 743 // Erase any other classifications that come after the elided one. |
746 i->classifications.erase(j.base(), i->classifications.end()); | 744 i->classifications.erase(j.base(), i->classifications.end()); |
747 runs->erase(i.base(), runs->end()); | 745 runs->erase(i.base(), runs->end()); |
748 return; | 746 return; |
749 } | 747 } |
750 | 748 |
751 // We couldn't fit an ellipsis. Move back one classification, | 749 // We couldn't fit an ellipsis. Move back one classification, |
752 // append an ellipsis, and try again. | 750 // append an ellipsis, and try again. |
753 // NOTE: In the edge case that a bold ellipsis doesn't fit but a | 751 // NOTE: In the edge case that a bold ellipsis doesn't fit but a |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 size_t index, | 1143 size_t index, |
1146 WindowOpenDisposition disposition) { | 1144 WindowOpenDisposition disposition) { |
1147 if (!HasMatchAt(index)) | 1145 if (!HasMatchAt(index)) |
1148 return; | 1146 return; |
1149 | 1147 |
1150 const AutocompleteMatch& match = model_->result().match_at(index); | 1148 const AutocompleteMatch& match = model_->result().match_at(index); |
1151 // OpenURL() may close the popup, which will clear the result set and, by | 1149 // OpenURL() may close the popup, which will clear the result set and, by |
1152 // extension, |match| and its contents. So copy the relevant strings out to | 1150 // extension, |match| and its contents. So copy the relevant strings out to |
1153 // make sure they stay alive until the call completes. | 1151 // make sure they stay alive until the call completes. |
1154 const GURL url(match.destination_url); | 1152 const GURL url(match.destination_url); |
1155 std::wstring keyword; | 1153 string16 keyword; |
1156 const bool is_keyword_hint = model_->GetKeywordForMatch(match, &keyword); | 1154 const bool is_keyword_hint = model_->GetKeywordForMatch(match, &keyword); |
1157 edit_view_->OpenURL(url, disposition, match.transition, GURL(), index, | 1155 edit_view_->OpenURL(url, disposition, match.transition, GURL(), index, |
1158 is_keyword_hint ? std::wstring() : keyword); | 1156 is_keyword_hint ? string16() : keyword); |
1159 } | 1157 } |
1160 | 1158 |
1161 size_t AutocompletePopupContentsView::GetIndexForPoint( | 1159 size_t AutocompletePopupContentsView::GetIndexForPoint( |
1162 const gfx::Point& point) { | 1160 const gfx::Point& point) { |
1163 if (!HitTest(point)) | 1161 if (!HitTest(point)) |
1164 return AutocompletePopupModel::kNoMatch; | 1162 return AutocompletePopupModel::kNoMatch; |
1165 | 1163 |
1166 int nb_match = model_->result().size(); | 1164 int nb_match = model_->result().size(); |
1167 DCHECK(nb_match <= GetChildViewCount()); | 1165 DCHECK(nb_match <= GetChildViewCount()); |
1168 for (int i = 0; i < nb_match; ++i) { | 1166 for (int i = 0; i < nb_match; ++i) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 opt_in_view_ = NULL; | 1201 opt_in_view_ = NULL; |
1204 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); | 1202 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); |
1205 DCHECK(counter); | 1203 DCHECK(counter); |
1206 counter->Hide(); | 1204 counter->Hide(); |
1207 if (opt_in) { | 1205 if (opt_in) { |
1208 browser::ShowInstantConfirmDialogIfNecessary( | 1206 browser::ShowInstantConfirmDialogIfNecessary( |
1209 location_bar_->GetWindow()->GetNativeWindow(), model_->profile()); | 1207 location_bar_->GetWindow()->GetNativeWindow(), model_->profile()); |
1210 } | 1208 } |
1211 UpdatePopupAppearance(); | 1209 UpdatePopupAppearance(); |
1212 } | 1210 } |
OLD | NEW |