summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
authorsamarth@chromium.org <samarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-14 00:46:26 +0000
committersamarth@chromium.org <samarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-14 00:46:26 +0000
commit0d0b4a4e77be5bcd40895f814241a1ea233f1a22 (patch)
tree9af16b951ba4b9a9b2cd72c9e1b43c0e61989f57 /chrome/browser/ui
parent41bb06f20858e038aa9fa02be5de415b757bc113 (diff)
downloadchromium_src-0d0b4a4e77be5bcd40895f814241a1ea233f1a22.zip
chromium_src-0d0b4a4e77be5bcd40895f814241a1ea233f1a22.tar.gz
chromium_src-0d0b4a4e77be5bcd40895f814241a1ea233f1a22.tar.bz2
InstantExtended: notify Instant NTP when user input starts and ends.
BUG=248164 R=jered@chromium.org, palmer@chromium.org Review URL: https://codereview.chromium.org/15951013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206255 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r--chrome/browser/ui/browser_instant_controller.cc8
-rw-r--r--chrome/browser/ui/search/instant_controller.cc15
-rw-r--r--chrome/browser/ui/search/instant_controller.h6
-rw-r--r--chrome/browser/ui/search/instant_page.cc5
-rw-r--r--chrome/browser/ui/search/instant_page.h3
5 files changed, 34 insertions, 3 deletions
diff --git a/chrome/browser/ui/browser_instant_controller.cc b/chrome/browser/ui/browser_instant_controller.cc
index cacd42f..008753e 100644
--- a/chrome/browser/ui/browser_instant_controller.cc
+++ b/chrome/browser/ui/browser_instant_controller.cc
@@ -211,6 +211,14 @@ void BrowserInstantController::FocusOmnibox(bool caret_visibility) {
GetLocationEntry();
omnibox_view->SetFocus();
omnibox_view->model()->SetCaretVisibility(caret_visibility);
+ if (!caret_visibility) {
+ // If the user clicked on the fakebox, any text already in the omnibox
+ // should get cleared when they start typing. Selecting all the existing
+ // text is a convenient way to accomplish this. It also gives a slight
+ // visual cue to users who really understand selection state about what will
+ // happen if they start typing.
+ omnibox_view->SelectAll(false);
+ }
}
content::WebContents* BrowserInstantController::GetActiveWebContents() const {
diff --git a/chrome/browser/ui/search/instant_controller.cc b/chrome/browser/ui/search/instant_controller.cc
index 9a3e084..f4ba1a4 100644
--- a/chrome/browser/ui/search/instant_controller.cc
+++ b/chrome/browser/ui/search/instant_controller.cc
@@ -976,8 +976,11 @@ void InstantController::OmniboxFocusChanged(
if (extended_enabled()) {
if (overlay_)
overlay_->FocusChanged(omnibox_focus_state_, reason);
- if (instant_tab_)
+
+ if (instant_tab_) {
instant_tab_->FocusChanged(omnibox_focus_state_, reason);
+ instant_tab_->SetInputInProgress(IsInputInProgress());
+ }
}
if (state == OMNIBOX_FOCUS_VISIBLE && old_focus_state == OMNIBOX_FOCUS_NONE) {
@@ -1008,6 +1011,10 @@ void InstantController::SearchModeChanged(const SearchMode& old_mode,
HideOverlay();
ResetInstantTab();
+
+ if (instant_tab_ &&
+ old_mode.is_search_suggestions() != new_mode.is_search_suggestions())
+ instant_tab_->SetInputInProgress(IsInputInProgress());
}
void InstantController::ActiveTabChanged() {
@@ -1655,9 +1662,15 @@ void InstantController::UpdateInfoForInstantTab() {
UpdateMostVisitedItems();
instant_tab_->FocusChanged(omnibox_focus_state_,
omnibox_focus_change_reason_);
+ instant_tab_->SetInputInProgress(IsInputInProgress());
}
}
+bool InstantController::IsInputInProgress() const {
+ return search_mode_.is_search_suggestions() &&
+ omnibox_focus_state_ == OMNIBOX_FOCUS_VISIBLE;
+}
+
void InstantController::HideOverlay() {
HideInternal();
ReloadOverlayIfStale();
diff --git a/chrome/browser/ui/search/instant_controller.h b/chrome/browser/ui/search/instant_controller.h
index fe4cd93..cdb170b 100644
--- a/chrome/browser/ui/search/instant_controller.h
+++ b/chrome/browser/ui/search/instant_controller.h
@@ -402,6 +402,10 @@ class InstantController : public InstantPage::Delegate {
// Sends theme info, omnibox bounds, font info, etc. down to the Instant tab.
void UpdateInfoForInstantTab();
+ // Returns whether input is in progress, i.e. if the omnibox has focus and the
+ // active tab is in mode SEARCH_SUGGESTIONS.
+ bool IsInputInProgress() const;
+
// Hide the overlay. Also sends an onchange event (with blank query) to the
// overlay, telling it to clear out results for any old queries.
void HideOverlay();
@@ -417,8 +421,6 @@ class InstantController : public InstantPage::Delegate {
// Send the omnibox popup bounds to the page.
void SendPopupBoundsToPage();
-
-
// If possible, tries to mutate |suggestion| to a valid suggestion. Returns
// true if successful. (Note that |suggestion| may be modified even if this
// returns false.)
diff --git a/chrome/browser/ui/search/instant_page.cc b/chrome/browser/ui/search/instant_page.cc
index 3fe82ba..8568d2e 100644
--- a/chrome/browser/ui/search/instant_page.cc
+++ b/chrome/browser/ui/search/instant_page.cc
@@ -117,6 +117,11 @@ void InstantPage::FocusChanged(OmniboxFocusState state,
Send(new ChromeViewMsg_SearchBoxFocusChanged(routing_id(), state, reason));
}
+void InstantPage::SetInputInProgress(bool input_in_progress) {
+ Send(new ChromeViewMsg_SearchBoxSetInputInProgress(
+ routing_id(), input_in_progress));
+}
+
void InstantPage::SendMostVisitedItems(
const std::vector<InstantMostVisitedItem>& items) {
Send(new ChromeViewMsg_SearchBoxMostVisitedItemsChanged(routing_id(), items));
diff --git a/chrome/browser/ui/search/instant_page.h b/chrome/browser/ui/search/instant_page.h
index 53a3243..5bb3045 100644
--- a/chrome/browser/ui/search/instant_page.h
+++ b/chrome/browser/ui/search/instant_page.h
@@ -191,6 +191,9 @@ class InstantPage : public content::WebContentsObserver {
// Tells the page that the omnibox focus has changed.
void FocusChanged(OmniboxFocusState state, OmniboxFocusChangeReason reason);
+ // Tells the page that user input started or stopped.
+ void SetInputInProgress(bool input_in_progress);
+
// Tells the page about new Most Visited data.
void SendMostVisitedItems(
const std::vector<InstantMostVisitedItem>& items);