| 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/autocomplete/autocomplete_popup_view_gtk.h" | 5 #include "chrome/browser/autocomplete/autocomplete_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 AutocompletePopupViewGtk::AcceptLine(size_t line, | 473 void AutocompletePopupViewGtk::AcceptLine(size_t line, |
| 474 WindowOpenDisposition disposition) { | 474 WindowOpenDisposition disposition) { |
| 475 const AutocompleteMatch& match = model_->result().match_at(line); | 475 const AutocompleteMatch& match = model_->result().match_at(line); |
| 476 // OpenURL() may close the popup, which will clear the result set and, by | 476 // OpenURL() may close the popup, which will clear the result set and, by |
| 477 // extension, |match| and its contents. So copy the relevant strings out to | 477 // extension, |match| and its contents. So copy the relevant strings out to |
| 478 // make sure they stay alive until the call completes. | 478 // make sure they stay alive until the call completes. |
| 479 string16 keyword; |
| 480 if (match.has_keyword_hint()) |
| 481 keyword.assign(match.keyword); |
| 482 |
| 479 const GURL url(match.destination_url); | 483 const GURL url(match.destination_url); |
| 480 string16 keyword; | |
| 481 const bool is_keyword_hint = model_->GetKeywordForMatch(match, &keyword); | |
| 482 edit_view_->OpenURL(url, disposition, match.transition, GURL(), line, | 484 edit_view_->OpenURL(url, disposition, match.transition, GURL(), line, |
| 483 is_keyword_hint ? string16() : keyword); | 485 keyword); |
| 484 } | 486 } |
| 485 | 487 |
| 486 GdkPixbuf* AutocompletePopupViewGtk::IconForMatch( | 488 GdkPixbuf* AutocompletePopupViewGtk::IconForMatch( |
| 487 const AutocompleteMatch& match, bool selected) { | 489 const AutocompleteMatch& match, bool selected) { |
| 488 const SkBitmap* bitmap = model_->GetSpecialIconForMatch(match); | 490 const SkBitmap* bitmap = model_->GetSpecialIconForMatch(match); |
| 489 if (bitmap) { | 491 if (bitmap) { |
| 490 if (!ContainsKey(pixbufs_, bitmap)) | 492 if (!ContainsKey(pixbufs_, bitmap)) |
| 491 pixbufs_[bitmap] = gfx::GdkPixbufFromSkBitmap(bitmap); | 493 pixbufs_[bitmap] = gfx::GdkPixbufFromSkBitmap(bitmap); |
| 492 return pixbufs_[bitmap]; | 494 return pixbufs_[bitmap]; |
| 493 } | 495 } |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 (text_width - actual_content_width - | 671 (text_width - actual_content_width - |
| 670 (actual_description_width / PANGO_SCALE)), | 672 (actual_description_width / PANGO_SCALE)), |
| 671 content_y, layout_); | 673 content_y, layout_); |
| 672 } | 674 } |
| 673 } | 675 } |
| 674 | 676 |
| 675 g_object_unref(gc); | 677 g_object_unref(gc); |
| 676 | 678 |
| 677 return TRUE; | 679 return TRUE; |
| 678 } | 680 } |
| OLD | NEW |