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

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

Issue 14608004: Move instant support to SearchTabHelper. Fix InstantTab reset. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Guard instant-extended-only bits. Created 7 years, 7 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
« no previous file with comments | « chrome/browser/ui/search/instant_tab.cc ('k') | chrome/browser/ui/search/search_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 class SearchModelObserver; 12 class SearchModelObserver;
13 13
14 // Represents whether a page supports Instant.
15 enum InstantSupportState {
16 INSTANT_SUPPORT_NO,
17 INSTANT_SUPPORT_YES,
18 INSTANT_SUPPORT_UNKNOWN,
19 };
20
14 // An observable model for UI components that care about search model state 21 // An observable model for UI components that care about search model state
15 // changes. 22 // changes.
16 class SearchModel { 23 class SearchModel {
17 public: 24 public:
18 struct State { 25 struct State {
19 State() : top_bars_visible(true) {} 26 State()
27 : top_bars_visible(true),
28 instant_support(INSTANT_SUPPORT_UNKNOWN) {}
20 29
21 bool operator==(const State& rhs) const { 30 bool operator==(const State& rhs) const {
22 return mode == rhs.mode && top_bars_visible == rhs.top_bars_visible; 31 return mode == rhs.mode && top_bars_visible == rhs.top_bars_visible &&
32 instant_support == rhs.instant_support;
23 } 33 }
24 34
25 // The display mode of UI elements such as the toolbar, the tab strip, etc. 35 // The display mode of UI elements such as the toolbar, the tab strip, etc.
26 SearchMode mode; 36 SearchMode mode;
27 37
28 // The visibility of top bars such as bookmark and info bars. 38 // The visibility of top bars such as bookmark and info bars.
29 bool top_bars_visible; 39 bool top_bars_visible;
40
41 // Does the current page support Instant?
42 InstantSupportState instant_support;
30 }; 43 };
31 44
32 SearchModel(); 45 SearchModel();
33 ~SearchModel(); 46 ~SearchModel();
34 47
35 // Returns true if visibility in top bars should be changed based on 48 // Returns true if visibility in top bars should be changed based on
36 // |old_state| and |new_state|. 49 // |old_state| and |new_state|.
37 static bool ShouldChangeTopBarsVisibility(const State& old_state, 50 static bool ShouldChangeTopBarsVisibility(const State& old_state,
38 const State& new_state); 51 const State& new_state);
39 52
40 // Change the state. Change notifications are sent to observers. 53 // Change the state. Change notifications are sent to observers.
41 void SetState(const State& state); 54 void SetState(const State& state);
42 55
43 // Get the current state. 56 // Get the current state.
44 const State& state() const { return state_; } 57 const State& state() const { return state_; }
45 58
46 // Change the mode. Change notifications are sent to observers. 59 // Change the mode. Change notifications are sent to observers.
47 void SetMode(const SearchMode& mode); 60 void SetMode(const SearchMode& mode);
48 61
49 // Get the active mode. 62 // Get the active mode.
50 const SearchMode& mode() const { return state_.mode; } 63 const SearchMode& mode() const { return state_.mode; }
51 64
52 // Set visibility of top bars. Change notifications are sent to observers. 65 // Set visibility of top bars. Change notifications are sent to observers.
53 void SetTopBarsVisible(bool visible); 66 void SetTopBarsVisible(bool visible);
54 67
55 // Get the visibility of top bars. 68 // Get the visibility of top bars.
56 bool top_bars_visible() const { return state_.top_bars_visible; } 69 bool top_bars_visible() const { return state_.top_bars_visible; }
57 70
71 // Set whether the page supporst Instant. Change notifications are sent to
72 // observers.
73 void SetSupportsInstant(bool supports_instant);
74
75 // Get whether the page supports Instant.
76 InstantSupportState instant_support() const {
77 return state_.instant_support;
78 }
79
58 // Add and remove observers. 80 // Add and remove observers.
59 void AddObserver(SearchModelObserver* observer); 81 void AddObserver(SearchModelObserver* observer);
60 void RemoveObserver(SearchModelObserver* observer); 82 void RemoveObserver(SearchModelObserver* observer);
61 83
62 private: 84 private:
63 // Current state of model. 85 // Current state of model.
64 State state_; 86 State state_;
65 87
66 // Observers. 88 // Observers.
67 ObserverList<SearchModelObserver> observers_; 89 ObserverList<SearchModelObserver> observers_;
68 90
69 DISALLOW_COPY_AND_ASSIGN(SearchModel); 91 DISALLOW_COPY_AND_ASSIGN(SearchModel);
70 }; 92 };
71 93
72 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_ 94 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/instant_tab.cc ('k') | chrome/browser/ui/search/search_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698