Chromium Code Reviews| 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 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 711 const GURL destination_url = autocomplete_controller()-> | 711 const GURL destination_url = autocomplete_controller()-> |
| 712 GetDestinationURL(match, query_formulation_time); | 712 GetDestinationURL(match, query_formulation_time); |
| 713 | 713 |
| 714 RecordPercentageMatchHistogram( | 714 RecordPercentageMatchHistogram( |
| 715 permanent_text_, current_text, | 715 permanent_text_, current_text, |
| 716 view_->toolbar_model()->WouldReplaceSearchURLWithSearchTerms(false), | 716 view_->toolbar_model()->WouldReplaceSearchURLWithSearchTerms(false), |
| 717 match.transition); | 717 match.transition); |
| 718 | 718 |
| 719 // Track whether the destination URL sends us to a search results page | 719 // Track whether the destination URL sends us to a search results page |
| 720 // using the default search provider. | 720 // using the default search provider. |
| 721 TemplateURL* default_provider = | 721 if (TemplateURLServiceFactory::GetForProfile(profile_)-> |
| 722 TemplateURLServiceFactory::GetForProfile(profile_)-> | 722 IsSearchResultsPageFromDefaultSearchProvider(destination_url)) { |
| 723 GetDefaultSearchProvider(); | |
| 724 if (default_provider && default_provider->IsSearchURL(destination_url)) | |
| 725 content::RecordAction( | 723 content::RecordAction( |
| 726 UserMetricsAction("OmniboxDestinationURLIsSearchOnDSP")); | 724 UserMetricsAction("OmniboxDestinationURLIsSearchOnDSP")); |
| 725 } | |
| 727 | 726 |
| 728 // This calls RevertAll again. | 727 // This calls RevertAll again. |
| 729 base::AutoReset<bool> tmp(&in_revert_, true); | 728 base::AutoReset<bool> tmp(&in_revert_, true); |
| 730 controller_->OnAutocompleteAccept(destination_url, disposition, | 729 controller_->OnAutocompleteAccept(destination_url, disposition, |
| 731 match.transition, alternate_nav_url); | 730 match.transition, alternate_nav_url); |
| 732 } | 731 } |
| 733 | 732 |
| 734 if (match.starred) | 733 if (match.starred) |
| 735 bookmark_utils::RecordBookmarkLaunch(bookmark_utils::LAUNCH_OMNIBOX); | 734 bookmark_utils::RecordBookmarkLaunch(bookmark_utils::LAUNCH_OMNIBOX); |
| 736 } | 735 } |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1262 const std::string& url = gurl.spec(); | 1261 const std::string& url = gurl.spec(); |
| 1263 if (url == chrome::kChromeUINewTabURL) | 1262 if (url == chrome::kChromeUINewTabURL) |
| 1264 return AutocompleteInput::NEW_TAB_PAGE; | 1263 return AutocompleteInput::NEW_TAB_PAGE; |
| 1265 if (url == content::kAboutBlankURL) | 1264 if (url == content::kAboutBlankURL) |
| 1266 return AutocompleteInput::BLANK; | 1265 return AutocompleteInput::BLANK; |
| 1267 if (url == profile()->GetPrefs()->GetString(prefs::kHomePage)) | 1266 if (url == profile()->GetPrefs()->GetString(prefs::kHomePage)) |
| 1268 return AutocompleteInput::HOMEPAGE; | 1267 return AutocompleteInput::HOMEPAGE; |
| 1269 if (view_->toolbar_model()->WouldReplaceSearchURLWithSearchTerms(true)) { | 1268 if (view_->toolbar_model()->WouldReplaceSearchURLWithSearchTerms(true)) { |
| 1270 return AutocompleteInput::SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT; | 1269 return AutocompleteInput::SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT; |
| 1271 } | 1270 } |
| 1271 if (delegate_->IsSearchResultsPage()) { | |
| 1272 return AutocompleteInput::SEARCH_RESULT_PAGE_NOT_DOING_SEARCH_TERM_REPLACEME NT; | |
|
rpetterson
2013/08/05 19:46:12
Putting AutocompleteInput::SEARCH_RESULT_PAGE_NOT_
Mark P
2013/08/06 19:38:36
Maybe you can break after the colon?
pkasting@ wo
Peter Kasting
2013/08/06 21:32:19
Yeah, break after the colon.
Better, try to come
rpetterson
2013/08/06 23:04:17
Excellent. I've changed the name. Problem avoided,
| |
| 1273 } | |
| 1272 return AutocompleteInput::OTHER; | 1274 return AutocompleteInput::OTHER; |
| 1273 } | 1275 } |
| 1274 | 1276 |
| 1275 void OmniboxEditModel::ClassifyStringForPasteAndGo( | 1277 void OmniboxEditModel::ClassifyStringForPasteAndGo( |
| 1276 const string16& text, | 1278 const string16& text, |
| 1277 AutocompleteMatch* match, | 1279 AutocompleteMatch* match, |
| 1278 GURL* alternate_nav_url) const { | 1280 GURL* alternate_nav_url) const { |
| 1279 DCHECK(match); | 1281 DCHECK(match); |
| 1280 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, | 1282 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, |
| 1281 false, false, match, alternate_nav_url); | 1283 false, false, match, alternate_nav_url); |
| 1282 } | 1284 } |
| 1283 | 1285 |
| 1284 void OmniboxEditModel::SetFocusState(OmniboxFocusState state, | 1286 void OmniboxEditModel::SetFocusState(OmniboxFocusState state, |
| 1285 OmniboxFocusChangeReason reason) { | 1287 OmniboxFocusChangeReason reason) { |
| 1286 if (state == focus_state_) | 1288 if (state == focus_state_) |
| 1287 return; | 1289 return; |
| 1288 | 1290 |
| 1289 InstantController* instant = GetInstantController(); | 1291 InstantController* instant = GetInstantController(); |
| 1290 if (instant) | 1292 if (instant) |
| 1291 instant->OmniboxFocusChanged(state, reason, NULL); | 1293 instant->OmniboxFocusChanged(state, reason, NULL); |
| 1292 | 1294 |
| 1293 // Update state and notify view if the omnibox has focus and the caret | 1295 // Update state and notify view if the omnibox has focus and the caret |
| 1294 // visibility changed. | 1296 // visibility changed. |
| 1295 const bool was_caret_visible = is_caret_visible(); | 1297 const bool was_caret_visible = is_caret_visible(); |
| 1296 focus_state_ = state; | 1298 focus_state_ = state; |
| 1297 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1299 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
| 1298 is_caret_visible() != was_caret_visible) | 1300 is_caret_visible() != was_caret_visible) |
| 1299 view_->ApplyCaretVisibility(); | 1301 view_->ApplyCaretVisibility(); |
| 1300 } | 1302 } |
| OLD | NEW |