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_win.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h" |
6 | 6 |
7 #include <locale> | 7 #include <locale> |
8 | 8 |
9 #include "app/gfx/canvas.h" | 9 #include "app/gfx/canvas.h" |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
(...skipping 2162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2173 | 2173 |
2174 void AutocompleteEditViewWin::TextChanged() { | 2174 void AutocompleteEditViewWin::TextChanged() { |
2175 ScopedFreeze freeze(this, GetTextObjectModel()); | 2175 ScopedFreeze freeze(this, GetTextObjectModel()); |
2176 EmphasizeURLComponents(); | 2176 EmphasizeURLComponents(); |
2177 controller_->OnChanged(); | 2177 controller_->OnChanged(); |
2178 } | 2178 } |
2179 | 2179 |
2180 std::wstring AutocompleteEditViewWin::GetClipboardText() const { | 2180 std::wstring AutocompleteEditViewWin::GetClipboardText() const { |
2181 // Try text format. | 2181 // Try text format. |
2182 Clipboard* clipboard = g_browser_process->clipboard(); | 2182 Clipboard* clipboard = g_browser_process->clipboard(); |
2183 if (clipboard->IsFormatAvailable(Clipboard::GetPlainTextWFormatType())) { | 2183 if (clipboard->IsFormatAvailable(Clipboard::GetPlainTextWFormatType(), |
| 2184 Clipboard::BUFFER_STANDARD)) { |
2184 std::wstring text; | 2185 std::wstring text; |
2185 clipboard->ReadText(&text); | 2186 clipboard->ReadText(Clipboard::BUFFER_STANDARD, &text); |
2186 | 2187 |
2187 // Note: Unlike in the find popup and textfield view, here we completely | 2188 // Note: Unlike in the find popup and textfield view, here we completely |
2188 // remove whitespace strings containing newlines. We assume users are | 2189 // remove whitespace strings containing newlines. We assume users are |
2189 // most likely pasting in URLs that may have been split into multiple | 2190 // most likely pasting in URLs that may have been split into multiple |
2190 // lines in terminals, email programs, etc., and so linebreaks indicate | 2191 // lines in terminals, email programs, etc., and so linebreaks indicate |
2191 // completely bogus whitespace that would just cause the input to be | 2192 // completely bogus whitespace that would just cause the input to be |
2192 // invalid. | 2193 // invalid. |
2193 return CollapseWhitespace(text, true); | 2194 return CollapseWhitespace(text, true); |
2194 } | 2195 } |
2195 | 2196 |
2196 // Try bookmark format. | 2197 // Try bookmark format. |
2197 // | 2198 // |
2198 // It is tempting to try bookmark format first, but the URL we get out of a | 2199 // It is tempting to try bookmark format first, but the URL we get out of a |
2199 // bookmark has been cannonicalized via GURL. This means if a user copies | 2200 // bookmark has been cannonicalized via GURL. This means if a user copies |
2200 // and pastes from the URL bar to itself, the text will get fixed up and | 2201 // and pastes from the URL bar to itself, the text will get fixed up and |
2201 // cannonicalized, which is not what the user expects. By pasting in this | 2202 // cannonicalized, which is not what the user expects. By pasting in this |
2202 // order, we are sure to paste what the user copied. | 2203 // order, we are sure to paste what the user copied. |
2203 if (clipboard->IsFormatAvailable(Clipboard::GetUrlWFormatType())) { | 2204 if (clipboard->IsFormatAvailable(Clipboard::GetUrlWFormatType(), |
| 2205 Clipboard::BUFFER_STANDARD)) { |
2204 std::string url_str; | 2206 std::string url_str; |
2205 clipboard->ReadBookmark(NULL, &url_str); | 2207 clipboard->ReadBookmark(NULL, &url_str); |
2206 // pass resulting url string through GURL to normalize | 2208 // pass resulting url string through GURL to normalize |
2207 GURL url(url_str); | 2209 GURL url(url_str); |
2208 if (url.is_valid()) | 2210 if (url.is_valid()) |
2209 return UTF8ToWide(url.spec()); | 2211 return UTF8ToWide(url.spec()); |
2210 } | 2212 } |
2211 | 2213 |
2212 return std::wstring(); | 2214 return std::wstring(); |
2213 } | 2215 } |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2369 context_menu_contents_->AddItemWithStringId(IDS_PASTE_AND_GO, | 2371 context_menu_contents_->AddItemWithStringId(IDS_PASTE_AND_GO, |
2370 IDS_PASTE_AND_GO); | 2372 IDS_PASTE_AND_GO); |
2371 context_menu_contents_->AddSeparator(); | 2373 context_menu_contents_->AddSeparator(); |
2372 context_menu_contents_->AddItemWithStringId(IDS_SELECT_ALL, IDS_SELECT_ALL); | 2374 context_menu_contents_->AddItemWithStringId(IDS_SELECT_ALL, IDS_SELECT_ALL); |
2373 context_menu_contents_->AddSeparator(); | 2375 context_menu_contents_->AddSeparator(); |
2374 context_menu_contents_->AddItemWithStringId(IDS_EDIT_SEARCH_ENGINES, | 2376 context_menu_contents_->AddItemWithStringId(IDS_EDIT_SEARCH_ENGINES, |
2375 IDS_EDIT_SEARCH_ENGINES); | 2377 IDS_EDIT_SEARCH_ENGINES); |
2376 } | 2378 } |
2377 context_menu_.reset(new views::Menu2(context_menu_contents_.get())); | 2379 context_menu_.reset(new views::Menu2(context_menu_contents_.get())); |
2378 } | 2380 } |
OLD | NEW |