diff options
author | abodenha@chromium.org <abodenha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-27 21:57:52 +0000 |
---|---|---|
committer | abodenha@chromium.org <abodenha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-27 21:57:52 +0000 |
commit | fb2a69925e923421fd245a403bb5689d6e7901f9 (patch) | |
tree | a109e213b2830fba16a531c97d660c047649b81a | |
parent | 60adec0ee3ad56b8e80066bdadca0337feeafb4a (diff) | |
download | chromium_src-fb2a69925e923421fd245a403bb5689d6e7901f9.zip chromium_src-fb2a69925e923421fd245a403bb5689d6e7901f9.tar.gz chromium_src-fb2a69925e923421fd245a403bb5689d6e7901f9.tar.bz2 |
Revert 185031
The most likely culprit for http://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Tests%20%28dbg%29%283%29/builds/21131
> Commit full-height overlay on show if the omnibox is not focused. This replaces explicit committing when clicking a query suggestion.
>
>
> BUG=175160
>
>
> Review URL: https://chromiumcodereview.appspot.com/12225159
TBR=melevin@chromium.org
Review URL: https://codereview.chromium.org/12328157
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185050 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/instant/instant_commit_type.h | 3 | ||||
-rw-r--r-- | chrome/browser/instant/instant_controller.cc | 22 | ||||
-rw-r--r-- | chrome/browser/instant/instant_controller.h | 2 | ||||
-rw-r--r-- | chrome/browser/instant/instant_extended_browsertest.cc | 74 |
4 files changed, 16 insertions, 85 deletions
diff --git a/chrome/browser/instant/instant_commit_type.h b/chrome/browser/instant/instant_commit_type.h index 7da72a5..c7c7da6 100644 --- a/chrome/browser/instant/instant_commit_type.h +++ b/chrome/browser/instant/instant_commit_type.h @@ -20,6 +20,9 @@ enum InstantCommitType { // The commit is due to the Instant overlay navigating to a non-Instant URL. INSTANT_COMMIT_NAVIGATED, + + // The commit is due to the user clicking on a query suggestion. + INSTANT_COMMIT_CLICKED_QUERY_SUGGESTION, }; #endif // CHROME_BROWSER_INSTANT_INSTANT_COMMIT_TYPE_H_ diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc index 189753c..9725d5e 100644 --- a/chrome/browser/instant/instant_controller.cc +++ b/chrome/browser/instant/instant_controller.cc @@ -603,7 +603,8 @@ bool InstantController::CommitIfPossible(InstantCommitType type) { if (type == INSTANT_COMMIT_FOCUS_LOST) overlay_->Cancel(last_omnibox_text_); - else if (type != INSTANT_COMMIT_NAVIGATED) + else if (type != INSTANT_COMMIT_NAVIGATED && + type != INSTANT_COMMIT_CLICKED_QUERY_SUGGESTION) overlay_->Submit(last_omnibox_text_); scoped_ptr<content::WebContents> preview = overlay_->ReleaseContents(); @@ -1157,10 +1158,10 @@ void InstantController::OmniboxLostFocus(gfx::NativeView view_gaining_focus) { if (!overlay_->is_pointer_down_from_activate()) HideOverlay(); #else - if (IsFullHeight(model_)) + if (IsViewInContents(GetViewGainingFocus(view_gaining_focus), + overlay_->contents())) CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST); - else if (!IsViewInContents(GetViewGainingFocus(view_gaining_focus), - overlay_->contents())) + else HideOverlay(); #endif } @@ -1284,7 +1285,8 @@ void InstantController::ShowOverlay(InstantShownReason reason, return; // Must have updated omnibox after the last HideOverlay() to show suggestions. - if (reason == INSTANT_SHOWN_QUERY_SUGGESTIONS && + if ((reason == INSTANT_SHOWN_QUERY_SUGGESTIONS || + reason == INSTANT_SHOWN_CLICKED_QUERY_SUGGESTION) && !allow_preview_to_show_search_suggestions_) return; @@ -1315,10 +1317,12 @@ void InstantController::ShowOverlay(InstantShownReason reason, else model_.SetPreviewState(search_mode_, 100, INSTANT_SIZE_PERCENT); - // If the overlay is being shown at full height and the omnibox is not - // focused, commit right away. - if (IsFullHeight(model_) && omnibox_focus_state_ == OMNIBOX_FOCUS_NONE) - CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST); + // If the user clicked on a query suggestion, also go ahead and commit the + // overlay. This is necessary because if the overlay was partially visible + // when the suggestion was clicked, the click itself would not commit the + // overlay (because we're not full height). + if (reason == INSTANT_SHOWN_CLICKED_QUERY_SUGGESTION) + CommitIfPossible(INSTANT_COMMIT_CLICKED_QUERY_SUGGESTION); } void InstantController::SendPopupBoundsToPage() { diff --git a/chrome/browser/instant/instant_controller.h b/chrome/browser/instant/instant_controller.h index ca639f4..def4880 100644 --- a/chrome/browser/instant/instant_controller.h +++ b/chrome/browser/instant/instant_controller.h @@ -204,8 +204,6 @@ class InstantController : public InstantPage::Delegate, FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, PreloadedNTPIsUsedInSameTab); FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, ProcessIsolation); FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, UnrelatedSiteInstance); - FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, - OmniboxCommitsWhenShownFullHeight); // Overridden from content::NotificationObserver: virtual void Observe(int type, diff --git a/chrome/browser/instant/instant_extended_browsertest.cc b/chrome/browser/instant/instant_extended_browsertest.cc index 9372fce..f0fc514 100644 --- a/chrome/browser/instant/instant_extended_browsertest.cc +++ b/chrome/browser/instant/instant_extended_browsertest.cc @@ -718,77 +718,3 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, MostVisited) { // Make sure we have the same number of items as before. EXPECT_EQ(most_visited_items_count_, old_most_visited_items_count); } - -// Commit does not happen on Mac: http://crbug.com/178520 -#if defined(OS_MACOSX) -#define MAYBE_CommitWhenFocusLostInFullHeight \ - DISABLED_CommitWhenFocusLostInFullHeight -#else -#define MAYBE_CommitWhenFocusLostInFullHeight CommitWhenFocusLostInFullHeight -#endif -// Test that the preview is committed when the omnibox loses focus when it is -// shown at 100% height. -IN_PROC_BROWSER_TEST_F(InstantExtendedTest, - MAYBE_CommitWhenFocusLostInFullHeight) { - ASSERT_NO_FATAL_FAILURE(SetupInstant()); - - // Focus omnibox and confirm overlay isn't shown. - FocusOmniboxAndWaitForInstantSupport(); - content::WebContents* preview_tab = instant()->GetPreviewContents(); - EXPECT_TRUE(preview_tab); - EXPECT_TRUE(instant()->model()->mode().is_default()); - EXPECT_FALSE(instant()->IsPreviewingSearchResults()); - - // Typing in the omnibox should show the overlay. - SetOmniboxTextAndWaitForInstantToShow("query"); - EXPECT_TRUE(instant()->IsPreviewingSearchResults()); - EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); - - // Explicitly unfocus the omnibox without triggering a click. Note that this - // doesn't actually change the focus state of the omnibox, only what the - // Instant controller sees it as. - omnibox()->model()->OnWillKillFocus(NULL); - omnibox()->model()->OnKillFocus(); - - // Confirm that the overlay has been committed. - content::WebContents* active_tab = - browser()->tab_strip_model()->GetActiveWebContents(); - EXPECT_EQ(preview_tab, active_tab); -} - -// Test that the preview is committed when shown at 100% height without focus -// in the omnibox. -IN_PROC_BROWSER_TEST_F(InstantExtendedTest, - CommitWhenShownInFullHeightWithoutFocus) { - ASSERT_NO_FATAL_FAILURE(SetupInstant()); - - // Focus omnibox and confirm overlay isn't shown. - FocusOmniboxAndWaitForInstantSupport(); - content::WebContents* preview_tab = instant()->GetPreviewContents(); - EXPECT_TRUE(preview_tab); - EXPECT_TRUE(instant()->model()->mode().is_default()); - EXPECT_FALSE(instant()->IsPreviewingSearchResults()); - - // Create an observer to wait for the commit. - content::WindowedNotificationObserver observer( - chrome::NOTIFICATION_INSTANT_COMMITTED, - content::NotificationService::AllSources()); - - // Typing in the omnibox should show the overlay. Don't wait for the overlay - // to show however. - SetOmniboxText("query"); - - // Explicitly unfocus the omnibox without triggering a click. Note that this - // doesn't actually change the focus state of the omnibox, only what the - // Instant controller sees it as. - omnibox()->model()->OnWillKillFocus(NULL); - omnibox()->model()->OnKillFocus(); - - // Wait for the overlay to show. - observer.Wait(); - - // Confirm that the overlay has been committed. - content::WebContents* active_tab = - browser()->tab_strip_model()->GetActiveWebContents(); - EXPECT_EQ(preview_tab, active_tab); -} |