| 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 22 matching lines...) Expand all Loading... |
| 33 type_(INVALID), | 33 type_(INVALID), |
| 34 prevent_inline_autocomplete_(false), | 34 prevent_inline_autocomplete_(false), |
| 35 prefer_keyword_(false), | 35 prefer_keyword_(false), |
| 36 allow_exact_keyword_match_(true), | 36 allow_exact_keyword_match_(true), |
| 37 matches_requested_(ALL_MATCHES) { | 37 matches_requested_(ALL_MATCHES) { |
| 38 } | 38 } |
| 39 | 39 |
| 40 AutocompleteInput::AutocompleteInput(const string16& text, | 40 AutocompleteInput::AutocompleteInput(const string16& text, |
| 41 size_t cursor_position, | 41 size_t cursor_position, |
| 42 const string16& desired_tld, | 42 const string16& desired_tld, |
| 43 const GURL& current_url, |
| 43 bool prevent_inline_autocomplete, | 44 bool prevent_inline_autocomplete, |
| 44 bool prefer_keyword, | 45 bool prefer_keyword, |
| 45 bool allow_exact_keyword_match, | 46 bool allow_exact_keyword_match, |
| 46 MatchesRequested matches_requested) | 47 MatchesRequested matches_requested) |
| 47 : cursor_position_(cursor_position), | 48 : cursor_position_(cursor_position), |
| 49 current_url_(current_url), |
| 48 prevent_inline_autocomplete_(prevent_inline_autocomplete), | 50 prevent_inline_autocomplete_(prevent_inline_autocomplete), |
| 49 prefer_keyword_(prefer_keyword), | 51 prefer_keyword_(prefer_keyword), |
| 50 allow_exact_keyword_match_(allow_exact_keyword_match), | 52 allow_exact_keyword_match_(allow_exact_keyword_match), |
| 51 matches_requested_(matches_requested) { | 53 matches_requested_(matches_requested) { |
| 52 DCHECK(cursor_position <= text.length() || cursor_position == string16::npos) | 54 DCHECK(cursor_position <= text.length() || cursor_position == string16::npos) |
| 53 << "Text: '" << text << "', cp: " << cursor_position; | 55 << "Text: '" << text << "', cp: " << cursor_position; |
| 54 // None of the providers care about leading white space so we always trim it. | 56 // None of the providers care about leading white space so we always trim it. |
| 55 // Providers that care about trailing white space handle trimming themselves. | 57 // Providers that care about trailing white space handle trimming themselves. |
| 56 if ((TrimWhitespace(text, TRIM_LEADING, &text_) & TRIM_LEADING) != 0) | 58 if ((TrimWhitespace(text, TRIM_LEADING, &text_) & TRIM_LEADING) != 0) |
| 57 AdjustCursorPositionIfNecessary(text.length() - text_.length(), | 59 AdjustCursorPositionIfNecessary(text.length() - text_.length(), |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 DCHECK(cursor_position <= text.length() || cursor_position == string16::npos) | 493 DCHECK(cursor_position <= text.length() || cursor_position == string16::npos) |
| 492 << "Text: '" << text << "', cp: " << cursor_position; | 494 << "Text: '" << text << "', cp: " << cursor_position; |
| 493 text_ = text; | 495 text_ = text; |
| 494 cursor_position_ = cursor_position; | 496 cursor_position_ = cursor_position; |
| 495 parts_ = parts; | 497 parts_ = parts; |
| 496 } | 498 } |
| 497 | 499 |
| 498 void AutocompleteInput::Clear() { | 500 void AutocompleteInput::Clear() { |
| 499 text_.clear(); | 501 text_.clear(); |
| 500 cursor_position_ = string16::npos; | 502 cursor_position_ = string16::npos; |
| 503 current_url_ = GURL(); |
| 501 type_ = INVALID; | 504 type_ = INVALID; |
| 502 parts_ = url_parse::Parsed(); | 505 parts_ = url_parse::Parsed(); |
| 503 scheme_.clear(); | 506 scheme_.clear(); |
| 504 canonicalized_url_ = GURL(); | 507 canonicalized_url_ = GURL(); |
| 505 prevent_inline_autocomplete_ = false; | 508 prevent_inline_autocomplete_ = false; |
| 506 prefer_keyword_ = false; | 509 prefer_keyword_ = false; |
| 507 allow_exact_keyword_match_ = false; | 510 allow_exact_keyword_match_ = false; |
| 508 matches_requested_ = ALL_MATCHES; | 511 matches_requested_ = ALL_MATCHES; |
| 509 } | 512 } |
| OLD | NEW |