| 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/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 | 355 |
| 356 void OmniboxViewMac::CloseOmniboxPopup() { | 356 void OmniboxViewMac::CloseOmniboxPopup() { |
| 357 // Call both base class methods. | 357 // Call both base class methods. |
| 358 ClosePopup(); | 358 ClosePopup(); |
| 359 OmniboxView::CloseOmniboxPopup(); | 359 OmniboxView::CloseOmniboxPopup(); |
| 360 } | 360 } |
| 361 | 361 |
| 362 void OmniboxViewMac::SetFocus() { | 362 void OmniboxViewMac::SetFocus() { |
| 363 } | 363 } |
| 364 | 364 |
| 365 void OmniboxViewMac::SetInvisibleFocus() { |
| 366 // TODO(mathp): implement for Mac. |
| 367 NOTIMPLEMENTED(); |
| 368 } |
| 369 |
| 365 void OmniboxViewMac::SetText(const string16& display_text) { | 370 void OmniboxViewMac::SetText(const string16& display_text) { |
| 366 // If we are setting the text directly, there cannot be any suggest text. | 371 // If we are setting the text directly, there cannot be any suggest text. |
| 367 suggest_text_length_ = 0; | 372 suggest_text_length_ = 0; |
| 368 SetTextInternal(display_text); | 373 SetTextInternal(display_text); |
| 369 } | 374 } |
| 370 | 375 |
| 371 void OmniboxViewMac::SetTextInternal(const string16& display_text) { | 376 void OmniboxViewMac::SetTextInternal(const string16& display_text) { |
| 372 NSString* ss = base::SysUTF16ToNSString(display_text); | 377 NSString* ss = base::SysUTF16ToNSString(display_text); |
| 373 NSMutableAttributedString* as = | 378 NSMutableAttributedString* as = |
| 374 [[[NSMutableAttributedString alloc] initWithString:ss] autorelease]; | 379 [[[NSMutableAttributedString alloc] initWithString:ss] autorelease]; |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 NSUInteger OmniboxViewMac::GetTextLength() const { | 1011 NSUInteger OmniboxViewMac::GetTextLength() const { |
| 1007 return ([field_ currentEditor] ? | 1012 return ([field_ currentEditor] ? |
| 1008 [[[field_ currentEditor] string] length] : | 1013 [[[field_ currentEditor] string] length] : |
| 1009 [[field_ stringValue] length]) - suggest_text_length_; | 1014 [[field_ stringValue] length]) - suggest_text_length_; |
| 1010 } | 1015 } |
| 1011 | 1016 |
| 1012 bool OmniboxViewMac::IsCaretAtEnd() const { | 1017 bool OmniboxViewMac::IsCaretAtEnd() const { |
| 1013 const NSRange selection = GetSelectedRange(); | 1018 const NSRange selection = GetSelectedRange(); |
| 1014 return selection.length == 0 && selection.location == GetTextLength(); | 1019 return selection.length == 0 && selection.location == GetTextLength(); |
| 1015 } | 1020 } |
| OLD | NEW |