Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_edit_model.cc

Issue 354773002: Reduces dependency from AutocompleteMatch to Profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 const TemplateURL* template_url = match.GetTemplateURL(profile_, false); 690 TemplateURLService* service =
691 TemplateURLServiceFactory::GetForProfile(profile_);
692 const TemplateURL* template_url = match.GetTemplateURL(service, false);
691 if (template_url && template_url->url_ref().HasGoogleBaseURLs( 693 if (template_url && template_url->url_ref().HasGoogleBaseURLs(
692 UIThreadSearchTermsData(profile_))) { 694 UIThreadSearchTermsData(profile_))) {
693 GoogleURLTracker* tracker = 695 GoogleURLTracker* tracker =
694 GoogleURLTrackerFactory::GetForProfile(profile_); 696 GoogleURLTrackerFactory::GetForProfile(profile_);
695 if (tracker) 697 if (tracker)
696 tracker->SearchCommitted(); 698 tracker->SearchCommitted();
697 } 699 }
698 700
699 DCHECK(popup_model()); 701 DCHECK(popup_model());
700 view_->OpenMatch(match, disposition, alternate_nav_url, base::string16(), 702 view_->OpenMatch(match, disposition, alternate_nav_url, base::string16(),
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 autocomplete_controller()->AddProvidersInfo(&log.providers_info); 779 autocomplete_controller()->AddProvidersInfo(&log.providers_info);
778 content::NotificationService::current()->Notify( 780 content::NotificationService::current()->Notify(
779 chrome::NOTIFICATION_OMNIBOX_OPENED_URL, 781 chrome::NOTIFICATION_OMNIBOX_OPENED_URL,
780 content::Source<Profile>(profile_), 782 content::Source<Profile>(profile_),
781 content::Details<OmniboxLog>(&log)); 783 content::Details<OmniboxLog>(&log));
782 HISTOGRAM_ENUMERATION("Omnibox.EventCount", 1, 2); 784 HISTOGRAM_ENUMERATION("Omnibox.EventCount", 1, 2);
783 DCHECK(!last_omnibox_focus_.is_null()) 785 DCHECK(!last_omnibox_focus_.is_null())
784 << "An omnibox focus should have occurred before opening a match."; 786 << "An omnibox focus should have occurred before opening a match.";
785 UMA_HISTOGRAM_TIMES(kFocusToOpenTimeHistogram, now - last_omnibox_focus_); 787 UMA_HISTOGRAM_TIMES(kFocusToOpenTimeHistogram, now - last_omnibox_focus_);
786 788
787 TemplateURL* template_url = match.GetTemplateURL(profile_, false); 789 TemplateURLService* service =
790 TemplateURLServiceFactory::GetForProfile(profile_);
791 TemplateURL* template_url = match.GetTemplateURL(service, false);
788 if (template_url) { 792 if (template_url) {
789 if (match.transition == content::PAGE_TRANSITION_KEYWORD) { 793 if (match.transition == content::PAGE_TRANSITION_KEYWORD) {
790 // The user is using a non-substituting keyword or is explicitly in 794 // The user is using a non-substituting keyword or is explicitly in
791 // keyword mode. 795 // keyword mode.
792 796
793 // Don't increment usage count for extension keywords. 797 // Don't increment usage count for extension keywords.
794 if (delegate_->ProcessExtensionKeyword(template_url, match, 798 if (delegate_->ProcessExtensionKeyword(template_url, match,
795 disposition)) { 799 disposition)) {
796 observer->OnSuccessfulNavigation(); 800 observer->OnSuccessfulNavigation();
797 if (disposition != NEW_BACKGROUND_TAB) 801 if (disposition != NEW_BACKGROUND_TAB)
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 // handling has completely migrated to omnibox_controller. 1262 // handling has completely migrated to omnibox_controller.
1259 void OmniboxEditModel::OnCurrentMatchChanged() { 1263 void OmniboxEditModel::OnCurrentMatchChanged() {
1260 has_temporary_text_ = false; 1264 has_temporary_text_ = false;
1261 1265
1262 const AutocompleteMatch& match = omnibox_controller_->current_match(); 1266 const AutocompleteMatch& match = omnibox_controller_->current_match();
1263 1267
1264 // We store |keyword| and |is_keyword_hint| in temporary variables since 1268 // We store |keyword| and |is_keyword_hint| in temporary variables since
1265 // OnPopupDataChanged use their previous state to detect changes. 1269 // OnPopupDataChanged use their previous state to detect changes.
1266 base::string16 keyword; 1270 base::string16 keyword;
1267 bool is_keyword_hint; 1271 bool is_keyword_hint;
1268 match.GetKeywordUIState(profile_, &keyword, &is_keyword_hint); 1272 TemplateURLService* service =
1273 TemplateURLServiceFactory::GetForProfile(profile_);
1274 match.GetKeywordUIState(service, &keyword, &is_keyword_hint);
1269 if (popup_model()) 1275 if (popup_model())
1270 popup_model()->OnResultChanged(); 1276 popup_model()->OnResultChanged();
1271 // OnPopupDataChanged() resets OmniboxController's |current_match_| early 1277 // OnPopupDataChanged() resets OmniboxController's |current_match_| early
1272 // on. Therefore, copy match.inline_autocompletion to a temp to preserve 1278 // on. Therefore, copy match.inline_autocompletion to a temp to preserve
1273 // its value across the entire call. 1279 // its value across the entire call.
1274 const base::string16 inline_autocompletion(match.inline_autocompletion); 1280 const base::string16 inline_autocompletion(match.inline_autocompletion);
1275 OnPopupDataChanged(inline_autocompletion, NULL, keyword, is_keyword_hint); 1281 OnPopupDataChanged(inline_autocompletion, NULL, keyword, is_keyword_hint);
1276 } 1282 }
1277 1283
1278 void OmniboxEditModel::SetSuggestionToPrefetch( 1284 void OmniboxEditModel::SetSuggestionToPrefetch(
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 // Update state and notify view if the omnibox has focus and the caret 1476 // Update state and notify view if the omnibox has focus and the caret
1471 // visibility changed. 1477 // visibility changed.
1472 const bool was_caret_visible = is_caret_visible(); 1478 const bool was_caret_visible = is_caret_visible();
1473 focus_state_ = state; 1479 focus_state_ = state;
1474 if (focus_state_ != OMNIBOX_FOCUS_NONE && 1480 if (focus_state_ != OMNIBOX_FOCUS_NONE &&
1475 is_caret_visible() != was_caret_visible) 1481 is_caret_visible() != was_caret_visible)
1476 view_->ApplyCaretVisibility(); 1482 view_->ApplyCaretVisibility();
1477 1483
1478 delegate_->OnFocusChanged(focus_state_, reason); 1484 delegate_->OnFocusChanged(focus_state_, reason);
1479 } 1485 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698