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