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/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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 size_t line = std::max(y - kBorderThickness, 0) / kHeightPerResult; | 469 size_t line = std::max(y - kBorderThickness, 0) / kHeightPerResult; |
470 return std::min(line, model_->result().size() - 1); | 470 return std::min(line, model_->result().size() - 1); |
471 } | 471 } |
472 | 472 |
473 void OmniboxPopupViewGtk::AcceptLine(size_t line, | 473 void OmniboxPopupViewGtk::AcceptLine(size_t line, |
474 WindowOpenDisposition disposition) { | 474 WindowOpenDisposition disposition) { |
475 // OpenMatch() may close the popup, which will clear the result set and, by | 475 // OpenMatch() may close the popup, which will clear the result set and, by |
476 // extension, |match| and its contents. So copy the relevant match out to | 476 // extension, |match| and its contents. So copy the relevant match out to |
477 // make sure it stays alive until the call completes. | 477 // make sure it stays alive until the call completes. |
478 AutocompleteMatch match = model_->result().match_at(line); | 478 AutocompleteMatch match = model_->result().match_at(line); |
479 string16 keyword; | |
480 const bool is_keyword_hint = model_->GetKeywordForMatch(match, &keyword); | |
481 omnibox_view_->OpenMatch(match, disposition, GURL(), line, | 479 omnibox_view_->OpenMatch(match, disposition, GURL(), line, |
482 is_keyword_hint ? string16() : keyword); | 480 match.keyword); |
483 } | 481 } |
484 | 482 |
485 GdkPixbuf* OmniboxPopupViewGtk::IconForMatch(const AutocompleteMatch& match, | 483 GdkPixbuf* OmniboxPopupViewGtk::IconForMatch(const AutocompleteMatch& match, |
486 bool selected) { | 484 bool selected) { |
487 const SkBitmap* bitmap = model_->GetIconIfExtensionMatch(match); | 485 const SkBitmap* bitmap = model_->GetIconIfExtensionMatch(match); |
488 if (bitmap) { | 486 if (bitmap) { |
489 if (!ContainsKey(pixbufs_, bitmap)) | 487 if (!ContainsKey(pixbufs_, bitmap)) |
490 pixbufs_[bitmap] = gfx::GdkPixbufFromSkBitmap(bitmap); | 488 pixbufs_[bitmap] = gfx::GdkPixbufFromSkBitmap(bitmap); |
491 return pixbufs_[bitmap]; | 489 return pixbufs_[bitmap]; |
492 } | 490 } |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 (text_width - actual_content_width - | 679 (text_width - actual_content_width - |
682 (actual_description_width / PANGO_SCALE)), | 680 (actual_description_width / PANGO_SCALE)), |
683 content_y, layout_); | 681 content_y, layout_); |
684 } | 682 } |
685 } | 683 } |
686 | 684 |
687 g_object_unref(gc); | 685 g_object_unref(gc); |
688 | 686 |
689 return TRUE; | 687 return TRUE; |
690 } | 688 } |
OLD | NEW |