| 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/cocoa/omnibox/omnibox_view_mac.h" | 5 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
| 6 | 6 |
| 7 #include <Carbon/Carbon.h> // kVK_Return | 7 #include <Carbon/Carbon.h> // kVK_Return |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 DCHECK_LE(caret_pos, text.size()); | 346 DCHECK_LE(caret_pos, text.size()); |
| 347 SetTextAndSelectedRange(text, NSMakeRange(caret_pos, 0)); | 347 SetTextAndSelectedRange(text, NSMakeRange(caret_pos, 0)); |
| 348 | 348 |
| 349 if (update_popup) | 349 if (update_popup) |
| 350 UpdatePopup(); | 350 UpdatePopup(); |
| 351 | 351 |
| 352 if (notify_text_changed) | 352 if (notify_text_changed) |
| 353 TextChanged(); | 353 TextChanged(); |
| 354 } | 354 } |
| 355 | 355 |
| 356 void OmniboxViewMac::SetCaretPos(size_t caret_pos) { |
| 357 size_t pos = std::min(caret_pos, GetTextLength()); |
| 358 SetSelectedRange(NSMakeRange(pos, 0)); |
| 359 } |
| 360 |
| 356 void OmniboxViewMac::EnterKeywordModeForDefaultSearchProvider() { | 361 void OmniboxViewMac::EnterKeywordModeForDefaultSearchProvider() { |
| 357 // We need to do this first, else |SetSelectedRange()| won't work. | 362 // We need to do this first, else |SetSelectedRange()| won't work. |
| 358 FocusLocation(true); | 363 FocusLocation(true); |
| 359 | 364 |
| 360 // Transition the user into keyword mode using their default search provider. | 365 // Transition the user into keyword mode using their default search provider. |
| 361 model()->EnterKeywordModeForDefaultSearchProvider( | 366 model()->EnterKeywordModeForDefaultSearchProvider( |
| 362 KeywordModeEntryMethod::KEYBOARD_SHORTCUT); | 367 KeywordModeEntryMethod::KEYBOARD_SHORTCUT); |
| 363 } | 368 } |
| 364 | 369 |
| 365 bool OmniboxViewMac::IsSelectAll() const { | 370 bool OmniboxViewMac::IsSelectAll() const { |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 display_text); | 1099 display_text); |
| 1095 NSDictionary* notification_info = @{ | 1100 NSDictionary* notification_info = @{ |
| 1096 NSAccessibilityAnnouncementKey : announcement, | 1101 NSAccessibilityAnnouncementKey : announcement, |
| 1097 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) | 1102 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) |
| 1098 }; | 1103 }; |
| 1099 NSAccessibilityPostNotificationWithUserInfo( | 1104 NSAccessibilityPostNotificationWithUserInfo( |
| 1100 [field_ window], | 1105 [field_ window], |
| 1101 NSAccessibilityAnnouncementRequestedNotification, | 1106 NSAccessibilityAnnouncementRequestedNotification, |
| 1102 notification_info); | 1107 notification_info); |
| 1103 } | 1108 } |
| OLD | NEW |