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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_
6 #define CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_
8 #include "base/basictypes.h"
9 #include "base/observer_list.h"
10 #include "chrome/common/search_types.h"
12 class SearchModelObserver
;
14 // Represents whether a page supports Instant.
15 enum InstantSupportState
{
18 INSTANT_SUPPORT_UNKNOWN
,
21 // An observable model for UI components that care about search model state
27 State(const SearchMode
& mode
,
28 InstantSupportState instant_support
,
29 bool voice_search_supported
);
31 bool operator==(const State
& rhs
) const;
33 // The display mode of UI elements such as the toolbar, the tab strip, etc.
36 // Does the current page support Instant?
37 InstantSupportState instant_support
;
39 // Does the current page support voice search?
40 bool voice_search_supported
;
46 // Change the state. Change notifications are sent to observers.
47 void SetState(const State
& state
);
49 // Get the current state.
50 const State
& state() const { return state_
; }
52 // Change the mode. Change notifications are sent to observers.
53 void SetMode(const SearchMode
& mode
);
55 // Get the active mode.
56 const SearchMode
& mode() const { return state_
.mode
; }
58 // Sets the page instant support state. Change notifications are sent to
60 void SetInstantSupportState(InstantSupportState instant_support
);
62 // Gets the instant support state of the page.
63 InstantSupportState
instant_support() const {
64 return state_
.instant_support
;
67 // Sets the page voice search support state. Change notifications are sent to
69 void SetVoiceSearchSupported(bool supported
);
71 // Gets the voice search support state of the page.
72 bool voice_search_supported() const { return state_
.voice_search_supported
; }
74 // Add and remove observers.
75 void AddObserver(SearchModelObserver
* observer
);
76 void RemoveObserver(SearchModelObserver
* observer
);
79 // Current state of model.
83 ObserverList
<SearchModelObserver
> observers_
;
85 DISALLOW_COPY_AND_ASSIGN(SearchModel
);
88 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_