| 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 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 IsWhitespace(new_text[space_position - 1]) || | 1381 IsWhitespace(new_text[space_position - 1]) || |
| 1382 new_text.compare(0, space_position, old_text, 0, space_position) || | 1382 new_text.compare(0, space_position, old_text, 0, space_position) || |
| 1383 !new_text.compare(space_position, new_text.length() - space_position, | 1383 !new_text.compare(space_position, new_text.length() - space_position, |
| 1384 old_text, space_position, | 1384 old_text, space_position, |
| 1385 old_text.length() - space_position)) { | 1385 old_text.length() - space_position)) { |
| 1386 return false; | 1386 return false; |
| 1387 } | 1387 } |
| 1388 | 1388 |
| 1389 // Then check if the text before the inserted space matches a keyword. | 1389 // Then check if the text before the inserted space matches a keyword. |
| 1390 base::string16 keyword; | 1390 base::string16 keyword; |
| 1391 TrimWhitespace(new_text.substr(0, space_position), TRIM_LEADING, &keyword); | 1391 base::TrimWhitespace(new_text.substr(0, space_position), base::TRIM_LEADING, |
| 1392 &keyword); |
| 1392 return !keyword.empty() && !autocomplete_controller()->keyword_provider()-> | 1393 return !keyword.empty() && !autocomplete_controller()->keyword_provider()-> |
| 1393 GetKeywordForText(keyword).empty(); | 1394 GetKeywordForText(keyword).empty(); |
| 1394 } | 1395 } |
| 1395 | 1396 |
| 1396 // static | 1397 // static |
| 1397 bool OmniboxEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { | 1398 bool OmniboxEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { |
| 1398 switch (c) { | 1399 switch (c) { |
| 1399 case 0x0020: // Space | 1400 case 0x0020: // Space |
| 1400 case 0x3000: // Ideographic Space | 1401 case 0x3000: // Ideographic Space |
| 1401 return true; | 1402 return true; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1450 instant->OmniboxFocusChanged(state, reason, NULL); | 1451 instant->OmniboxFocusChanged(state, reason, NULL); |
| 1451 | 1452 |
| 1452 // Update state and notify view if the omnibox has focus and the caret | 1453 // Update state and notify view if the omnibox has focus and the caret |
| 1453 // visibility changed. | 1454 // visibility changed. |
| 1454 const bool was_caret_visible = is_caret_visible(); | 1455 const bool was_caret_visible = is_caret_visible(); |
| 1455 focus_state_ = state; | 1456 focus_state_ = state; |
| 1456 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1457 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
| 1457 is_caret_visible() != was_caret_visible) | 1458 is_caret_visible() != was_caret_visible) |
| 1458 view_->ApplyCaretVisibility(); | 1459 view_->ApplyCaretVisibility(); |
| 1459 } | 1460 } |
| OLD | NEW |