| 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 "ui/views/controls/textfield/native_textfield_win.h" | 5 #include "ui/views/controls/textfield/native_textfield_win.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 MenuRunner::HAS_MNEMONICS)); | 552 MenuRunner::HAS_MNEMONICS)); |
| 553 } | 553 } |
| 554 | 554 |
| 555 void NativeTextfieldWin::OnCopy() { | 555 void NativeTextfieldWin::OnCopy() { |
| 556 if (textfield_->IsObscured()) | 556 if (textfield_->IsObscured()) |
| 557 return; | 557 return; |
| 558 | 558 |
| 559 const string16 text(GetSelectedText()); | 559 const string16 text(GetSelectedText()); |
| 560 if (!text.empty() && ViewsDelegate::views_delegate) { | 560 if (!text.empty() && ViewsDelegate::views_delegate) { |
| 561 ui::ScopedClipboardWriter scw( | 561 ui::ScopedClipboardWriter scw( |
| 562 ViewsDelegate::views_delegate->GetClipboard(), | 562 ui::Clipboard::GetForCurrentThread(), |
| 563 ui::Clipboard::BUFFER_STANDARD); | 563 ui::Clipboard::BUFFER_STANDARD); |
| 564 scw.WriteText(text); | 564 scw.WriteText(text); |
| 565 } | 565 } |
| 566 } | 566 } |
| 567 | 567 |
| 568 void NativeTextfieldWin::OnCut() { | 568 void NativeTextfieldWin::OnCut() { |
| 569 if (textfield_->read_only() || textfield_->IsObscured()) | 569 if (textfield_->read_only() || textfield_->IsObscured()) |
| 570 return; | 570 return; |
| 571 | 571 |
| 572 OnCopy(); | 572 OnCopy(); |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 // x-buttons (which usually means "thumb buttons") are pressed, so we only | 959 // x-buttons (which usually means "thumb buttons") are pressed, so we only |
| 960 // call this for M and R down. | 960 // call this for M and R down. |
| 961 tracking_double_click_ = false; | 961 tracking_double_click_ = false; |
| 962 SetMsgHandled(false); | 962 SetMsgHandled(false); |
| 963 } | 963 } |
| 964 | 964 |
| 965 void NativeTextfieldWin::OnPaste() { | 965 void NativeTextfieldWin::OnPaste() { |
| 966 if (textfield_->read_only() || !ViewsDelegate::views_delegate) | 966 if (textfield_->read_only() || !ViewsDelegate::views_delegate) |
| 967 return; | 967 return; |
| 968 | 968 |
| 969 ui::Clipboard* clipboard = ViewsDelegate::views_delegate->GetClipboard(); | 969 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); |
| 970 if (!clipboard->IsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(), | 970 if (!clipboard->IsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(), |
| 971 ui::Clipboard::BUFFER_STANDARD)) | 971 ui::Clipboard::BUFFER_STANDARD)) |
| 972 return; | 972 return; |
| 973 | 973 |
| 974 string16 clipboard_str; | 974 string16 clipboard_str; |
| 975 clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &clipboard_str); | 975 clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &clipboard_str); |
| 976 if (!clipboard_str.empty()) { | 976 if (!clipboard_str.empty()) { |
| 977 string16 collapsed(CollapseWhitespace(clipboard_str, false)); | 977 string16 collapsed(CollapseWhitespace(clipboard_str, false)); |
| 978 if (textfield_->style() & Textfield::STYLE_LOWERCASE) | 978 if (textfield_->style() & Textfield::STYLE_LOWERCASE) |
| 979 collapsed = base::i18n::ToLower(collapsed); | 979 collapsed = base::i18n::ToLower(collapsed); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); | 1200 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); |
| 1201 context_menu_contents_->AddItemWithStringId(IDS_APP_CUT, IDS_APP_CUT); | 1201 context_menu_contents_->AddItemWithStringId(IDS_APP_CUT, IDS_APP_CUT); |
| 1202 context_menu_contents_->AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); | 1202 context_menu_contents_->AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); |
| 1203 context_menu_contents_->AddItemWithStringId(IDS_APP_PASTE, IDS_APP_PASTE); | 1203 context_menu_contents_->AddItemWithStringId(IDS_APP_PASTE, IDS_APP_PASTE); |
| 1204 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); | 1204 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); |
| 1205 context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL, | 1205 context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL, |
| 1206 IDS_APP_SELECT_ALL); | 1206 IDS_APP_SELECT_ALL); |
| 1207 } | 1207 } |
| 1208 | 1208 |
| 1209 } // namespace views | 1209 } // namespace views |
| OLD | NEW |