| 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" |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 DCHECK_EQ([field_ currentEditor], [[field_ window] firstResponder]); | 654 DCHECK_EQ([field_ currentEditor], [[field_ window] firstResponder]); |
| 655 } | 655 } |
| 656 | 656 |
| 657 // TODO(shess): Copied from autocomplete_edit_view_win.cc. Could this | 657 // TODO(shess): Copied from autocomplete_edit_view_win.cc. Could this |
| 658 // be pushed into the model? | 658 // be pushed into the model? |
| 659 std::wstring AutocompleteEditViewMac::GetClipboardText(Clipboard* clipboard) { | 659 std::wstring AutocompleteEditViewMac::GetClipboardText(Clipboard* clipboard) { |
| 660 // autocomplete_edit_view_win.cc assumes this can never happen, we | 660 // autocomplete_edit_view_win.cc assumes this can never happen, we |
| 661 // will too. | 661 // will too. |
| 662 DCHECK(clipboard); | 662 DCHECK(clipboard); |
| 663 | 663 |
| 664 if (clipboard->IsFormatAvailable(Clipboard::GetPlainTextWFormatType())) { | 664 if (clipboard->IsFormatAvailable(Clipboard::GetPlainTextWFormatType(), |
| 665 Clipboard::BUFFER_STANDARD)) { |
| 665 string16 text16; | 666 string16 text16; |
| 666 clipboard->ReadText(&text16); | 667 clipboard->ReadText(Clipboard::BUFFER_STANDARD, &text16); |
| 667 | 668 |
| 668 // Note: Unlike in the find popup and textfield view, here we completely | 669 // Note: Unlike in the find popup and textfield view, here we completely |
| 669 // remove whitespace strings containing newlines. We assume users are | 670 // remove whitespace strings containing newlines. We assume users are |
| 670 // most likely pasting in URLs that may have been split into multiple | 671 // most likely pasting in URLs that may have been split into multiple |
| 671 // lines in terminals, email programs, etc., and so linebreaks indicate | 672 // lines in terminals, email programs, etc., and so linebreaks indicate |
| 672 // completely bogus whitespace that would just cause the input to be | 673 // completely bogus whitespace that would just cause the input to be |
| 673 // invalid. | 674 // invalid. |
| 674 return CollapseWhitespace(UTF16ToWide(text16), true); | 675 return CollapseWhitespace(UTF16ToWide(text16), true); |
| 675 } | 676 } |
| 676 | 677 |
| 677 // Try bookmark format. | 678 // Try bookmark format. |
| 678 // | 679 // |
| 679 // It is tempting to try bookmark format first, but the URL we get out of a | 680 // It is tempting to try bookmark format first, but the URL we get out of a |
| 680 // bookmark has been cannonicalized via GURL. This means if a user copies | 681 // bookmark has been cannonicalized via GURL. This means if a user copies |
| 681 // and pastes from the URL bar to itself, the text will get fixed up and | 682 // and pastes from the URL bar to itself, the text will get fixed up and |
| 682 // cannonicalized, which is not what the user expects. By pasting in this | 683 // cannonicalized, which is not what the user expects. By pasting in this |
| 683 // order, we are sure to paste what the user copied. | 684 // order, we are sure to paste what the user copied. |
| 684 if (clipboard->IsFormatAvailable(Clipboard::GetUrlWFormatType())) { | 685 if (clipboard->IsFormatAvailable(Clipboard::GetUrlWFormatType(), |
| 686 Clipboard::BUFFER_STANDARD)) { |
| 685 std::string url_str; | 687 std::string url_str; |
| 686 clipboard->ReadBookmark(NULL, &url_str); | 688 clipboard->ReadBookmark(NULL, &url_str); |
| 687 // pass resulting url string through GURL to normalize | 689 // pass resulting url string through GURL to normalize |
| 688 GURL url(url_str); | 690 GURL url(url_str); |
| 689 if (url.is_valid()) { | 691 if (url.is_valid()) { |
| 690 return UTF8ToWide(url.spec()); | 692 return UTF8ToWide(url.spec()); |
| 691 } | 693 } |
| 692 } | 694 } |
| 693 | 695 |
| 694 return std::wstring(); | 696 return std::wstring(); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 // prepended and ".com" appended. This calls down to | 847 // prepended and ".com" appended. This calls down to |
| 846 // AutocompleteEditModel::OnControlKeyChanged() so that it can change | 848 // AutocompleteEditModel::OnControlKeyChanged() so that it can change |
| 847 // the popup to reflect this. See autocomplete_edit.cc | 849 // the popup to reflect this. See autocomplete_edit.cc |
| 848 // OnControlKeyChanged() and OnAfterPossibleChange(). | 850 // OnControlKeyChanged() and OnAfterPossibleChange(). |
| 849 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent { | 851 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent { |
| 850 bool controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0; | 852 bool controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0; |
| 851 edit_view_->OnControlKeyChanged(controlFlag); | 853 edit_view_->OnControlKeyChanged(controlFlag); |
| 852 } | 854 } |
| 853 | 855 |
| 854 @end | 856 @end |
| OLD | NEW |