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 21 matching lines...) Expand all Loading... |
32 #include "chrome/browser/net/url_fixer_upper.h" | 32 #include "chrome/browser/net/url_fixer_upper.h" |
33 #include "chrome/browser/profile.h" | 33 #include "chrome/browser/profile.h" |
34 #include "chrome/browser/search_engines/template_url.h" | 34 #include "chrome/browser/search_engines/template_url.h" |
35 #include "chrome/browser/search_engines/template_url_model.h" | 35 #include "chrome/browser/search_engines/template_url_model.h" |
36 #include "chrome/browser/tab_contents/tab_contents.h" | 36 #include "chrome/browser/tab_contents/tab_contents.h" |
37 #include "chrome/browser/views/location_bar_view.h" | 37 #include "chrome/browser/views/location_bar_view.h" |
38 #include "chrome/common/gfx/utils.h" | 38 #include "chrome/common/gfx/utils.h" |
39 #include "chrome/common/notification_service.h" | 39 #include "chrome/common/notification_service.h" |
40 #include "googleurl/src/url_util.h" | 40 #include "googleurl/src/url_util.h" |
41 #include "grit/generated_resources.h" | 41 #include "grit/generated_resources.h" |
| 42 #include "net/base/escape.h" |
42 #include "skia/ext/skia_utils_win.h" | 43 #include "skia/ext/skia_utils_win.h" |
43 #include "views/drag_utils.h" | 44 #include "views/drag_utils.h" |
44 #include "views/focus/focus_util_win.h" | 45 #include "views/focus/focus_util_win.h" |
45 #include "views/widget/widget.h" | 46 #include "views/widget/widget.h" |
46 | 47 |
47 #pragma comment(lib, "oleacc.lib") // Needed for accessibility support. | 48 #pragma comment(lib, "oleacc.lib") // Needed for accessibility support. |
48 | 49 |
49 /////////////////////////////////////////////////////////////////////////////// | 50 /////////////////////////////////////////////////////////////////////////////// |
50 // AutocompleteEditModel | 51 // AutocompleteEditModel |
51 | 52 |
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 if (model_->GetURLForText(text, &url)) { | 1191 if (model_->GetURLForText(text, &url)) { |
1191 // If the scheme is http or https and the user isn't editing, | 1192 // If the scheme is http or https and the user isn't editing, |
1192 // we should copy the true URL instead of the (unescaped) display | 1193 // we should copy the true URL instead of the (unescaped) display |
1193 // string to avoid encoding and escaping issues when pasting this text | 1194 // string to avoid encoding and escaping issues when pasting this text |
1194 // elsewhere. | 1195 // elsewhere. |
1195 if ((url.SchemeIs("http") || url.SchemeIs("https")) && | 1196 if ((url.SchemeIs("http") || url.SchemeIs("https")) && |
1196 !model_->user_input_in_progress()) | 1197 !model_->user_input_in_progress()) |
1197 scw.WriteText(UTF8ToWide(url.spec())); | 1198 scw.WriteText(UTF8ToWide(url.spec())); |
1198 else | 1199 else |
1199 scw.WriteText(text); | 1200 scw.WriteText(text); |
1200 scw.WriteHyperlink(text, url.spec()); | 1201 scw.WriteBookmark(text, url.spec()); |
| 1202 scw.WriteHyperlink(EscapeForHTML(UTF16ToUTF8(text)), url.spec()); |
1201 return; | 1203 return; |
1202 } | 1204 } |
1203 } | 1205 } |
1204 scw.WriteText(text); | 1206 scw.WriteText(text); |
1205 } | 1207 } |
1206 | 1208 |
1207 void AutocompleteEditViewWin::OnCut() { | 1209 void AutocompleteEditViewWin::OnCut() { |
1208 OnCopy(); | 1210 OnCopy(); |
1209 | 1211 |
1210 // This replace selection will have no effect (even on the undo stack) if the | 1212 // This replace selection will have no effect (even on the undo stack) if the |
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2371 context_menu_contents_->AddItemWithStringId(IDS_PASTE_AND_GO, | 2373 context_menu_contents_->AddItemWithStringId(IDS_PASTE_AND_GO, |
2372 IDS_PASTE_AND_GO); | 2374 IDS_PASTE_AND_GO); |
2373 context_menu_contents_->AddSeparator(); | 2375 context_menu_contents_->AddSeparator(); |
2374 context_menu_contents_->AddItemWithStringId(IDS_SELECT_ALL, IDS_SELECT_ALL); | 2376 context_menu_contents_->AddItemWithStringId(IDS_SELECT_ALL, IDS_SELECT_ALL); |
2375 context_menu_contents_->AddSeparator(); | 2377 context_menu_contents_->AddSeparator(); |
2376 context_menu_contents_->AddItemWithStringId(IDS_EDIT_SEARCH_ENGINES, | 2378 context_menu_contents_->AddItemWithStringId(IDS_EDIT_SEARCH_ENGINES, |
2377 IDS_EDIT_SEARCH_ENGINES); | 2379 IDS_EDIT_SEARCH_ENGINES); |
2378 } | 2380 } |
2379 context_menu_.reset(new views::Menu2(context_menu_contents_.get())); | 2381 context_menu_.reset(new views::Menu2(context_menu_contents_.get())); |
2380 } | 2382 } |
OLD | NEW |