OLD | NEW |
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/gtk/omnibox/omnibox_popup_view_gtk.h" | 5 #include "chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 size_t line = std::max(y - kBorderThickness, 0) / kHeightPerResult; | 476 size_t line = std::max(y - kBorderThickness, 0) / kHeightPerResult; |
477 return std::min(line, model_->result().size() - 1); | 477 return std::min(line, model_->result().size() - 1); |
478 } | 478 } |
479 | 479 |
480 void OmniboxPopupViewGtk::AcceptLine(size_t line, | 480 void OmniboxPopupViewGtk::AcceptLine(size_t line, |
481 WindowOpenDisposition disposition) { | 481 WindowOpenDisposition disposition) { |
482 // OpenMatch() may close the popup, which will clear the result set and, by | 482 // OpenMatch() may close the popup, which will clear the result set and, by |
483 // extension, |match| and its contents. So copy the relevant match out to | 483 // extension, |match| and its contents. So copy the relevant match out to |
484 // make sure it stays alive until the call completes. | 484 // make sure it stays alive until the call completes. |
485 AutocompleteMatch match = model_->result().match_at(line); | 485 AutocompleteMatch match = model_->result().match_at(line); |
| 486 string16 keyword; |
| 487 const bool is_keyword_hint = model_->GetKeywordForMatch(match, &keyword); |
486 omnibox_view_->OpenMatch(match, disposition, GURL(), line, | 488 omnibox_view_->OpenMatch(match, disposition, GURL(), line, |
487 match.keyword); | 489 is_keyword_hint ? string16() : keyword); |
488 } | 490 } |
489 | 491 |
490 const gfx::Image* OmniboxPopupViewGtk::IconForMatch( | 492 const gfx::Image* OmniboxPopupViewGtk::IconForMatch( |
491 const AutocompleteMatch& match, bool selected) { | 493 const AutocompleteMatch& match, bool selected) { |
492 const SkBitmap* bitmap = model_->GetIconIfExtensionMatch(match); | 494 const SkBitmap* bitmap = model_->GetIconIfExtensionMatch(match); |
493 if (bitmap) { | 495 if (bitmap) { |
494 if (!ContainsKey(images_, bitmap)) { | 496 if (!ContainsKey(images_, bitmap)) { |
495 // gfx::Image wants ownership of bitmaps given to it, and we might as | 497 // gfx::Image wants ownership of bitmaps given to it, and we might as |
496 // well make the bitmap copy a format that will be used. | 498 // well make the bitmap copy a format that will be used. |
497 images_[bitmap] = new gfx::Image(gfx::GdkPixbufFromSkBitmap(bitmap)); | 499 images_[bitmap] = new gfx::Image(gfx::GdkPixbufFromSkBitmap(bitmap)); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 (actual_description_width / PANGO_SCALE)), | 694 (actual_description_width / PANGO_SCALE)), |
693 content_y); | 695 content_y); |
694 pango_cairo_show_layout(cr, layout_); | 696 pango_cairo_show_layout(cr, layout_); |
695 cairo_restore(cr); | 697 cairo_restore(cr); |
696 } | 698 } |
697 } | 699 } |
698 | 700 |
699 cairo_destroy(cr); | 701 cairo_destroy(cr); |
700 return TRUE; | 702 return TRUE; |
701 } | 703 } |
OLD | NEW |