| 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/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 OmniboxPopupModel::kNoMatch); | 530 OmniboxPopupModel::kNoMatch); |
| 531 } | 531 } |
| 532 | 532 |
| 533 void OmniboxEditModel::OpenMatch(const AutocompleteMatch& match, | 533 void OmniboxEditModel::OpenMatch(const AutocompleteMatch& match, |
| 534 WindowOpenDisposition disposition, | 534 WindowOpenDisposition disposition, |
| 535 const GURL& alternate_nav_url, | 535 const GURL& alternate_nav_url, |
| 536 size_t index) { | 536 size_t index) { |
| 537 // We only care about cases where there is a selection (i.e. the popup is | 537 // We only care about cases where there is a selection (i.e. the popup is |
| 538 // open). | 538 // open). |
| 539 if (popup_->IsOpen()) { | 539 if (popup_->IsOpen()) { |
| 540 const base::TimeTicks& now(base::TimeTicks::Now()); |
| 540 // TODO(sreeram): Handle is_temporary_text_set_by_instant_ correctly. | 541 // TODO(sreeram): Handle is_temporary_text_set_by_instant_ correctly. |
| 541 AutocompleteLog log( | 542 AutocompleteLog log( |
| 542 autocomplete_controller_->input().text(), | 543 autocomplete_controller_->input().text(), |
| 543 just_deleted_text_, | 544 just_deleted_text_, |
| 544 autocomplete_controller_->input().type(), | 545 autocomplete_controller_->input().type(), |
| 545 popup_->selected_line(), | 546 popup_->selected_line(), |
| 546 -1, // don't yet know tab ID; set later if appropriate | 547 -1, // don't yet know tab ID; set later if appropriate |
| 547 ClassifyPage(controller_->GetWebContents()->GetURL()), | 548 ClassifyPage(controller_->GetWebContents()->GetURL()), |
| 548 base::TimeTicks::Now() - time_user_first_modified_omnibox_, | 549 now - time_user_first_modified_omnibox_, |
| 549 string16::npos, // inline autocomplete length; possibly set later | 550 string16::npos, // inline autocomplete length; possibly set later |
| 551 now - autocomplete_controller_->last_time_default_match_changed(), |
| 550 result()); | 552 result()); |
| 551 DCHECK(user_input_in_progress_ || | 553 DCHECK(user_input_in_progress_ || |
| 552 match.provider->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST) | 554 match.provider->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST) |
| 553 << "We didn't get here through the expected series of calls. " | 555 << "We didn't get here through the expected series of calls. " |
| 554 << "time_user_first_modified_omnibox_ is not set correctly and other " | 556 << "time_user_first_modified_omnibox_ is not set correctly and other " |
| 555 << "things may be wrong. Match provider: " << match.provider->GetName(); | 557 << "things may be wrong. Match provider: " << match.provider->GetName(); |
| 558 DCHECK(log.elapsed_time_since_user_first_modified_omnibox >= |
| 559 log.elapsed_time_since_last_change_to_default_match) |
| 560 << "We should've got the notification that the user modified the " |
| 561 << "omnibox text at same time or before the most recent time the " |
| 562 << "default match changed."; |
| 556 if (index != OmniboxPopupModel::kNoMatch) | 563 if (index != OmniboxPopupModel::kNoMatch) |
| 557 log.selected_index = index; | 564 log.selected_index = index; |
| 558 else if (!has_temporary_text_) | 565 else if (!has_temporary_text_) |
| 559 log.inline_autocompleted_length = inline_autocomplete_text_.length(); | 566 log.inline_autocompleted_length = inline_autocomplete_text_.length(); |
| 560 if (disposition == CURRENT_TAB) { | 567 if (disposition == CURRENT_TAB) { |
| 561 // If we know the destination is being opened in the current tab, | 568 // If we know the destination is being opened in the current tab, |
| 562 // we can easily get the tab ID. (If it's being opened in a new | 569 // we can easily get the tab ID. (If it's being opened in a new |
| 563 // tab, we don't know the tab ID yet.) | 570 // tab, we don't know the tab ID yet.) |
| 564 log.tab_id = SessionTabHelper::FromWebContents( | 571 log.tab_id = SessionTabHelper::FromWebContents( |
| 565 controller_->GetWebContents())->session_id().id(); | 572 controller_->GetWebContents())->session_id().id(); |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1264 } | 1271 } |
| 1265 | 1272 |
| 1266 void OmniboxEditModel::ClassifyStringForPasteAndGo( | 1273 void OmniboxEditModel::ClassifyStringForPasteAndGo( |
| 1267 const string16& text, | 1274 const string16& text, |
| 1268 AutocompleteMatch* match, | 1275 AutocompleteMatch* match, |
| 1269 GURL* alternate_nav_url) const { | 1276 GURL* alternate_nav_url) const { |
| 1270 DCHECK(match); | 1277 DCHECK(match); |
| 1271 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, | 1278 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, |
| 1272 string16(), false, false, match, alternate_nav_url); | 1279 string16(), false, false, match, alternate_nav_url); |
| 1273 } | 1280 } |
| OLD | NEW |