| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 8 |
| 9 #include "app/clipboard/clipboard.h" | 9 #include "app/clipboard/clipboard.h" |
| 10 #include "app/clipboard/scoped_clipboard_writer.h" | 10 #include "app/clipboard/scoped_clipboard_writer.h" |
| (...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 // beginning of the text. Delete the selected keyword. | 877 // beginning of the text. Delete the selected keyword. |
| 878 model_->ClearKeyword(GetText()); | 878 model_->ClearKeyword(GetText()); |
| 879 return true; | 879 return true; |
| 880 } | 880 } |
| 881 | 881 |
| 882 void AutocompleteEditViewMac::OnControlKeyChanged(bool pressed) { | 882 void AutocompleteEditViewMac::OnControlKeyChanged(bool pressed) { |
| 883 model_->OnControlKeyChanged(pressed); | 883 model_->OnControlKeyChanged(pressed); |
| 884 } | 884 } |
| 885 | 885 |
| 886 void AutocompleteEditViewMac::FocusLocation(bool select_all) { | 886 void AutocompleteEditViewMac::FocusLocation(bool select_all) { |
| 887 // TODO(pkasting): Figure out Mac's weird focus-handling and do the right | |
| 888 // thing here :( | |
| 889 if ([field_ isEditable]) { | 887 if ([field_ isEditable]) { |
| 890 [[field_ window] makeFirstResponder:field_]; | 888 // If the text field has a field editor, it's the first responder, meaning |
| 889 // that it's already focused. makeFirstResponder: will select all, so only |
| 890 // call it if this behavior is desired. |
| 891 if (select_all || ![field_ currentEditor]) |
| 892 [[field_ window] makeFirstResponder:field_]; |
| 891 DCHECK_EQ([field_ currentEditor], [[field_ window] firstResponder]); | 893 DCHECK_EQ([field_ currentEditor], [[field_ window] firstResponder]); |
| 892 } | 894 } |
| 893 } | 895 } |
| 894 | 896 |
| 895 // TODO(shess): Copied from autocomplete_edit_view_win.cc. Could this | 897 // TODO(shess): Copied from autocomplete_edit_view_win.cc. Could this |
| 896 // be pushed into the model? | 898 // be pushed into the model? |
| 897 std::wstring AutocompleteEditViewMac::GetClipboardText(Clipboard* clipboard) { | 899 std::wstring AutocompleteEditViewMac::GetClipboardText(Clipboard* clipboard) { |
| 898 // autocomplete_edit_view_win.cc assumes this can never happen, we | 900 // autocomplete_edit_view_win.cc assumes this can never happen, we |
| 899 // will too. | 901 // will too. |
| 900 DCHECK(clipboard); | 902 DCHECK(clipboard); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 926 clipboard->ReadBookmark(NULL, &url_str); | 928 clipboard->ReadBookmark(NULL, &url_str); |
| 927 // pass resulting url string through GURL to normalize | 929 // pass resulting url string through GURL to normalize |
| 928 GURL url(url_str); | 930 GURL url(url_str); |
| 929 if (url.is_valid()) { | 931 if (url.is_valid()) { |
| 930 return UTF8ToWide(url.spec()); | 932 return UTF8ToWide(url.spec()); |
| 931 } | 933 } |
| 932 } | 934 } |
| 933 | 935 |
| 934 return std::wstring(); | 936 return std::wstring(); |
| 935 } | 937 } |
| OLD | NEW |