| 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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; | 535 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; |
| 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 string16 keyword; |
| 546 bool is_keyword_hint = false; |
| 547 |
| 548 if (match.keyword.get()) { |
| 549 keyword = match.keyword->text; |
| 550 is_keyword_hint = match.keyword->is_keyword_hint; |
| 551 } |
| 545 const AutocompleteMatch& match = model_->result().match_at(row); | 552 const AutocompleteMatch& match = model_->result().match_at(row); |
| 546 const GURL url(match.destination_url); | 553 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, | 554 edit_view_->OpenURL(url, disposition, match.transition, GURL(), row, |
| 550 is_keyword_hint ? string16() : keyword); | 555 is_keyword_hint ? string16() : keyword); |
| 551 } | 556 } |
| 552 | 557 |
| 553 void AutocompletePopupViewMac::UserPressedOptIn(bool opt_in) { | 558 void AutocompletePopupViewMac::UserPressedOptIn(bool opt_in) { |
| 554 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); | 559 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); |
| 555 DCHECK(counter); | 560 DCHECK(counter); |
| 556 counter->Hide(); | 561 counter->Hide(); |
| 557 if (opt_in) { | 562 if (opt_in) { |
| 558 browser::ShowInstantConfirmDialogIfNecessary([field_ window], | 563 browser::ShowInstantConfirmDialogIfNecessary([field_ window], |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 bottomRightCornerRadius:kPopupRoundingRadius]; | 828 bottomRightCornerRadius:kPopupRoundingRadius]; |
| 824 | 829 |
| 825 // Draw the matrix clipped to our border. | 830 // Draw the matrix clipped to our border. |
| 826 [NSGraphicsContext saveGraphicsState]; | 831 [NSGraphicsContext saveGraphicsState]; |
| 827 [path addClip]; | 832 [path addClip]; |
| 828 [super drawRect:rect]; | 833 [super drawRect:rect]; |
| 829 [NSGraphicsContext restoreGraphicsState]; | 834 [NSGraphicsContext restoreGraphicsState]; |
| 830 } | 835 } |
| 831 | 836 |
| 832 @end | 837 @end |
| OLD | NEW |