| 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/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 UpdatePopup(); | 266 UpdatePopup(); |
| 267 | 267 |
| 268 if (notify_text_changed) | 268 if (notify_text_changed) |
| 269 TextChanged(); | 269 TextChanged(); |
| 270 } | 270 } |
| 271 | 271 |
| 272 void OmniboxViewMac::SetForcedQuery() { | 272 void OmniboxViewMac::SetForcedQuery() { |
| 273 // We need to do this first, else |SetSelectedRange()| won't work. | 273 // We need to do this first, else |SetSelectedRange()| won't work. |
| 274 FocusLocation(true); | 274 FocusLocation(true); |
| 275 | 275 |
| 276 const string16 current_text(GetText()); | 276 const base::string16 current_text(GetText()); |
| 277 const size_t start = current_text.find_first_not_of(kWhitespaceUTF16); | 277 const size_t start = current_text.find_first_not_of(base::kWhitespaceUTF16); |
| 278 if (start == string16::npos || (current_text[start] != '?')) { | 278 if (start == string16::npos || (current_text[start] != '?')) { |
| 279 SetUserText(ASCIIToUTF16("?")); | 279 SetUserText(ASCIIToUTF16("?")); |
| 280 } else { | 280 } else { |
| 281 NSRange range = NSMakeRange(start + 1, current_text.size() - start - 1); | 281 NSRange range = NSMakeRange(start + 1, current_text.size() - start - 1); |
| 282 [[field_ currentEditor] setSelectedRange:range]; | 282 [[field_ currentEditor] setSelectedRange:range]; |
| 283 } | 283 } |
| 284 } | 284 } |
| 285 | 285 |
| 286 bool OmniboxViewMac::IsSelectAll() const { | 286 bool OmniboxViewMac::IsSelectAll() const { |
| 287 if (![field_ currentEditor]) | 287 if (![field_ currentEditor]) |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 | 947 |
| 948 NSUInteger OmniboxViewMac::GetTextLength() const { | 948 NSUInteger OmniboxViewMac::GetTextLength() const { |
| 949 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : | 949 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : |
| 950 [[field_ stringValue] length]; | 950 [[field_ stringValue] length]; |
| 951 } | 951 } |
| 952 | 952 |
| 953 bool OmniboxViewMac::IsCaretAtEnd() const { | 953 bool OmniboxViewMac::IsCaretAtEnd() const { |
| 954 const NSRange selection = GetSelectedRange(); | 954 const NSRange selection = GetSelectedRange(); |
| 955 return NSMaxRange(selection) == GetTextLength(); | 955 return NSMaxRange(selection) == GetTextLength(); |
| 956 } | 956 } |
| OLD | NEW |