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 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 // treat this as a reload. | 679 // treat this as a reload. |
680 match.transition = content::PAGE_TRANSITION_RELOAD; | 680 match.transition = content::PAGE_TRANSITION_RELOAD; |
681 } else if (for_drop || ((paste_state_ != NONE) && | 681 } else if (for_drop || ((paste_state_ != NONE) && |
682 match.is_history_what_you_typed_match)) { | 682 match.is_history_what_you_typed_match)) { |
683 // When the user pasted in a URL and hit enter, score it like a link click | 683 // When the user pasted in a URL and hit enter, score it like a link click |
684 // rather than a normal typed URL, so it doesn't get inline autocompleted | 684 // rather than a normal typed URL, so it doesn't get inline autocompleted |
685 // as aggressively later. | 685 // as aggressively later. |
686 match.transition = content::PAGE_TRANSITION_LINK; | 686 match.transition = content::PAGE_TRANSITION_LINK; |
687 } | 687 } |
688 | 688 |
689 const TemplateURL* template_url = match.GetTemplateURL(profile_, false); | 689 TemplateURLService* service = |
| 690 TemplateURLServiceFactory::GetForProfile(profile_); |
| 691 const TemplateURL* template_url = match.GetTemplateURL(service, false); |
690 if (template_url && template_url->url_ref().HasGoogleBaseURLs( | 692 if (template_url && template_url->url_ref().HasGoogleBaseURLs( |
691 UIThreadSearchTermsData(profile_))) { | 693 UIThreadSearchTermsData(profile_))) { |
692 GoogleURLTracker* tracker = | 694 GoogleURLTracker* tracker = |
693 GoogleURLTrackerFactory::GetForProfile(profile_); | 695 GoogleURLTrackerFactory::GetForProfile(profile_); |
694 if (tracker) | 696 if (tracker) |
695 tracker->SearchCommitted(); | 697 tracker->SearchCommitted(); |
696 } | 698 } |
697 | 699 |
698 DCHECK(popup_model()); | 700 DCHECK(popup_model()); |
699 view_->OpenMatch(match, disposition, alternate_nav_url, base::string16(), | 701 view_->OpenMatch(match, disposition, alternate_nav_url, base::string16(), |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 autocomplete_controller()->AddProvidersInfo(&log.providers_info); | 778 autocomplete_controller()->AddProvidersInfo(&log.providers_info); |
777 content::NotificationService::current()->Notify( | 779 content::NotificationService::current()->Notify( |
778 chrome::NOTIFICATION_OMNIBOX_OPENED_URL, | 780 chrome::NOTIFICATION_OMNIBOX_OPENED_URL, |
779 content::Source<Profile>(profile_), | 781 content::Source<Profile>(profile_), |
780 content::Details<OmniboxLog>(&log)); | 782 content::Details<OmniboxLog>(&log)); |
781 HISTOGRAM_ENUMERATION("Omnibox.EventCount", 1, 2); | 783 HISTOGRAM_ENUMERATION("Omnibox.EventCount", 1, 2); |
782 DCHECK(!last_omnibox_focus_.is_null()) | 784 DCHECK(!last_omnibox_focus_.is_null()) |
783 << "An omnibox focus should have occurred before opening a match."; | 785 << "An omnibox focus should have occurred before opening a match."; |
784 UMA_HISTOGRAM_TIMES(kFocusToOpenTimeHistogram, now - last_omnibox_focus_); | 786 UMA_HISTOGRAM_TIMES(kFocusToOpenTimeHistogram, now - last_omnibox_focus_); |
785 | 787 |
786 TemplateURL* template_url = match.GetTemplateURL(profile_, false); | 788 TemplateURLService* service = |
| 789 TemplateURLServiceFactory::GetForProfile(profile_); |
| 790 TemplateURL* template_url = match.GetTemplateURL(service, false); |
787 if (template_url) { | 791 if (template_url) { |
788 if (match.transition == content::PAGE_TRANSITION_KEYWORD) { | 792 if (match.transition == content::PAGE_TRANSITION_KEYWORD) { |
789 // The user is using a non-substituting keyword or is explicitly in | 793 // The user is using a non-substituting keyword or is explicitly in |
790 // keyword mode. | 794 // keyword mode. |
791 | 795 |
792 // Don't increment usage count for extension keywords. | 796 // Don't increment usage count for extension keywords. |
793 if (delegate_->ProcessExtensionKeyword(template_url, match, | 797 if (delegate_->ProcessExtensionKeyword(template_url, match, |
794 disposition)) { | 798 disposition)) { |
795 observer->OnSuccessfulNavigation(); | 799 observer->OnSuccessfulNavigation(); |
796 if (disposition != NEW_BACKGROUND_TAB) | 800 if (disposition != NEW_BACKGROUND_TAB) |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 // handling has completely migrated to omnibox_controller. | 1261 // handling has completely migrated to omnibox_controller. |
1258 void OmniboxEditModel::OnCurrentMatchChanged() { | 1262 void OmniboxEditModel::OnCurrentMatchChanged() { |
1259 has_temporary_text_ = false; | 1263 has_temporary_text_ = false; |
1260 | 1264 |
1261 const AutocompleteMatch& match = omnibox_controller_->current_match(); | 1265 const AutocompleteMatch& match = omnibox_controller_->current_match(); |
1262 | 1266 |
1263 // We store |keyword| and |is_keyword_hint| in temporary variables since | 1267 // We store |keyword| and |is_keyword_hint| in temporary variables since |
1264 // OnPopupDataChanged use their previous state to detect changes. | 1268 // OnPopupDataChanged use their previous state to detect changes. |
1265 base::string16 keyword; | 1269 base::string16 keyword; |
1266 bool is_keyword_hint; | 1270 bool is_keyword_hint; |
1267 match.GetKeywordUIState(profile_, &keyword, &is_keyword_hint); | 1271 TemplateURLService* service = |
| 1272 TemplateURLServiceFactory::GetForProfile(profile_); |
| 1273 match.GetKeywordUIState(service, &keyword, &is_keyword_hint); |
1268 if (popup_model()) | 1274 if (popup_model()) |
1269 popup_model()->OnResultChanged(); | 1275 popup_model()->OnResultChanged(); |
1270 // OnPopupDataChanged() resets OmniboxController's |current_match_| early | 1276 // OnPopupDataChanged() resets OmniboxController's |current_match_| early |
1271 // on. Therefore, copy match.inline_autocompletion to a temp to preserve | 1277 // on. Therefore, copy match.inline_autocompletion to a temp to preserve |
1272 // its value across the entire call. | 1278 // its value across the entire call. |
1273 const base::string16 inline_autocompletion(match.inline_autocompletion); | 1279 const base::string16 inline_autocompletion(match.inline_autocompletion); |
1274 OnPopupDataChanged(inline_autocompletion, NULL, keyword, is_keyword_hint); | 1280 OnPopupDataChanged(inline_autocompletion, NULL, keyword, is_keyword_hint); |
1275 } | 1281 } |
1276 | 1282 |
1277 void OmniboxEditModel::SetSuggestionToPrefetch( | 1283 void OmniboxEditModel::SetSuggestionToPrefetch( |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1469 // Update state and notify view if the omnibox has focus and the caret | 1475 // Update state and notify view if the omnibox has focus and the caret |
1470 // visibility changed. | 1476 // visibility changed. |
1471 const bool was_caret_visible = is_caret_visible(); | 1477 const bool was_caret_visible = is_caret_visible(); |
1472 focus_state_ = state; | 1478 focus_state_ = state; |
1473 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1479 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1474 is_caret_visible() != was_caret_visible) | 1480 is_caret_visible() != was_caret_visible) |
1475 view_->ApplyCaretVisibility(); | 1481 view_->ApplyCaretVisibility(); |
1476 | 1482 |
1477 delegate_->OnFocusChanged(focus_state_, reason); | 1483 delegate_->OnFocusChanged(focus_state_, reason); |
1478 } | 1484 } |
OLD | NEW |