Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: chrome/browser/autocomplete/autocomplete_input.cc

Issue 11896016: Omnibox: Trim Leading Spaces After Initial Forced-Query '?' (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 questions mark and first actual character.
Peter Kasting 2013/01/21 18:53:15 Nit: questions -> question
Mark P 2013/01/21 20:50:54 Done.
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698