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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/stringprintf.h" | |
11 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
12 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
13 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 15 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
14 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 16 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
15 #include "chrome/browser/autocomplete/autocomplete_input.h" | 17 #include "chrome/browser/autocomplete/autocomplete_input.h" |
16 #include "chrome/browser/autocomplete/autocomplete_log.h" | 18 #include "chrome/browser/autocomplete/autocomplete_log.h" |
17 #include "chrome/browser/autocomplete/extension_app_provider.h" | 19 #include "chrome/browser/autocomplete/extension_app_provider.h" |
18 #include "chrome/browser/autocomplete/keyword_provider.h" | 20 #include "chrome/browser/autocomplete/keyword_provider.h" |
19 #include "chrome/browser/autocomplete/search_provider.h" | 21 #include "chrome/browser/autocomplete/search_provider.h" |
20 #include "chrome/browser/bookmarks/bookmark_utils.h" | 22 #include "chrome/browser/bookmarks/bookmark_utils.h" |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
596 } | 598 } |
597 | 599 |
598 if (disposition != NEW_BACKGROUND_TAB) { | 600 if (disposition != NEW_BACKGROUND_TAB) { |
599 in_revert_ = true; | 601 in_revert_ = true; |
600 view_->RevertAll(); // Revert the box to its unedited state | 602 view_->RevertAll(); // Revert the box to its unedited state |
601 } | 603 } |
602 | 604 |
603 if (match.type == AutocompleteMatch::EXTENSION_APP) { | 605 if (match.type == AutocompleteMatch::EXTENSION_APP) { |
604 ExtensionAppProvider::LaunchAppFromOmnibox(match, profile_, disposition); | 606 ExtensionAppProvider::LaunchAppFromOmnibox(match, profile_, disposition); |
605 } else { | 607 } else { |
606 controller_->OnAutocompleteAccept(match.destination_url, disposition, | 608 GURL destination_url(match.destination_url); |
609 if (template_url && match.search_terms_args.get()) { | |
Peter Kasting
2012/07/31 02:35:01
I think you should add "&& !match.search_terms_arg
hfung
2012/07/31 17:14:45
Done.
| |
610 // Append the query formulation time (time from when the user first typed | |
Peter Kasting
2012/07/31 02:35:01
Nit: The comment should probably go up above this
hfung
2012/07/31 17:14:45
Done.
| |
611 // a character into the omnibox to when the user selected a query) to the | |
612 // AQS parameter if other AQS parameters were already populated. | |
613 base::TimeDelta query_formulation_time = | |
614 base::TimeTicks::Now() - time_user_first_modified_omnibox_; | |
615 TemplateURLRef::SearchTermsArgs search_terms_args( | |
616 *match.search_terms_args); | |
617 if (!search_terms_args.assisted_query_stats.empty()) { | |
618 search_terms_args.assisted_query_stats += | |
619 base::StringPrintf(".%" PRId64, | |
620 query_formulation_time.InMilliseconds()); | |
621 } | |
622 destination_url = GURL(template_url->url_ref(). | |
623 ReplaceSearchTerms(search_terms_args)); | |
624 } | |
625 controller_->OnAutocompleteAccept(destination_url, disposition, | |
607 match.transition, alternate_nav_url); | 626 match.transition, alternate_nav_url); |
608 } | 627 } |
609 | 628 |
610 if (match.starred) | 629 if (match.starred) |
611 bookmark_utils::RecordBookmarkLaunch(bookmark_utils::LAUNCH_OMNIBOX); | 630 bookmark_utils::RecordBookmarkLaunch(bookmark_utils::LAUNCH_OMNIBOX); |
612 | 631 |
613 InstantController* instant = controller_->GetInstant(); | 632 InstantController* instant = controller_->GetInstant(); |
614 if (instant && !popup_->IsOpen()) | 633 if (instant && !popup_->IsOpen()) |
615 instant->DestroyPreviewContents(); | 634 instant->DestroyPreviewContents(); |
616 in_revert_ = false; | 635 in_revert_ = false; |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1173 } | 1192 } |
1174 | 1193 |
1175 void OmniboxEditModel::ClassifyStringForPasteAndGo( | 1194 void OmniboxEditModel::ClassifyStringForPasteAndGo( |
1176 const string16& text, | 1195 const string16& text, |
1177 AutocompleteMatch* match, | 1196 AutocompleteMatch* match, |
1178 GURL* alternate_nav_url) const { | 1197 GURL* alternate_nav_url) const { |
1179 DCHECK(match); | 1198 DCHECK(match); |
1180 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, | 1199 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, |
1181 string16(), false, false, match, alternate_nav_url); | 1200 string16(), false, false, match, alternate_nav_url); |
1182 } | 1201 } |
OLD | NEW |