| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/autocomplete/autocomplete_edit_view_mac.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" |
| 6 | 6 |
| 7 #include <Carbon/Carbon.h> // kVK_Return | 7 #include <Carbon/Carbon.h> // kVK_Return |
| 8 #include "app/gfx/font.h" | 8 #include "app/gfx/font.h" |
| 9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
| 10 #include "base/clipboard.h" | 10 #include "base/clipboard.h" |
| 11 #import "base/cocoa_protocols_mac.h" |
| 11 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 12 #include "base/sys_string_conversions.h" | 13 #include "base/sys_string_conversions.h" |
| 13 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 14 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 14 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 15 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
| 15 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" | 16 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" |
| 16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/cocoa/autocomplete_text_field.h" | 18 #include "chrome/browser/cocoa/autocomplete_text_field.h" |
| 18 #include "chrome/browser/cocoa/event_utils.h" | 19 #include "chrome/browser/cocoa/event_utils.h" |
| 19 #include "chrome/browser/tab_contents/tab_contents.h" | 20 #include "chrome/browser/tab_contents/tab_contents.h" |
| 20 | 21 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 return NSMakeRange(static_cast<NSInteger>(component.begin), | 119 return NSMakeRange(static_cast<NSInteger>(component.begin), |
| 119 static_cast<NSInteger>(component.len)); | 120 static_cast<NSInteger>(component.len)); |
| 120 } | 121 } |
| 121 | 122 |
| 122 } // namespace | 123 } // namespace |
| 123 | 124 |
| 124 // Thin Obj-C bridge class that is the delegate of the omnibox field. | 125 // Thin Obj-C bridge class that is the delegate of the omnibox field. |
| 125 // It intercepts various control delegate methods and vectors them to | 126 // It intercepts various control delegate methods and vectors them to |
| 126 // the edit view. | 127 // the edit view. |
| 127 | 128 |
| 128 @interface AutocompleteFieldDelegate : NSObject { | 129 @interface AutocompleteFieldDelegate : NSObject<NSTextFieldDelegate> { |
| 129 @private | 130 @private |
| 130 AutocompleteEditViewMac* edit_view_; // weak, owns us. | 131 AutocompleteEditViewMac* edit_view_; // weak, owns us. |
| 131 } | 132 } |
| 132 - initWithEditView:(AutocompleteEditViewMac*)view; | 133 - initWithEditView:(AutocompleteEditViewMac*)view; |
| 133 - (void)windowDidResignKey:(NSNotification*)notification; | 134 - (void)windowDidResignKey:(NSNotification*)notification; |
| 134 @end | 135 @end |
| 135 | 136 |
| 136 // TODO(shess): AutocompletePopupViewMac doesn't really need an | 137 // TODO(shess): AutocompletePopupViewMac doesn't really need an |
| 137 // NSTextField. It wants to know where the position the popup, what | 138 // NSTextField. It wants to know where the position the popup, what |
| 138 // font to use, and it also needs to be able to attach the popup to | 139 // font to use, and it also needs to be able to attach the popup to |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 // prepended and ".com" appended. This calls down to | 848 // prepended and ".com" appended. This calls down to |
| 848 // AutocompleteEditModel::OnControlKeyChanged() so that it can change | 849 // AutocompleteEditModel::OnControlKeyChanged() so that it can change |
| 849 // the popup to reflect this. See autocomplete_edit.cc | 850 // the popup to reflect this. See autocomplete_edit.cc |
| 850 // OnControlKeyChanged() and OnAfterPossibleChange(). | 851 // OnControlKeyChanged() and OnAfterPossibleChange(). |
| 851 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent { | 852 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent { |
| 852 bool controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0; | 853 bool controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0; |
| 853 edit_view_->OnControlKeyChanged(controlFlag); | 854 edit_view_->OnControlKeyChanged(controlFlag); |
| 854 } | 855 } |
| 855 | 856 |
| 856 @end | 857 @end |
| OLD | NEW |