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/views/omnibox/omnibox_view_win.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <locale> | 8 #include <locale> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 CHARRANGE sel; | 1327 CHARRANGE sel; |
1328 GURL url; | 1328 GURL url; |
1329 bool write_url = false; | 1329 bool write_url = false; |
1330 GetSel(sel); | 1330 GetSel(sel); |
1331 // GetSel() doesn't preserve selection direction, so sel.cpMin will always be | 1331 // GetSel() doesn't preserve selection direction, so sel.cpMin will always be |
1332 // the smaller value. | 1332 // the smaller value. |
1333 model()->AdjustTextForCopy(sel.cpMin, IsSelectAll(), &text, &url, &write_url); | 1333 model()->AdjustTextForCopy(sel.cpMin, IsSelectAll(), &text, &url, &write_url); |
1334 ui::ScopedClipboardWriter scw(g_browser_process->clipboard(), | 1334 ui::ScopedClipboardWriter scw(g_browser_process->clipboard(), |
1335 ui::Clipboard::BUFFER_STANDARD); | 1335 ui::Clipboard::BUFFER_STANDARD); |
1336 scw.WriteText(text); | 1336 scw.WriteText(text); |
1337 if (write_url) { | 1337 if (write_url) |
1338 scw.WriteBookmark(text, url.spec()); | 1338 scw.WriteBookmark(text, url.spec()); |
1339 scw.WriteHyperlink(net::EscapeForHTML(text), url.spec()); | |
1340 } | |
1341 } | 1339 } |
1342 | 1340 |
1343 void OmniboxViewWin::OnCut() { | 1341 void OmniboxViewWin::OnCut() { |
1344 OnCopy(); | 1342 OnCopy(); |
1345 | 1343 |
1346 // This replace selection will have no effect (even on the undo stack) if the | 1344 // This replace selection will have no effect (even on the undo stack) if the |
1347 // current selection is empty. | 1345 // current selection is empty. |
1348 ReplaceSel(L"", true); | 1346 ReplaceSel(L"", true); |
1349 } | 1347 } |
1350 | 1348 |
(...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2632 return (rect.left - client_rect.left) + (client_rect.right - rect.right); | 2630 return (rect.left - client_rect.left) + (client_rect.right - rect.right); |
2633 } | 2631 } |
2634 | 2632 |
2635 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { | 2633 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { |
2636 // Use font_.GetStringWidth() instead of | 2634 // Use font_.GetStringWidth() instead of |
2637 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is | 2635 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is |
2638 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, | 2636 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, |
2639 // PosFromChar(i) might return 0 when i is greater than 1. | 2637 // PosFromChar(i) might return 0 when i is greater than 1. |
2640 return font_.GetStringWidth(text) + GetHorizontalMargin(); | 2638 return font_.GetStringWidth(text) + GetHorizontalMargin(); |
2641 } | 2639 } |
OLD | NEW |