OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/ui/omnibox/omnibox_edit_model.h" | 5 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 IsWhitespace(new_text[space_position - 1]) || | 1361 IsWhitespace(new_text[space_position - 1]) || |
1362 new_text.compare(0, space_position, old_text, 0, space_position) || | 1362 new_text.compare(0, space_position, old_text, 0, space_position) || |
1363 !new_text.compare(space_position, new_text.length() - space_position, | 1363 !new_text.compare(space_position, new_text.length() - space_position, |
1364 old_text, space_position, | 1364 old_text, space_position, |
1365 old_text.length() - space_position)) { | 1365 old_text.length() - space_position)) { |
1366 return false; | 1366 return false; |
1367 } | 1367 } |
1368 | 1368 |
1369 // Then check if the text before the inserted space matches a keyword. | 1369 // Then check if the text before the inserted space matches a keyword. |
1370 base::string16 keyword; | 1370 base::string16 keyword; |
1371 TrimWhitespace(new_text.substr(0, space_position), TRIM_LEADING, &keyword); | 1371 base::TrimWhitespace(new_text.substr(0, space_position), base::TRIM_LEADING, |
| 1372 &keyword); |
1372 return !keyword.empty() && !autocomplete_controller()->keyword_provider()-> | 1373 return !keyword.empty() && !autocomplete_controller()->keyword_provider()-> |
1373 GetKeywordForText(keyword).empty(); | 1374 GetKeywordForText(keyword).empty(); |
1374 } | 1375 } |
1375 | 1376 |
1376 // static | 1377 // static |
1377 bool OmniboxEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { | 1378 bool OmniboxEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { |
1378 switch (c) { | 1379 switch (c) { |
1379 case 0x0020: // Space | 1380 case 0x0020: // Space |
1380 case 0x3000: // Ideographic Space | 1381 case 0x3000: // Ideographic Space |
1381 return true; | 1382 return true; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 // Update state and notify view if the omnibox has focus and the caret | 1429 // Update state and notify view if the omnibox has focus and the caret |
1429 // visibility changed. | 1430 // visibility changed. |
1430 const bool was_caret_visible = is_caret_visible(); | 1431 const bool was_caret_visible = is_caret_visible(); |
1431 focus_state_ = state; | 1432 focus_state_ = state; |
1432 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1433 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1433 is_caret_visible() != was_caret_visible) | 1434 is_caret_visible() != was_caret_visible) |
1434 view_->ApplyCaretVisibility(); | 1435 view_->ApplyCaretVisibility(); |
1435 | 1436 |
1436 delegate_->OnFocusChanged(focus_state_, reason); | 1437 delegate_->OnFocusChanged(focus_state_, reason); |
1437 } | 1438 } |
OLD | NEW |