OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <cmath> | 5 #include <cmath> |
6 | 6 |
7 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" | 7 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" |
8 | 8 |
9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 if (!force_background) { | 536 if (!force_background) { |
537 disposition = | 537 disposition = |
538 event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); | 538 event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); |
539 } | 539 } |
540 | 540 |
541 // OpenURL() may close the popup, which will clear the result set | 541 // OpenURL() may close the popup, which will clear the result set |
542 // and, by extension, |match| and its contents. So copy the | 542 // and, by extension, |match| and its contents. So copy the |
543 // relevant strings out to make sure they stay alive until the call | 543 // relevant strings out to make sure they stay alive until the call |
544 // completes. | 544 // completes. |
545 const AutocompleteMatch& match = model_->result().match_at(row); | 545 const AutocompleteMatch& match = model_->result().match_at(row); |
| 546 string16 keyword; |
| 547 if (match.has_keyword_hint()) |
| 548 keyword.assign(match.keyword); |
| 549 |
546 const GURL url(match.destination_url); | 550 const GURL url(match.destination_url); |
547 string16 keyword; | |
548 const bool is_keyword_hint = model_->GetKeywordForMatch(match, &keyword); | |
549 edit_view_->OpenURL(url, disposition, match.transition, GURL(), row, | 551 edit_view_->OpenURL(url, disposition, match.transition, GURL(), row, |
550 is_keyword_hint ? string16() : keyword); | 552 keyword); |
551 } | 553 } |
552 | 554 |
553 void AutocompletePopupViewMac::UserPressedOptIn(bool opt_in) { | 555 void AutocompletePopupViewMac::UserPressedOptIn(bool opt_in) { |
554 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); | 556 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); |
555 DCHECK(counter); | 557 DCHECK(counter); |
556 counter->Hide(); | 558 counter->Hide(); |
557 if (opt_in) { | 559 if (opt_in) { |
558 browser::ShowInstantConfirmDialogIfNecessary([field_ window], | 560 browser::ShowInstantConfirmDialogIfNecessary([field_ window], |
559 model_->profile()); | 561 model_->profile()); |
560 } | 562 } |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 bottomRightCornerRadius:kPopupRoundingRadius]; | 825 bottomRightCornerRadius:kPopupRoundingRadius]; |
824 | 826 |
825 // Draw the matrix clipped to our border. | 827 // Draw the matrix clipped to our border. |
826 [NSGraphicsContext saveGraphicsState]; | 828 [NSGraphicsContext saveGraphicsState]; |
827 [path addClip]; | 829 [path addClip]; |
828 [super drawRect:rect]; | 830 [super drawRect:rect]; |
829 [NSGraphicsContext restoreGraphicsState]; | 831 [NSGraphicsContext restoreGraphicsState]; |
830 } | 832 } |
831 | 833 |
832 @end | 834 @end |
OLD | NEW |