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