| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| 11 #include "base/format_macros.h" | 11 #include "base/format_macros.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 14 #include "base/profiler/scoped_tracker.h" |
| 14 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 18 #include "chrome/app/chrome_command_ids.h" | 19 #include "chrome/app/chrome_command_ids.h" |
| 19 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 20 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| 20 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 21 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
| 21 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 22 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
| 22 #include "chrome/browser/autocomplete/history_url_provider.h" | 23 #include "chrome/browser/autocomplete/history_url_provider.h" |
| 23 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 24 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 false, true); | 547 false, true); |
| 547 AutocompleteActionPredictor* action_predictor = | 548 AutocompleteActionPredictor* action_predictor = |
| 548 predictors::AutocompleteActionPredictorFactory::GetForProfile(profile_); | 549 predictors::AutocompleteActionPredictorFactory::GetForProfile(profile_); |
| 549 action_predictor->ClearTransitionalMatches(); | 550 action_predictor->ClearTransitionalMatches(); |
| 550 action_predictor->CancelPrerender(); | 551 action_predictor->CancelPrerender(); |
| 551 } | 552 } |
| 552 | 553 |
| 553 void OmniboxEditModel::StartAutocomplete( | 554 void OmniboxEditModel::StartAutocomplete( |
| 554 bool has_selected_text, | 555 bool has_selected_text, |
| 555 bool prevent_inline_autocomplete) { | 556 bool prevent_inline_autocomplete) { |
| 557 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed. |
| 558 tracked_objects::ScopedTracker tracking_profile( |
| 559 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 560 "440919 OmniboxEditModel::StartAutocomplete")); |
| 556 size_t cursor_position; | 561 size_t cursor_position; |
| 557 if (inline_autocomplete_text_.empty()) { | 562 if (inline_autocomplete_text_.empty()) { |
| 558 // Cursor position is equivalent to the current selection's end. | 563 // Cursor position is equivalent to the current selection's end. |
| 559 size_t start; | 564 size_t start; |
| 560 view_->GetSelectionBounds(&start, &cursor_position); | 565 view_->GetSelectionBounds(&start, &cursor_position); |
| 561 // Adjust cursor position taking into account possible keyword in the user | 566 // Adjust cursor position taking into account possible keyword in the user |
| 562 // text. We rely on DisplayTextFromUserText() method which is consistent | 567 // text. We rely on DisplayTextFromUserText() method which is consistent |
| 563 // with keyword extraction done in KeywordProvider/SearchProvider. | 568 // with keyword extraction done in KeywordProvider/SearchProvider. |
| 564 const size_t cursor_offset = | 569 const size_t cursor_offset = |
| 565 user_text_.length() - DisplayTextFromUserText(user_text_).length(); | 570 user_text_.length() - DisplayTextFromUserText(user_text_).length(); |
| (...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1462 // Update state and notify view if the omnibox has focus and the caret | 1467 // Update state and notify view if the omnibox has focus and the caret |
| 1463 // visibility changed. | 1468 // visibility changed. |
| 1464 const bool was_caret_visible = is_caret_visible(); | 1469 const bool was_caret_visible = is_caret_visible(); |
| 1465 focus_state_ = state; | 1470 focus_state_ = state; |
| 1466 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1471 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
| 1467 is_caret_visible() != was_caret_visible) | 1472 is_caret_visible() != was_caret_visible) |
| 1468 view_->ApplyCaretVisibility(); | 1473 view_->ApplyCaretVisibility(); |
| 1469 | 1474 |
| 1470 delegate_->OnFocusChanged(focus_state_, reason); | 1475 delegate_->OnFocusChanged(focus_state_, reason); |
| 1471 } | 1476 } |
| OLD | NEW |