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

Side by Side Diff: chrome/browser/ui/search/search_model.h

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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_ 5 #ifndef CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_
6 #define CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_ 6 #define CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/observer_list.h" 9 #include "base/observer_list.h"
10 #include "chrome/common/search_types.h" 10 #include "chrome/common/search_types.h"
11 11
12 namespace chrome { 12 namespace chrome {
13 namespace search { 13 namespace search {
14 14
15 class SearchModelObserver; 15 class SearchModelObserver;
16 16
17 // An observable model for UI components that care about search model state 17 // An observable model for UI components that care about search model state
18 // changes. 18 // changes.
19 class SearchModel { 19 class SearchModel {
20 public: 20 public:
21 struct State {
22 State() : top_bars_visible(true) {}
23
24 bool operator==(const State& rhs) const {
25 return mode == rhs.mode && top_bars_visible == rhs.top_bars_visible;
26 }
27
28 // The display mode of UI elements such as the toolbar, the tab strip, etc.
29 Mode mode;
30 // The visibility of top bars (bookmark and info bars).
dhollowa 2013/03/14 00:30:58 nit: Match comment style: "The visibility of top b
kuan 2013/03/14 00:44:18 Done.
31 bool top_bars_visible;
32 };
33
21 SearchModel(); 34 SearchModel();
22 ~SearchModel(); 35 ~SearchModel();
23 36
24 // Change the mode. Change notifications are sent to observers. An animated 37 // Change the state. Change notifications are sent to observers.
25 // transition may be requested. 38 void SetState(const State& state);
39
40 // Get the current state.
41 const State& state() const { return state_; }
42
43 // Change the mode. Change notifications are sent to observers.
26 void SetMode(const Mode& mode); 44 void SetMode(const Mode& mode);
27 45
28 // Get the active mode. 46 // Get the active mode.
29 const Mode& mode() const { return mode_; } 47 const Mode& mode() const { return state_.mode; }
48
49 // Set visibility of top bars (bookmark and info bars). Notifications are
dhollowa 2013/03/14 00:30:58 You can remove the "(bookmark and info bars)" bit
kuan 2013/03/14 00:44:18 Done.
50 // sent to observers.
51 void SetTopBarsVisible(bool visible);
52
53 // Get the visibility of top bars (bookmark and info bars).
dhollowa 2013/03/14 00:30:58 You can remove the "(bookmark and info bars)" bit
kuan 2013/03/14 00:44:18 Done.
54 bool top_bars_visible() const { return state_.top_bars_visible; }
30 55
31 // Add and remove observers. 56 // Add and remove observers.
32 void AddObserver(SearchModelObserver* observer); 57 void AddObserver(SearchModelObserver* observer);
33 void RemoveObserver(SearchModelObserver* observer); 58 void RemoveObserver(SearchModelObserver* observer);
34 59
60 // Returns true if visibility in top bars should be changed based on
61 // |old_mode| and |new_mode|.
dhollowa 2013/03/14 00:30:58 old_state, new_state
kuan 2013/03/14 00:44:18 Done.
62 static bool ShouldChangeTopBarsVisibility(const State& old_state,
dhollowa 2013/03/14 00:30:58 Public static methods go to top of class.
kuan 2013/03/14 00:44:18 Done.
63 const State& new_state);
64
35 private: 65 private:
36 // The display mode of UI elements such as the toolbar, the tab strip, etc. 66 // Current state of model.
37 Mode mode_; 67 State state_;
38 68
39 // Observers. 69 // Observers.
40 ObserverList<SearchModelObserver> observers_; 70 ObserverList<SearchModelObserver> observers_;
41 71
42 DISALLOW_COPY_AND_ASSIGN(SearchModel); 72 DISALLOW_COPY_AND_ASSIGN(SearchModel);
43 }; 73 };
44 74
45 } // namespace search 75 } // namespace search
46 } // namespace chrome 76 } // namespace chrome
47 77
48 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_ 78 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698