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/keyword_provider.h" | 5 #include "chrome/browser/autocomplete/keyword_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 } // namespace | 99 } // namespace |
100 | 100 |
101 // static | 101 // static |
102 string16 KeywordProvider::SplitKeywordFromInput( | 102 string16 KeywordProvider::SplitKeywordFromInput( |
103 const string16& input, | 103 const string16& input, |
104 bool trim_leading_whitespace, | 104 bool trim_leading_whitespace, |
105 string16* remaining_input) { | 105 string16* remaining_input) { |
106 // Find end of first token. The AutocompleteController has trimmed leading | 106 // Find end of first token. The AutocompleteController has trimmed leading |
107 // whitespace, so we need not skip over that. | 107 // whitespace, so we need not skip over that. |
108 const size_t first_white(input.find_first_of(kWhitespaceUTF16)); | 108 const size_t first_white(input.find_first_of(base::kWhitespaceUTF16)); |
109 DCHECK_NE(0U, first_white); | 109 DCHECK_NE(0U, first_white); |
110 if (first_white == string16::npos) | 110 if (first_white == string16::npos) |
111 return input; // Only one token provided. | 111 return input; // Only one token provided. |
112 | 112 |
113 // Set |remaining_input| to everything after the first token. | 113 // Set |remaining_input| to everything after the first token. |
114 DCHECK(remaining_input != NULL); | 114 DCHECK(remaining_input != NULL); |
115 const size_t remaining_start = trim_leading_whitespace ? | 115 const size_t remaining_start = trim_leading_whitespace ? |
116 input.find_first_not_of(kWhitespaceUTF16, first_white) : first_white + 1; | 116 input.find_first_not_of(base::kWhitespaceUTF16, first_white) : |
| 117 first_white + 1; |
117 | 118 |
118 if (remaining_start < input.length()) | 119 if (remaining_start < input.length()) |
119 remaining_input->assign(input.begin() + remaining_start, input.end()); | 120 remaining_input->assign(input.begin() + remaining_start, input.end()); |
120 | 121 |
121 // Return first token as keyword. | 122 // Return first token as keyword. |
122 return input.substr(0, first_white); | 123 return input.substr(0, first_white); |
123 } | 124 } |
124 | 125 |
125 // static | 126 // static |
126 string16 KeywordProvider::SplitReplacementStringFromInput( | 127 string16 KeywordProvider::SplitReplacementStringFromInput( |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 } | 631 } |
631 | 632 |
632 void KeywordProvider::MaybeEndExtensionKeywordMode() { | 633 void KeywordProvider::MaybeEndExtensionKeywordMode() { |
633 if (!current_keyword_extension_id_.empty()) { | 634 if (!current_keyword_extension_id_.empty()) { |
634 extensions::ExtensionOmniboxEventRouter::OnInputCancelled( | 635 extensions::ExtensionOmniboxEventRouter::OnInputCancelled( |
635 profile_, current_keyword_extension_id_); | 636 profile_, current_keyword_extension_id_); |
636 | 637 |
637 current_keyword_extension_id_.clear(); | 638 current_keyword_extension_id_.clear(); |
638 } | 639 } |
639 } | 640 } |
OLD | NEW |