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 char16 kEllipsis[] = { 0x2026 }; | 111 const wchar_t kEllipsis[] = L"\x2026"; |
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 string16 text; | 296 std::wstring 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 string16& text, | 330 const std::wstring& 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(string16(kEllipsis))), | 425 ellipsis_width_(font.GetStringWidth(WideToUTF16(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 string16 separator = | 461 std::wstring separator = UTF16ToWide(l10n_util::GetStringUTF16( |
462 l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR); | 462 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 string16& text, | 537 const std::wstring& 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(text, base::i18n::IsRTL(), is_url)) | 561 if (!bidi_line.Open(WideToUTF16Hack(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(current_data->text); | 616 current_data->font->GetStringWidth( |
| 617 WideToUTF16Hack(current_data->text)); |
617 current_run->pixel_width += current_data->pixel_width; | 618 current_run->pixel_width += current_data->pixel_width; |
618 } | 619 } |
619 DCHECK(!current_run->classifications.empty()); | 620 DCHECK(!current_run->classifications.empty()); |
620 } | 621 } |
621 DCHECK(!runs.empty()); | 622 DCHECK(!runs.empty()); |
622 | 623 |
623 // Sort into logical order so we can elide logically. | 624 // Sort into logical order so we can elide logically. |
624 std::sort(runs.begin(), runs.end(), &SortRunsLogically); | 625 std::sort(runs.begin(), runs.end(), &SortRunsLogically); |
625 | 626 |
626 // Now determine what to elide, if anything. Several subtle points: | 627 // Now determine what to elide, if anything. Several subtle points: |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 const bool reverse_visible_order = (i->is_rtl != base::i18n::IsRTL()); | 663 const bool reverse_visible_order = (i->is_rtl != base::i18n::IsRTL()); |
663 int flags = gfx::Canvas::NO_ELLIPSIS; // We've already elided. | 664 int flags = gfx::Canvas::NO_ELLIPSIS; // We've already elided. |
664 if (reverse_visible_order) { | 665 if (reverse_visible_order) { |
665 std::reverse(i->classifications.begin(), i->classifications.end()); | 666 std::reverse(i->classifications.begin(), i->classifications.end()); |
666 if (i->is_rtl) | 667 if (i->is_rtl) |
667 flags |= gfx::Canvas::FORCE_RTL_DIRECTIONALITY; | 668 flags |= gfx::Canvas::FORCE_RTL_DIRECTIONALITY; |
668 } | 669 } |
669 for (Classifications::const_iterator j(i->classifications.begin()); | 670 for (Classifications::const_iterator j(i->classifications.begin()); |
670 j != i->classifications.end(); ++j) { | 671 j != i->classifications.end(); ++j) { |
671 int left = mirroring_context_->mirrored_left_coord(x, x + j->pixel_width); | 672 int left = mirroring_context_->mirrored_left_coord(x, x + j->pixel_width); |
672 canvas->DrawStringInt(j->text, *j->font, j->color, left, | 673 canvas->DrawStringInt(WideToUTF16Hack(j->text), *j->font, j->color, left, |
673 y, j->pixel_width, j->font->GetHeight(), flags); | 674 y, j->pixel_width, j->font->GetHeight(), flags); |
674 x += j->pixel_width; | 675 x += j->pixel_width; |
675 } | 676 } |
676 } | 677 } |
677 | 678 |
678 return x; | 679 return x; |
679 } | 680 } |
680 | 681 |
681 void AutocompleteResultView::Elide(Runs* runs, int remaining_width) const { | 682 void AutocompleteResultView::Elide(Runs* runs, int remaining_width) const { |
682 // The complexity of this function is due to edge cases like the following: | 683 // The complexity of this function is due to edge cases like the following: |
(...skipping 18 matching lines...) Expand all Loading... |
701 j->text += kEllipsis; | 702 j->text += kEllipsis; |
702 | 703 |
703 // We also add this classification's width (sans ellipsis) back to the | 704 // We also add this classification's width (sans ellipsis) back to the |
704 // available width since we want to consider the available space we'll | 705 // available width since we want to consider the available space we'll |
705 // have when we draw this classification. | 706 // have when we draw this classification. |
706 remaining_width += j->pixel_width; | 707 remaining_width += j->pixel_width; |
707 } | 708 } |
708 first_classification = false; | 709 first_classification = false; |
709 | 710 |
710 // Can we fit at least an ellipsis? | 711 // Can we fit at least an ellipsis? |
711 string16 elided_text = | 712 std::wstring elided_text(UTF16ToWideHack( |
712 ui::ElideText(j->text, *j->font, remaining_width, false); | 713 ui::ElideText(WideToUTF16Hack(j->text), *j->font, remaining_width, |
| 714 false))); |
713 Classifications::reverse_iterator prior_classification(j); | 715 Classifications::reverse_iterator prior_classification(j); |
714 ++prior_classification; | 716 ++prior_classification; |
715 const bool on_first_classification = | 717 const bool on_first_classification = |
716 (prior_classification == i->classifications.rend()); | 718 (prior_classification == i->classifications.rend()); |
717 if (elided_text.empty() && (remaining_width >= ellipsis_width_) && | 719 if (elided_text.empty() && (remaining_width >= ellipsis_width_) && |
718 on_first_classification) { | 720 on_first_classification) { |
719 // Edge case: This classification is bold, we can't fit a bold ellipsis | 721 // Edge case: This classification is bold, we can't fit a bold ellipsis |
720 // but we can fit a normal one, and this is the first classification in | 722 // but we can fit a normal one, and this is the first classification in |
721 // the run. We should display a lone normal ellipsis, because appending | 723 // the run. We should display a lone normal ellipsis, because appending |
722 // one to the end of the previous run might put it in the wrong visual | 724 // one to the end of the previous run might put it in the wrong visual |
723 // location (if the previous run is reversed from the normal visual | 725 // location (if the previous run is reversed from the normal visual |
724 // order). | 726 // order). |
725 // NOTE: If this isn't the first classification in the run, we don't | 727 // NOTE: If this isn't the first classification in the run, we don't |
726 // need to bother with this; see note below. | 728 // need to bother with this; see note below. |
727 elided_text = kEllipsis; | 729 elided_text = kEllipsis; |
728 } | 730 } |
729 if (!elided_text.empty()) { | 731 if (!elided_text.empty()) { |
730 // Success. Elide this classification and stop. | 732 // Success. Elide this classification and stop. |
731 j->text = elided_text; | 733 j->text = elided_text; |
732 | 734 |
733 // If we could only fit an ellipsis, then only make it bold if there was | 735 // If we could only fit an ellipsis, then only make it bold if there was |
734 // an immediate prior classification in this run that was also bold, or | 736 // an immediate prior classification in this run that was also bold, or |
735 // it will look orphaned. | 737 // it will look orphaned. |
736 if ((elided_text.length() == 1) && | 738 if ((elided_text.length() == 1) && |
737 (on_first_classification || | 739 (on_first_classification || |
738 (prior_classification->font == &normal_font_))) | 740 (prior_classification->font == &normal_font_))) |
739 j->font = &normal_font_; | 741 j->font = &normal_font_; |
740 | 742 |
741 j->pixel_width = j->font->GetStringWidth(elided_text); | 743 j->pixel_width = j->font->GetStringWidth(WideToUTF16Hack(elided_text)); |
742 | 744 |
743 // Erase any other classifications that come after the elided one. | 745 // Erase any other classifications that come after the elided one. |
744 i->classifications.erase(j.base(), i->classifications.end()); | 746 i->classifications.erase(j.base(), i->classifications.end()); |
745 runs->erase(i.base(), runs->end()); | 747 runs->erase(i.base(), runs->end()); |
746 return; | 748 return; |
747 } | 749 } |
748 | 750 |
749 // We couldn't fit an ellipsis. Move back one classification, | 751 // We couldn't fit an ellipsis. Move back one classification, |
750 // append an ellipsis, and try again. | 752 // append an ellipsis, and try again. |
751 // NOTE: In the edge case that a bold ellipsis doesn't fit but a | 753 // 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... |
1143 size_t index, | 1145 size_t index, |
1144 WindowOpenDisposition disposition) { | 1146 WindowOpenDisposition disposition) { |
1145 if (!HasMatchAt(index)) | 1147 if (!HasMatchAt(index)) |
1146 return; | 1148 return; |
1147 | 1149 |
1148 const AutocompleteMatch& match = model_->result().match_at(index); | 1150 const AutocompleteMatch& match = model_->result().match_at(index); |
1149 // OpenURL() may close the popup, which will clear the result set and, by | 1151 // OpenURL() may close the popup, which will clear the result set and, by |
1150 // extension, |match| and its contents. So copy the relevant strings out to | 1152 // extension, |match| and its contents. So copy the relevant strings out to |
1151 // make sure they stay alive until the call completes. | 1153 // make sure they stay alive until the call completes. |
1152 const GURL url(match.destination_url); | 1154 const GURL url(match.destination_url); |
1153 string16 keyword; | 1155 std::wstring keyword; |
1154 const bool is_keyword_hint = model_->GetKeywordForMatch(match, &keyword); | 1156 const bool is_keyword_hint = model_->GetKeywordForMatch(match, &keyword); |
1155 edit_view_->OpenURL(url, disposition, match.transition, GURL(), index, | 1157 edit_view_->OpenURL(url, disposition, match.transition, GURL(), index, |
1156 is_keyword_hint ? string16() : keyword); | 1158 is_keyword_hint ? std::wstring() : keyword); |
1157 } | 1159 } |
1158 | 1160 |
1159 size_t AutocompletePopupContentsView::GetIndexForPoint( | 1161 size_t AutocompletePopupContentsView::GetIndexForPoint( |
1160 const gfx::Point& point) { | 1162 const gfx::Point& point) { |
1161 if (!HitTest(point)) | 1163 if (!HitTest(point)) |
1162 return AutocompletePopupModel::kNoMatch; | 1164 return AutocompletePopupModel::kNoMatch; |
1163 | 1165 |
1164 int nb_match = model_->result().size(); | 1166 int nb_match = model_->result().size(); |
1165 DCHECK(nb_match <= GetChildViewCount()); | 1167 DCHECK(nb_match <= GetChildViewCount()); |
1166 for (int i = 0; i < nb_match; ++i) { | 1168 for (int i = 0; i < nb_match; ++i) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1201 opt_in_view_ = NULL; | 1203 opt_in_view_ = NULL; |
1202 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); | 1204 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); |
1203 DCHECK(counter); | 1205 DCHECK(counter); |
1204 counter->Hide(); | 1206 counter->Hide(); |
1205 if (opt_in) { | 1207 if (opt_in) { |
1206 browser::ShowInstantConfirmDialogIfNecessary( | 1208 browser::ShowInstantConfirmDialogIfNecessary( |
1207 location_bar_->GetWindow()->GetNativeWindow(), model_->profile()); | 1209 location_bar_->GetWindow()->GetNativeWindow(), model_->profile()); |
1208 } | 1210 } |
1209 UpdatePopupAppearance(); | 1211 UpdatePopupAppearance(); |
1210 } | 1212 } |
OLD | NEW |