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

Unified Diff: chrome/browser/ui/search/search_model.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: rebased, resolved conflicts 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_model.cc
diff --git a/chrome/browser/ui/search/search_model.cc b/chrome/browser/ui/search/search_model.cc
index 74232f32e8579f2b0181d03a1ee4b441c8b47d4c..5b5ab0d493caddeb3e0fc5bef5e93e53e69bdb53 100644
--- a/chrome/browser/ui/search/search_model.cc
+++ b/chrome/browser/ui/search/search_model.cc
@@ -10,7 +10,7 @@
namespace chrome {
namespace search {
-SearchModel::SearchModel() {
+SearchModel::SearchModel() : top_bars_visible_(true) {
}
SearchModel::~SearchModel() {
@@ -27,8 +27,25 @@ void SearchModel::SetMode(const Mode& new_mode) {
const Mode old_mode = mode_;
mode_ = new_mode;
+ // For |SEARCH_SUGGESTIONS| and |SEARCH_RESULTS| modes, SearchBox API will
+ // determine visibility of top bars via SetTopBarsVisible(); for other modes,
+ // top bars are always visible, if available.
+ if (!mode_.is_search())
+ top_bars_visible_ = true;
+
+ FOR_EACH_OBSERVER(SearchModelObserver, observers_,
+ ModelChanged(old_mode, mode_, top_bars_visible_));
+}
+
+void SearchModel::SetTopBarsVisible(bool visible) {
+ DCHECK(IsInstantExtendedAPIEnabled())
+ << "Please do not try to set the SearchModel mode without first "
+ << "checking if Search is enabled.";
+
+ top_bars_visible_ = visible;
dhollowa 2013/03/13 17:21:55 Do an early return if there's no change to the vis
kuan 2013/03/13 22:21:07 Done.
+
dhollowa 2013/03/13 17:21:55 Save off old_state_ here so the receiver can dete
kuan 2013/03/13 22:21:07 Done.
FOR_EACH_OBSERVER(SearchModelObserver, observers_,
- ModeChanged(old_mode, mode_));
+ ModelChanged(mode_, mode_, top_bars_visible_));
}
void SearchModel::AddObserver(SearchModelObserver* observer) {

Powered by Google App Engine
This is Rietveld 408576698