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

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

Issue 2885853002: Instant: remove InstantSupportState (Closed)
Patch Set: Created 3 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
« no previous file with comments | « chrome/browser/ui/search/search_delegate.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/macros.h" 8 #include "base/macros.h"
9 #include "base/observer_list.h" 9 #include "base/observer_list.h"
10 #include "chrome/common/search/search_types.h" 10 #include "chrome/common/search/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 };
19
20 // An observable model for UI components that care about search model state 14 // An observable model for UI components that care about search model state
21 // changes. 15 // changes.
22 class SearchModel { 16 class SearchModel {
23 public: 17 public:
24 struct State {
25 State();
26 State(const SearchMode& mode, InstantSupportState instant_support);
27
28 bool operator==(const State& rhs) const;
29
30 // The display mode of UI elements such as the toolbar, the tab strip, etc.
31 SearchMode mode;
32
33 // Does the current page support Instant?
34 InstantSupportState instant_support;
35 };
36
37 SearchModel(); 18 SearchModel();
38 ~SearchModel(); 19 ~SearchModel();
39 20
40 // Change the state. Change notifications are sent to observers.
41 void SetState(const State& state);
42
43 // Get the current state.
44 const State& state() const { return state_; }
45
46 // Change the mode. Change notifications are sent to observers. 21 // Change the mode. Change notifications are sent to observers.
47 void SetMode(const SearchMode& mode); 22 void SetMode(const SearchMode& mode);
48 23
49 // Get the active mode. 24 // Get the active mode.
50 const SearchMode& mode() const { return state_.mode; } 25 const SearchMode& mode() const { return mode_; }
51
52 // Sets the page instant support state. Change notifications are sent to
53 // observers.
54 void SetInstantSupportState(InstantSupportState instant_support);
55
56 // Gets the instant support state of the page.
57 InstantSupportState instant_support() const {
58 return state_.instant_support;
59 }
60 26
61 // Add and remove observers. 27 // Add and remove observers.
62 void AddObserver(SearchModelObserver* observer); 28 void AddObserver(SearchModelObserver* observer);
63 void RemoveObserver(SearchModelObserver* observer); 29 void RemoveObserver(SearchModelObserver* observer);
64 30
65 private: 31 private:
66 // Current state of model. 32 // Current state of model.
67 State state_; 33 SearchMode mode_;
68 34
69 // Observers. 35 // Observers.
70 base::ObserverList<SearchModelObserver> observers_; 36 base::ObserverList<SearchModelObserver> observers_;
71 37
72 DISALLOW_COPY_AND_ASSIGN(SearchModel); 38 DISALLOW_COPY_AND_ASSIGN(SearchModel);
73 }; 39 };
74 40
75 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_ 41 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/search_delegate.cc ('k') | chrome/browser/ui/search/search_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698