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 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 input_text = user_input_in_progress_ ? user_text_ : permanent_text_; | 708 input_text = user_input_in_progress_ ? user_text_ : permanent_text_; |
709 scoped_ptr<OmniboxNavigationObserver> observer( | 709 scoped_ptr<OmniboxNavigationObserver> observer( |
710 new OmniboxNavigationObserver( | 710 new OmniboxNavigationObserver( |
711 profile_, input_text, match, | 711 profile_, input_text, match, |
712 autocomplete_controller()->history_url_provider()->SuggestExactInput( | 712 autocomplete_controller()->history_url_provider()->SuggestExactInput( |
713 input_text, alternate_nav_url, | 713 input_text, alternate_nav_url, |
714 AutocompleteInput::HasHTTPScheme(input_text)))); | 714 AutocompleteInput::HasHTTPScheme(input_text)))); |
715 | 715 |
716 base::TimeDelta elapsed_time_since_last_change_to_default_match( | 716 base::TimeDelta elapsed_time_since_last_change_to_default_match( |
717 now - autocomplete_controller()->last_time_default_match_changed()); | 717 now - autocomplete_controller()->last_time_default_match_changed()); |
| 718 DCHECK(match.provider); |
718 // These elapsed times don't really make sense for ZeroSuggest matches | 719 // These elapsed times don't really make sense for ZeroSuggest matches |
719 // (because the user does not modify the omnibox for ZeroSuggest), so for | 720 // (because the user does not modify the omnibox for ZeroSuggest), so for |
720 // those we set the elapsed times to something that will be ignored by | 721 // those we set the elapsed times to something that will be ignored by |
721 // metrics_log.cc. They also don't necessarily make sense if the omnibox | 722 // metrics_log.cc. They also don't necessarily make sense if the omnibox |
722 // dropdown is closed or the user used a paste-and-go action. (In most | 723 // dropdown is closed or the user used a paste-and-go action. (In most |
723 // cases when this happens, the user never modified the omnibox.) | 724 // cases when this happens, the user never modified the omnibox.) |
724 if ((match.provider && | 725 if ((match.provider->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST) || |
725 (match.provider->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST)) || | |
726 !popup_model()->IsOpen() || !pasted_text.empty()) { | 726 !popup_model()->IsOpen() || !pasted_text.empty()) { |
727 const base::TimeDelta default_time_delta = | 727 const base::TimeDelta default_time_delta = |
728 base::TimeDelta::FromMilliseconds(-1); | 728 base::TimeDelta::FromMilliseconds(-1); |
729 elapsed_time_since_user_first_modified_omnibox = default_time_delta; | 729 elapsed_time_since_user_first_modified_omnibox = default_time_delta; |
730 elapsed_time_since_last_change_to_default_match = default_time_delta; | 730 elapsed_time_since_last_change_to_default_match = default_time_delta; |
731 } | 731 } |
732 // If the popup is closed or this is a paste-and-go action (meaning the | 732 // If the popup is closed or this is a paste-and-go action (meaning the |
733 // contents of the dropdown are ignored regardless), we record for logging | 733 // contents of the dropdown are ignored regardless), we record for logging |
734 // purposes a selected_index of 0 and a suggestion list as having a single | 734 // purposes a selected_index of 0 and a suggestion list as having a single |
735 // entry of the match used. | 735 // entry of the match used. |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 // When we're not extracting search terms, AcceptInput() will take care of | 1311 // When we're not extracting search terms, AcceptInput() will take care of |
1312 // this (see code referring to PAGE_TRANSITION_RELOAD there), but when we're | 1312 // this (see code referring to PAGE_TRANSITION_RELOAD there), but when we're |
1313 // extracting search terms, the conditionals there won't fire, so we | 1313 // extracting search terms, the conditionals there won't fire, so we |
1314 // explicitly set up a match that will reload here. | 1314 // explicitly set up a match that will reload here. |
1315 | 1315 |
1316 // It's important that we fetch the current visible URL to reload instead of | 1316 // It's important that we fetch the current visible URL to reload instead of |
1317 // just getting a "search what you typed" URL from | 1317 // just getting a "search what you typed" URL from |
1318 // SearchProvider::CreateSearchSuggestion(), since the user may be in a | 1318 // SearchProvider::CreateSearchSuggestion(), since the user may be in a |
1319 // non-default search mode such as image search. | 1319 // non-default search mode such as image search. |
1320 match->type = AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED; | 1320 match->type = AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED; |
| 1321 match->provider = autocomplete_controller()->search_provider(); |
1321 match->destination_url = | 1322 match->destination_url = |
1322 delegate_->GetNavigationController().GetVisibleEntry()->GetURL(); | 1323 delegate_->GetNavigationController().GetVisibleEntry()->GetURL(); |
1323 match->transition = content::PAGE_TRANSITION_RELOAD; | 1324 match->transition = content::PAGE_TRANSITION_RELOAD; |
1324 } else if (query_in_progress() || | 1325 } else if (query_in_progress() || |
1325 (popup_model() && popup_model()->IsOpen())) { | 1326 (popup_model() && popup_model()->IsOpen())) { |
1326 if (query_in_progress()) { | 1327 if (query_in_progress()) { |
1327 // It's technically possible for |result| to be empty if no provider | 1328 // It's technically possible for |result| to be empty if no provider |
1328 // returns a synchronous result but the query has not completed | 1329 // returns a synchronous result but the query has not completed |
1329 // synchronously; pratically, however, that should never actually happen. | 1330 // synchronously; pratically, however, that should never actually happen. |
1330 if (result().empty()) | 1331 if (result().empty()) |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 // Update state and notify view if the omnibox has focus and the caret | 1457 // Update state and notify view if the omnibox has focus and the caret |
1457 // visibility changed. | 1458 // visibility changed. |
1458 const bool was_caret_visible = is_caret_visible(); | 1459 const bool was_caret_visible = is_caret_visible(); |
1459 focus_state_ = state; | 1460 focus_state_ = state; |
1460 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1461 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1461 is_caret_visible() != was_caret_visible) | 1462 is_caret_visible() != was_caret_visible) |
1462 view_->ApplyCaretVisibility(); | 1463 view_->ApplyCaretVisibility(); |
1463 | 1464 |
1464 delegate_->OnFocusChanged(focus_state_, reason); | 1465 delegate_->OnFocusChanged(focus_state_, reason); |
1465 } | 1466 } |
OLD | NEW |