summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-12 19:32:49 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-12 19:32:49 +0000
commita4ffa8cf38d76e3ed86f55e5abe5bb9650fb6383 (patch)
tree048ebe6de0e34afd23a449704919f6fbe8a137c1 /chrome
parent9603c8e626c6818e92368904b9b5d8d21191d376 (diff)
downloadchromium_src-a4ffa8cf38d76e3ed86f55e5abe5bb9650fb6383.zip
chromium_src-a4ffa8cf38d76e3ed86f55e5abe5bb9650fb6383.tar.gz
chromium_src-a4ffa8cf38d76e3ed86f55e5abe5bb9650fb6383.tar.bz2
Omnibox metrics logging patch splitout, part 3: Pass match.type to the edit and let it make the determination about showing the search hint, instead of making the determination in the popup.
In the ultimate patch, the types on which we'll show the hint will expand, so this saved duplicating some logic at points in the popup; in retrospect it makes more sense anyway, since there's no reason for the popup to know anything about the search hint. That's more the edit's job anyway. Review URL: http://codereview.chromium.org/10839 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5276 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit.cc9
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit.h12
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup.cc9
3 files changed, 13 insertions, 17 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc
index fa60973..f9cd006 100644
--- a/chrome/browser/autocomplete/autocomplete_edit.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit.cc
@@ -434,20 +434,21 @@ void AutocompleteEditModel::OnPopupDataChanged(
bool is_temporary_text,
const std::wstring& keyword,
bool is_keyword_hint,
- bool can_show_search_hint) {
+ AutocompleteMatch::Type type) {
// We don't want to show the search hint if we're showing a keyword hint or
// selected keyword, or (subtle!) if we would be showing a selected keyword
// but for keyword_ui_state_ == NO_KEYWORD.
- can_show_search_hint &= keyword.empty();
+ const bool show_search_hint = keyword.empty() &&
+ (type == AutocompleteMatch::SEARCH);
// Update keyword/hint-related local state.
bool keyword_state_changed = (keyword_ != keyword) ||
((is_keyword_hint_ != is_keyword_hint) && !keyword.empty()) ||
- (show_search_hint_ != can_show_search_hint);
+ (show_search_hint_ != show_search_hint);
if (keyword_state_changed) {
keyword_ = keyword;
is_keyword_hint_ = is_keyword_hint;
- show_search_hint_ = can_show_search_hint;
+ show_search_hint_ = show_search_hint;
}
// Handle changes to temporary text.
diff --git a/chrome/browser/autocomplete/autocomplete_edit.h b/chrome/browser/autocomplete/autocomplete_edit.h
index 15e3688..99309ef 100644
--- a/chrome/browser/autocomplete/autocomplete_edit.h
+++ b/chrome/browser/autocomplete/autocomplete_edit.h
@@ -260,22 +260,18 @@ class AutocompleteEditModel {
// |text| is either the new temporary text (if |is_temporary_text| is true)
// from the user manually selecting a different match, or the inline
// autocomplete text (if |is_temporary_text| is false).
- // |previous_selected_match| is only used when changing the temporary text;
- // it is the match that was (manually or automatically) selected before
- // the current manual selection, and is saved to be restored later if the
- // user hits <esc>.
- // |can_show_search_hint| is true if the current choice is nonexistent or a
- // search result; in these cases it may be OK to show the "Type to search"
- // hint (see comments on show_search_hint_).
// |keyword| is the keyword to show a hint for if |is_keyword_hint| is true,
// or the currently selected keyword if |is_keyword_hint| is false (see
// comments on keyword_ and is_keyword_hint_).
+ // |type| is the type of match selected; this is used to determine whether
+ // we can show the "Type to search" hint (see comments on
+ // show_search_hint_).
void OnPopupDataChanged(
const std::wstring& text,
bool is_temporary_text,
const std::wstring& keyword,
bool is_keyword_hint,
- bool can_show_search_hint);
+ AutocompleteMatch::Type type);
// Called by the AutocompleteEditView after something changes, with details
// about what state changes occured. Updates internal state, updates the
diff --git a/chrome/browser/autocomplete/autocomplete_popup.cc b/chrome/browser/autocomplete/autocomplete_popup.cc
index 9b61383..5a457c9 100644
--- a/chrome/browser/autocomplete/autocomplete_popup.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup.cc
@@ -751,8 +751,7 @@ void AutocompletePopupModel::SetSelectedLine(size_t line,
const bool is_keyword_hint = GetKeywordForMatch(match, &keyword);
edit_model_->OnPopupDataChanged(
reset_to_default ? std::wstring() : match.fill_into_edit,
- !reset_to_default, keyword, is_keyword_hint,
- (match.type == AutocompleteMatch::SEARCH));
+ !reset_to_default, keyword, is_keyword_hint, match.type);
// Repaint old and new selected lines immediately, so that the edit doesn't
// appear to update [much] faster than the popup. We must not update
@@ -952,7 +951,7 @@ void AutocompletePopupModel::Observe(NotificationType type,
std::wstring inline_autocomplete_text;
std::wstring keyword;
bool is_keyword_hint = false;
- bool can_show_search_hint = true;
+ AutocompleteMatch::Type type = AutocompleteMatch::SEARCH;
const AutocompleteResult::const_iterator match(result.default_match());
if (match != result.end()) {
if ((match->inline_autocomplete_offset != std::wstring::npos) &&
@@ -968,10 +967,10 @@ void AutocompletePopupModel::Observe(NotificationType type,
// the OS DNS cache could suffer eviction problems for minimal gain.
is_keyword_hint = GetKeywordForMatch(*match, &keyword);
- can_show_search_hint = (match->type == AutocompleteMatch::SEARCH);
+ type = match->type;
}
edit_model_->OnPopupDataChanged(inline_autocomplete_text, false, keyword,
- is_keyword_hint, can_show_search_hint);
+ is_keyword_hint, type);
return;
}