| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 NSRange ComponentToNSRange(const url_parse::Component& component) { | 117 NSRange ComponentToNSRange(const url_parse::Component& component) { |
| 118 return NSMakeRange(static_cast<NSInteger>(component.begin), | 118 return NSMakeRange(static_cast<NSInteger>(component.begin), |
| 119 static_cast<NSInteger>(component.len)); | 119 static_cast<NSInteger>(component.len)); |
| 120 } | 120 } |
| 121 | 121 |
| 122 } // namespace | 122 } // namespace |
| 123 | 123 |
| 124 // static | 124 // static |
| 125 NSImage* OmniboxViewMac::ImageForResource(int resource_id) { | 125 NSImage* OmniboxViewMac::ImageForResource(int resource_id) { |
| 126 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 126 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 127 return rb.GetNativeImageNamed(resource_id); | 127 return rb.GetNativeImageNamed(resource_id).ToNSImage(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 OmniboxViewMac::OmniboxViewMac(OmniboxEditController* controller, | 130 OmniboxViewMac::OmniboxViewMac(OmniboxEditController* controller, |
| 131 ToolbarModel* toolbar_model, | 131 ToolbarModel* toolbar_model, |
| 132 Profile* profile, | 132 Profile* profile, |
| 133 CommandUpdater* command_updater, | 133 CommandUpdater* command_updater, |
| 134 AutocompleteTextField* field) | 134 AutocompleteTextField* field) |
| 135 : OmniboxView(profile, controller, toolbar_model, command_updater), | 135 : OmniboxView(profile, controller, toolbar_model, command_updater), |
| 136 popup_view_(new OmniboxPopupViewMac(this, model(), field)), | 136 popup_view_(new OmniboxPopupViewMac(this, model(), field)), |
| 137 field_(field), | 137 field_(field), |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 NSUInteger OmniboxViewMac::GetTextLength() const { | 1007 NSUInteger OmniboxViewMac::GetTextLength() const { |
| 1008 return ([field_ currentEditor] ? | 1008 return ([field_ currentEditor] ? |
| 1009 [[[field_ currentEditor] string] length] : | 1009 [[[field_ currentEditor] string] length] : |
| 1010 [[field_ stringValue] length]) - suggest_text_length_; | 1010 [[field_ stringValue] length]) - suggest_text_length_; |
| 1011 } | 1011 } |
| 1012 | 1012 |
| 1013 bool OmniboxViewMac::IsCaretAtEnd() const { | 1013 bool OmniboxViewMac::IsCaretAtEnd() const { |
| 1014 const NSRange selection = GetSelectedRange(); | 1014 const NSRange selection = GetSelectedRange(); |
| 1015 return selection.length == 0 && selection.location == GetTextLength(); | 1015 return selection.length == 0 && selection.location == GetTextLength(); |
| 1016 } | 1016 } |
| OLD | NEW |