Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm

Issue 2435103002: Omnibox: Preserve display text and select all on a focus search (Closed)
Patch Set: Use display_text.length() as caret pos for KEYBOARD_SHORTCUT Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 368
369 if (notify_text_changed) 369 if (notify_text_changed)
370 TextChanged(); 370 TextChanged();
371 } 371 }
372 372
373 void OmniboxViewMac::EnterKeywordModeForDefaultSearchProvider() { 373 void OmniboxViewMac::EnterKeywordModeForDefaultSearchProvider() {
374 // We need to do this first, else |SetSelectedRange()| won't work. 374 // We need to do this first, else |SetSelectedRange()| won't work.
375 FocusLocation(true); 375 FocusLocation(true);
376 376
377 // Transition the user into keyword mode using their default search provider. 377 // Transition the user into keyword mode using their default search provider.
378 // Select their query if they typed one.
379 model()->EnterKeywordModeForDefaultSearchProvider( 378 model()->EnterKeywordModeForDefaultSearchProvider(
380 KeywordModeEntryMethod::KEYBOARD_SHORTCUT); 379 KeywordModeEntryMethod::KEYBOARD_SHORTCUT);
381 SelectAll(false);
382 } 380 }
383 381
384 bool OmniboxViewMac::IsSelectAll() const { 382 bool OmniboxViewMac::IsSelectAll() const {
385 if (![field_ currentEditor]) 383 if (![field_ currentEditor])
386 return true; 384 return true;
387 const NSRange all_range = NSMakeRange(0, GetTextLength()); 385 const NSRange all_range = NSMakeRange(0, GetTextLength());
388 return NSEqualRanges(all_range, GetSelectedRange()); 386 return NSEqualRanges(all_range, GetSelectedRange());
389 } 387 }
390 388
391 bool OmniboxViewMac::DeleteAtEndPressed() { 389 bool OmniboxViewMac::DeleteAtEndPressed() {
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 display_text); 1112 display_text);
1115 NSDictionary* notification_info = @{ 1113 NSDictionary* notification_info = @{
1116 NSAccessibilityAnnouncementKey : announcement, 1114 NSAccessibilityAnnouncementKey : announcement,
1117 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) 1115 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh)
1118 }; 1116 };
1119 NSAccessibilityPostNotificationWithUserInfo( 1117 NSAccessibilityPostNotificationWithUserInfo(
1120 [field_ window], 1118 [field_ window],
1121 NSAccessibilityAnnouncementRequestedNotification, 1119 NSAccessibilityAnnouncementRequestedNotification,
1122 notification_info); 1120 notification_info);
1123 } 1121 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_browsertest.cc ('k') | chrome/browser/ui/omnibox/chrome_omnibox_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698