| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 if (sel_start != 0) | 177 if (sel_start != 0) |
| 178 return; | 178 return; |
| 179 | 179 |
| 180 // We can't use CurrentTextIsURL() or GetDataForURLExport() because right now | 180 // We can't use CurrentTextIsURL() or GetDataForURLExport() because right now |
| 181 // the user is probably holding down control to cause the copy, which will | 181 // the user is probably holding down control to cause the copy, which will |
| 182 // screw up our calculation of the desired_tld. | 182 // screw up our calculation of the desired_tld. |
| 183 if (!GetURLForText(*text, url)) | 183 if (!GetURLForText(*text, url)) |
| 184 return; // Can't be parsed as a url, no need to adjust text. | 184 return; // Can't be parsed as a url, no need to adjust text. |
| 185 | 185 |
| 186 if (!user_input_in_progress() && is_all_selected) { | 186 if (!user_input_in_progress() && is_all_selected) { |
| 187 // The user selected all the text and has not edited it. Use the url as the |
| 188 // text so that if the scheme was stripped it's added back, and the url |
| 189 // is unescaped (we escape parts of the url for display). |
| 187 *text = UTF8ToWide(url->spec()); | 190 *text = UTF8ToWide(url->spec()); |
| 188 *write_url = true; | 191 *write_url = true; |
| 189 return; | 192 return; |
| 190 } | 193 } |
| 191 | 194 |
| 192 // Prefix the text with 'http://' if the text doesn't start with 'http://', | 195 // Prefix the text with 'http://' if the text doesn't start with 'http://', |
| 193 // the text parses as a url with a scheme of http, the user selected the | 196 // the text parses as a url with a scheme of http, the user selected the |
| 194 // entire host, and the user hasn't edited the host or manually removed the | 197 // entire host, and the user hasn't edited the host or manually removed the |
| 195 // scheme. | 198 // scheme. |
| 196 if (url->SchemeIs(chrome::kHttpScheme)) { | 199 if (url->SchemeIs(chrome::kHttpScheme)) { |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 AutocompleteMatch* match, | 622 AutocompleteMatch* match, |
| 620 GURL* alternate_nav_url) const { | 623 GURL* alternate_nav_url) const { |
| 621 if (popup_->IsOpen() || query_in_progress()) { | 624 if (popup_->IsOpen() || query_in_progress()) { |
| 622 popup_->InfoForCurrentSelection(match, alternate_nav_url); | 625 popup_->InfoForCurrentSelection(match, alternate_nav_url); |
| 623 } else { | 626 } else { |
| 624 profile_->GetAutocompleteClassifier()->Classify( | 627 profile_->GetAutocompleteClassifier()->Classify( |
| 625 UserTextFromDisplayText(view_->GetText()), GetDesiredTLD(), match, | 628 UserTextFromDisplayText(view_->GetText()), GetDesiredTLD(), match, |
| 626 alternate_nav_url); | 629 alternate_nav_url); |
| 627 } | 630 } |
| 628 } | 631 } |
| OLD | NEW |