| 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/autocomplete/autocomplete_input.h" | 5 #include "chrome/browser/autocomplete/autocomplete_input.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/external_protocol/external_protocol_handler.h" | 9 #include "chrome/browser/external_protocol/external_protocol_handler.h" |
| 10 #include "chrome/browser/net/url_fixer_upper.h" | 10 #include "chrome/browser/net/url_fixer_upper.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 if (((type_ == UNKNOWN) || (type_ == REQUESTED_URL) || (type_ == URL)) && | 66 if (((type_ == UNKNOWN) || (type_ == REQUESTED_URL) || (type_ == URL)) && |
| 67 canonicalized_url.is_valid() && | 67 canonicalized_url.is_valid() && |
| 68 (!canonicalized_url.IsStandard() || canonicalized_url.SchemeIsFile() || | 68 (!canonicalized_url.IsStandard() || canonicalized_url.SchemeIsFile() || |
| 69 canonicalized_url.SchemeIsFileSystem() || | 69 canonicalized_url.SchemeIsFileSystem() || |
| 70 !canonicalized_url.host().empty())) | 70 !canonicalized_url.host().empty())) |
| 71 canonicalized_url_ = canonicalized_url; | 71 canonicalized_url_ = canonicalized_url; |
| 72 | 72 |
| 73 size_t chars_removed = RemoveForcedQueryStringIfNecessary(type_, &text_); | 73 size_t chars_removed = RemoveForcedQueryStringIfNecessary(type_, &text_); |
| 74 AdjustCursorPositionIfNecessary(chars_removed, &cursor_position_); | 74 AdjustCursorPositionIfNecessary(chars_removed, &cursor_position_); |
| 75 if (chars_removed) { |
| 76 // Remove spaces between opening question mark and first actual character. |
| 77 string16 trimmed_text; |
| 78 if ((TrimWhitespace(text_, TRIM_LEADING, &trimmed_text) & TRIM_LEADING) != |
| 79 0) { |
| 80 AdjustCursorPositionIfNecessary(text_.length() - trimmed_text.length(), |
| 81 &cursor_position_); |
| 82 text_ = trimmed_text; |
| 83 } |
| 84 } |
| 75 } | 85 } |
| 76 | 86 |
| 77 AutocompleteInput::~AutocompleteInput() { | 87 AutocompleteInput::~AutocompleteInput() { |
| 78 } | 88 } |
| 79 | 89 |
| 80 // static | 90 // static |
| 81 size_t AutocompleteInput::RemoveForcedQueryStringIfNecessary(Type type, | 91 size_t AutocompleteInput::RemoveForcedQueryStringIfNecessary(Type type, |
| 82 string16* text) { | 92 string16* text) { |
| 83 if (type != FORCED_QUERY || text->empty() || (*text)[0] != L'?') | 93 if (type != FORCED_QUERY || text->empty() || (*text)[0] != L'?') |
| 84 return 0; | 94 return 0; |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 void AutocompleteInput::Clear() { | 512 void AutocompleteInput::Clear() { |
| 503 text_.clear(); | 513 text_.clear(); |
| 504 cursor_position_ = string16::npos; | 514 cursor_position_ = string16::npos; |
| 505 type_ = INVALID; | 515 type_ = INVALID; |
| 506 parts_ = url_parse::Parsed(); | 516 parts_ = url_parse::Parsed(); |
| 507 scheme_.clear(); | 517 scheme_.clear(); |
| 508 desired_tld_.clear(); | 518 desired_tld_.clear(); |
| 509 prevent_inline_autocomplete_ = false; | 519 prevent_inline_autocomplete_ = false; |
| 510 prefer_keyword_ = false; | 520 prefer_keyword_ = false; |
| 511 } | 521 } |
| OLD | NEW |