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

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

Issue 1428423002: Remove setVoiceSearchSupported part of EmbeddedSearch SearchBox API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mac fix 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, 27 State(const SearchMode& mode, InstantSupportState instant_support);
28 InstantSupportState instant_support,
29 bool voice_search_supported);
30 28
31 bool operator==(const State& rhs) const; 29 bool operator==(const State& rhs) const;
32 30
33 // The display mode of UI elements such as the toolbar, the tab strip, etc. 31 // The display mode of UI elements such as the toolbar, the tab strip, etc.
34 SearchMode mode; 32 SearchMode mode;
35 33
36 // Does the current page support Instant? 34 // Does the current page support Instant?
37 InstantSupportState instant_support; 35 InstantSupportState instant_support;
38
39 // Does the current page support voice search?
40 bool voice_search_supported;
41 }; 36 };
42 37
43 SearchModel(); 38 SearchModel();
44 ~SearchModel(); 39 ~SearchModel();
45 40
46 // Change the state. Change notifications are sent to observers. 41 // Change the state. Change notifications are sent to observers.
47 void SetState(const State& state); 42 void SetState(const State& state);
48 43
49 // Get the current state. 44 // Get the current state.
50 const State& state() const { return state_; } 45 const State& state() const { return state_; }
51 46
52 // Change the mode. Change notifications are sent to observers. 47 // Change the mode. Change notifications are sent to observers.
53 void SetMode(const SearchMode& mode); 48 void SetMode(const SearchMode& mode);
54 49
55 // Get the active mode. 50 // Get the active mode.
56 const SearchMode& mode() const { return state_.mode; } 51 const SearchMode& mode() const { return state_.mode; }
57 52
58 // Sets the page instant support state. Change notifications are sent to 53 // Sets the page instant support state. Change notifications are sent to
59 // observers. 54 // observers.
60 void SetInstantSupportState(InstantSupportState instant_support); 55 void SetInstantSupportState(InstantSupportState instant_support);
61 56
62 // Gets the instant support state of the page. 57 // Gets the instant support state of the page.
63 InstantSupportState instant_support() const { 58 InstantSupportState instant_support() const {
64 return state_.instant_support; 59 return state_.instant_support;
65 } 60 }
66 61
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
74 // Add and remove observers. 62 // Add and remove observers.
75 void AddObserver(SearchModelObserver* observer); 63 void AddObserver(SearchModelObserver* observer);
76 void RemoveObserver(SearchModelObserver* observer); 64 void RemoveObserver(SearchModelObserver* observer);
77 65
78 private: 66 private:
79 // Current state of model. 67 // Current state of model.
80 State state_; 68 State state_;
81 69
82 // Observers. 70 // Observers.
83 base::ObserverList<SearchModelObserver> observers_; 71 base::ObserverList<SearchModelObserver> observers_;
84 72
85 DISALLOW_COPY_AND_ASSIGN(SearchModel); 73 DISALLOW_COPY_AND_ASSIGN(SearchModel);
86 }; 74 };
87 75
88 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_ 76 #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