| 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/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/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
| 15 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 15 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| 16 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 16 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
| 17 #include "chrome/browser/autocomplete/autocomplete_input.h" | 17 #include "chrome/browser/autocomplete/autocomplete_input.h" |
| 18 #include "chrome/browser/autocomplete/autocomplete_log.h" | 18 #include "chrome/browser/autocomplete/autocomplete_log.h" |
| 19 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
| 19 #include "chrome/browser/autocomplete/extension_app_provider.h" | 20 #include "chrome/browser/autocomplete/extension_app_provider.h" |
| 20 #include "chrome/browser/autocomplete/keyword_provider.h" | 21 #include "chrome/browser/autocomplete/keyword_provider.h" |
| 21 #include "chrome/browser/autocomplete/search_provider.h" | 22 #include "chrome/browser/autocomplete/search_provider.h" |
| 22 #include "chrome/browser/bookmarks/bookmark_utils.h" | 23 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 23 #include "chrome/browser/command_updater.h" | 24 #include "chrome/browser/command_updater.h" |
| 24 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" | 25 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
| 25 #include "chrome/browser/google/google_url_tracker.h" | 26 #include "chrome/browser/google/google_url_tracker.h" |
| 26 #include "chrome/browser/instant/instant_controller.h" | 27 #include "chrome/browser/instant/instant_controller.h" |
| 27 #include "chrome/browser/net/predictor.h" | 28 #include "chrome/browser/net/predictor.h" |
| 28 #include "chrome/browser/net/url_fixer_upper.h" | 29 #include "chrome/browser/net/url_fixer_upper.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 OmniboxEditModel::State::~State() { | 78 OmniboxEditModel::State::~State() { |
| 78 } | 79 } |
| 79 | 80 |
| 80 /////////////////////////////////////////////////////////////////////////////// | 81 /////////////////////////////////////////////////////////////////////////////// |
| 81 // OmniboxEditModel | 82 // OmniboxEditModel |
| 82 | 83 |
| 83 OmniboxEditModel::OmniboxEditModel(OmniboxView* view, | 84 OmniboxEditModel::OmniboxEditModel(OmniboxView* view, |
| 84 OmniboxEditController* controller, | 85 OmniboxEditController* controller, |
| 85 Profile* profile) | 86 Profile* profile) |
| 86 : ALLOW_THIS_IN_INITIALIZER_LIST( | 87 : ALLOW_THIS_IN_INITIALIZER_LIST( |
| 87 autocomplete_controller_(new AutocompleteController(profile, this))), | 88 autocomplete_controller_(new AutocompleteController(profile, this, |
| 89 AutocompleteClassifier::kDefaultOmniboxProviders))), |
| 88 view_(view), | 90 view_(view), |
| 89 popup_(NULL), | 91 popup_(NULL), |
| 90 controller_(controller), | 92 controller_(controller), |
| 91 has_focus_(false), | 93 has_focus_(false), |
| 92 user_input_in_progress_(false), | 94 user_input_in_progress_(false), |
| 93 just_deleted_text_(false), | 95 just_deleted_text_(false), |
| 94 has_temporary_text_(false), | 96 has_temporary_text_(false), |
| 95 paste_state_(NONE), | 97 paste_state_(NONE), |
| 96 control_key_state_(UP), | 98 control_key_state_(UP), |
| 97 is_keyword_hint_(false), | 99 is_keyword_hint_(false), |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 autocomplete_controller_->input().text(), | 521 autocomplete_controller_->input().text(), |
| 520 just_deleted_text_, | 522 just_deleted_text_, |
| 521 autocomplete_controller_->input().type(), | 523 autocomplete_controller_->input().type(), |
| 522 popup_->selected_line(), | 524 popup_->selected_line(), |
| 523 -1, // don't yet know tab ID; set later if appropriate | 525 -1, // don't yet know tab ID; set later if appropriate |
| 524 ClassifyPage(controller_->GetTabContents()-> | 526 ClassifyPage(controller_->GetTabContents()-> |
| 525 web_contents()->GetURL()), | 527 web_contents()->GetURL()), |
| 526 base::TimeTicks::Now() - time_user_first_modified_omnibox_, | 528 base::TimeTicks::Now() - time_user_first_modified_omnibox_, |
| 527 0, // inline autocomplete length; possibly set later | 529 0, // inline autocomplete length; possibly set later |
| 528 result()); | 530 result()); |
| 529 DCHECK(user_input_in_progress_ || match.provider->name() == "ZeroSuggest") | 531 DCHECK(user_input_in_progress_ || |
| 532 match.provider->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST) |
| 530 << "We didn't get here through the expected series of calls. " | 533 << "We didn't get here through the expected series of calls. " |
| 531 << "time_user_first_modified_omnibox_ is not set correctly and other " | 534 << "time_user_first_modified_omnibox_ is not set correctly and other " |
| 532 << "things may be wrong. Match provider: " << match.provider->name(); | 535 << "things may be wrong. Match provider: " << match.provider->GetName(); |
| 533 if (index != OmniboxPopupModel::kNoMatch) | 536 if (index != OmniboxPopupModel::kNoMatch) |
| 534 log.selected_index = index; | 537 log.selected_index = index; |
| 535 else if (!has_temporary_text_) | 538 else if (!has_temporary_text_) |
| 536 log.inline_autocompleted_length = inline_autocomplete_text_.length(); | 539 log.inline_autocompleted_length = inline_autocomplete_text_.length(); |
| 537 if (disposition == CURRENT_TAB) { | 540 if (disposition == CURRENT_TAB) { |
| 538 // If we know the destination is being opened in the current tab, | 541 // If we know the destination is being opened in the current tab, |
| 539 // we can easily get the tab ID. (If it's being opened in a new | 542 // we can easily get the tab ID. (If it's being opened in a new |
| 540 // tab, we don't know the tab ID yet.) | 543 // tab, we don't know the tab ID yet.) |
| 541 log.tab_id = controller_->GetTabContents()-> | 544 log.tab_id = controller_->GetTabContents()-> |
| 542 session_tab_helper()->session_id().id(); | 545 session_tab_helper()->session_id().id(); |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1221 } | 1224 } |
| 1222 | 1225 |
| 1223 void OmniboxEditModel::ClassifyStringForPasteAndGo( | 1226 void OmniboxEditModel::ClassifyStringForPasteAndGo( |
| 1224 const string16& text, | 1227 const string16& text, |
| 1225 AutocompleteMatch* match, | 1228 AutocompleteMatch* match, |
| 1226 GURL* alternate_nav_url) const { | 1229 GURL* alternate_nav_url) const { |
| 1227 DCHECK(match); | 1230 DCHECK(match); |
| 1228 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, | 1231 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, |
| 1229 string16(), false, false, match, alternate_nav_url); | 1232 string16(), false, false, match, alternate_nav_url); |
| 1230 } | 1233 } |
| OLD | NEW |