Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Unified Diff: chrome/browser/ui/search/search_tab_helper.cc

Issue 12631008: alternate ntp: implement Show/HideBars API to reduce jank when showing/hiding bars (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert obsolete changes in search.h/cc Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/search/search_tab_helper.cc
diff --git a/chrome/browser/ui/search/search_tab_helper.cc b/chrome/browser/ui/search/search_tab_helper.cc
index c65d13d7562942f9cfd329061ad72a47aee6bbe0..0dc811f437bc2d6417affc0287a754dee5770590 100644
--- a/chrome/browser/ui/search/search_tab_helper.cc
+++ b/chrome/browser/ui/search/search_tab_helper.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/search/search_tab_helper.h"
#include "chrome/browser/instant/search.h"
+#include "chrome/common/render_messages.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_service.h"
@@ -35,7 +36,8 @@ namespace chrome {
namespace search {
SearchTabHelper::SearchTabHelper(content::WebContents* web_contents)
- : is_search_enabled_(chrome::search::IsInstantExtendedAPIEnabled()),
+ : WebContentsObserver(web_contents),
+ is_search_enabled_(chrome::search::IsInstantExtendedAPIEnabled()),
user_input_in_progress_(false),
web_contents_(web_contents) {
if (!is_search_enabled_)
@@ -60,14 +62,14 @@ void SearchTabHelper::OmniboxEditModelChanged(bool user_input_in_progress,
if (!user_input_in_progress && !cancelling)
return;
- UpdateModel();
+ UpdateModelMode();
dhollowa 2013/03/14 00:30:58 UpdateMode would be fine.
kuan 2013/03/14 00:44:18 Done.
}
void SearchTabHelper::NavigationEntryUpdated() {
if (!is_search_enabled_)
return;
- UpdateModel();
+ UpdateModelMode();
}
void SearchTabHelper::Observe(
@@ -75,10 +77,22 @@ void SearchTabHelper::Observe(
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type);
- UpdateModel();
+ UpdateModelMode();
}
-void SearchTabHelper::UpdateModel() {
+bool SearchTabHelper::OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(SearchTabHelper, message)
+ IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxShowBars,
+ OnSearchBoxShowBars)
+ IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxHideBars,
+ OnSearchBoxHideBars)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void SearchTabHelper::UpdateModelMode() {
Mode::Type type = Mode::MODE_DEFAULT;
Mode::Origin origin = Mode::ORIGIN_DEFAULT;
if (IsNTP(web_contents_)) {
@@ -93,5 +107,17 @@ void SearchTabHelper::UpdateModel() {
model_.SetMode(Mode(type, origin));
}
+void SearchTabHelper::OnSearchBoxShowBars(int page_id) {
+ if (web_contents()->IsActiveEntry(page_id))
+ model_.SetTopBarsVisible(true);
+}
+
+void SearchTabHelper::OnSearchBoxHideBars(int page_id) {
+ if (web_contents()->IsActiveEntry(page_id)) {
+ model_.SetTopBarsVisible(false);
+ Send(new ChromeViewMsg_SearchBoxBarsHidden(routing_id()));
+ }
+}
+
} // namespace search
} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698