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

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

Issue 1436583002: Revert of Remove setVoiceSearchSupported part of EmbeddedSearch SearchBox API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
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. 14 // Represents whether a page supports Instant.
15 enum InstantSupportState { 15 enum InstantSupportState {
16 INSTANT_SUPPORT_NO, 16 INSTANT_SUPPORT_NO,
17 INSTANT_SUPPORT_YES, 17 INSTANT_SUPPORT_YES,
18 INSTANT_SUPPORT_UNKNOWN, 18 INSTANT_SUPPORT_UNKNOWN,
19 }; 19 };
20 20
21 // 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
22 // changes. 22 // changes.
23 class SearchModel { 23 class SearchModel {
24 public: 24 public:
25 struct State { 25 struct State {
26 State(); 26 State();
27 State(const SearchMode& mode, InstantSupportState instant_support); 27 State(const SearchMode& mode,
28 InstantSupportState instant_support,
29 bool voice_search_supported);
28 30
29 bool operator==(const State& rhs) const; 31 bool operator==(const State& rhs) const;
30 32
31 // The display mode of UI elements such as the toolbar, the tab strip, etc. 33 // The display mode of UI elements such as the toolbar, the tab strip, etc.
32 SearchMode mode; 34 SearchMode mode;
33 35
34 // Does the current page support Instant? 36 // Does the current page support Instant?
35 InstantSupportState instant_support; 37 InstantSupportState instant_support;
38
39 // Does the current page support voice search?
40 bool voice_search_supported;
36 }; 41 };
37 42
38 SearchModel(); 43 SearchModel();
39 ~SearchModel(); 44 ~SearchModel();
40 45
41 // Change the state. Change notifications are sent to observers. 46 // Change the state. Change notifications are sent to observers.
42 void SetState(const State& state); 47 void SetState(const State& state);
43 48
44 // Get the current state. 49 // Get the current state.
45 const State& state() const { return state_; } 50 const State& state() const { return state_; }
46 51
47 // Change the mode. Change notifications are sent to observers. 52 // Change the mode. Change notifications are sent to observers.
48 void SetMode(const SearchMode& mode); 53 void SetMode(const SearchMode& mode);
49 54
50 // Get the active mode. 55 // Get the active mode.
51 const SearchMode& mode() const { return state_.mode; } 56 const SearchMode& mode() const { return state_.mode; }
52 57
53 // Sets the page instant support state. Change notifications are sent to 58 // Sets the page instant support state. Change notifications are sent to
54 // observers. 59 // observers.
55 void SetInstantSupportState(InstantSupportState instant_support); 60 void SetInstantSupportState(InstantSupportState instant_support);
56 61
57 // Gets the instant support state of the page. 62 // Gets the instant support state of the page.
58 InstantSupportState instant_support() const { 63 InstantSupportState instant_support() const {
59 return state_.instant_support; 64 return state_.instant_support;
60 } 65 }
61 66
67 // Sets the page voice search support state. Change notifications are sent to
68 // observers.
69 void SetVoiceSearchSupported(bool supported);
70
71 // Gets the voice search support state of the page.
72 bool voice_search_supported() const { return state_.voice_search_supported; }
73
62 // Add and remove observers. 74 // Add and remove observers.
63 void AddObserver(SearchModelObserver* observer); 75 void AddObserver(SearchModelObserver* observer);
64 void RemoveObserver(SearchModelObserver* observer); 76 void RemoveObserver(SearchModelObserver* observer);
65 77
66 private: 78 private:
67 // Current state of model. 79 // Current state of model.
68 State state_; 80 State state_;
69 81
70 // Observers. 82 // Observers.
71 base::ObserverList<SearchModelObserver> observers_; 83 base::ObserverList<SearchModelObserver> observers_;
72 84
73 DISALLOW_COPY_AND_ASSIGN(SearchModel); 85 DISALLOW_COPY_AND_ASSIGN(SearchModel);
74 }; 86 };
75 87
76 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_ 88 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/search_ipc_router_unittest.cc ('k') | chrome/browser/ui/search/search_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698