| 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); | |
| 488 omnibox_view_->OpenMatch(match, disposition, GURL(), line, | 486 omnibox_view_->OpenMatch(match, disposition, GURL(), line, |
| 489 is_keyword_hint ? string16() : keyword); | 487 match.keyword); |
| 490 } | 488 } |
| 491 | 489 |
| 492 const gfx::Image* OmniboxPopupViewGtk::IconForMatch( | 490 const gfx::Image* OmniboxPopupViewGtk::IconForMatch( |
| 493 const AutocompleteMatch& match, bool selected) { | 491 const AutocompleteMatch& match, bool selected) { |
| 494 const SkBitmap* bitmap = model_->GetIconIfExtensionMatch(match); | 492 const SkBitmap* bitmap = model_->GetIconIfExtensionMatch(match); |
| 495 if (bitmap) { | 493 if (bitmap) { |
| 496 if (!ContainsKey(images_, bitmap)) { | 494 if (!ContainsKey(images_, bitmap)) { |
| 497 // gfx::Image wants ownership of bitmaps given to it, and we might as | 495 // gfx::Image wants ownership of bitmaps given to it, and we might as |
| 498 // well make the bitmap copy a format that will be used. | 496 // well make the bitmap copy a format that will be used. |
| 499 images_[bitmap] = new gfx::Image(gfx::GdkPixbufFromSkBitmap(bitmap)); | 497 images_[bitmap] = new gfx::Image(gfx::GdkPixbufFromSkBitmap(bitmap)); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 (actual_description_width / PANGO_SCALE)), | 692 (actual_description_width / PANGO_SCALE)), |
| 695 content_y); | 693 content_y); |
| 696 pango_cairo_show_layout(cr, layout_); | 694 pango_cairo_show_layout(cr, layout_); |
| 697 cairo_restore(cr); | 695 cairo_restore(cr); |
| 698 } | 696 } |
| 699 } | 697 } |
| 700 | 698 |
| 701 cairo_destroy(cr); | 699 cairo_destroy(cr); |
| 702 return TRUE; | 700 return TRUE; |
| 703 } | 701 } |
| OLD | NEW |