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

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

Issue 17132011: Add setVoiceSearchSupported to the searchbox API. This will be used to determine whether to show a … (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Rebase past 16035020, add test. Created 7 years, 6 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 | « no previous file | 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. 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,
28 bool top_bars_visible, 28 bool top_bars_visible,
29 InstantSupportState instant_support); 29 InstantSupportState instant_support,
30 bool voice_search_supported);
30 31
31 bool operator==(const State& rhs) const; 32 bool operator==(const State& rhs) const;
32 33
33 // The display mode of UI elements such as the toolbar, the tab strip, etc. 34 // The display mode of UI elements such as the toolbar, the tab strip, etc.
34 SearchMode mode; 35 SearchMode mode;
35 36
36 // The visibility of top bars such as bookmark and info bars. 37 // The visibility of top bars such as bookmark and info bars.
37 bool top_bars_visible; 38 bool top_bars_visible;
38 39
39 // Does the current page support Instant? 40 // Does the current page support Instant?
40 InstantSupportState instant_support; 41 InstantSupportState instant_support;
42
43 // Does the current page support voice search?
44 bool voice_search_supported;
41 }; 45 };
42 46
43 SearchModel(); 47 SearchModel();
44 ~SearchModel(); 48 ~SearchModel();
45 49
46 // Returns true if visibility in top bars should be changed based on 50 // Returns true if visibility in top bars should be changed based on
47 // |old_state| and |new_state|. 51 // |old_state| and |new_state|.
48 static bool ShouldChangeTopBarsVisibility(const State& old_state, 52 static bool ShouldChangeTopBarsVisibility(const State& old_state,
49 const State& new_state); 53 const State& new_state);
50 54
(...skipping 17 matching lines...) Expand all
68 72
69 // Sets the page instant support state. Change notifications are sent to 73 // Sets the page instant support state. Change notifications are sent to
70 // observers. 74 // observers.
71 void SetInstantSupportState(InstantSupportState instant_support); 75 void SetInstantSupportState(InstantSupportState instant_support);
72 76
73 // Gets the instant support state of the page. 77 // Gets the instant support state of the page.
74 InstantSupportState instant_support() const { 78 InstantSupportState instant_support() const {
75 return state_.instant_support; 79 return state_.instant_support;
76 } 80 }
77 81
82 // Sets the page voice search support state. Change notifications are sent to
83 // observers.
84 void SetVoiceSearchSupported(bool supported);
85
86 // Gets the voice search support state of the page.
87 bool voice_search_supported() const { return state_.voice_search_supported; }
88
78 // Add and remove observers. 89 // Add and remove observers.
79 void AddObserver(SearchModelObserver* observer); 90 void AddObserver(SearchModelObserver* observer);
80 void RemoveObserver(SearchModelObserver* observer); 91 void RemoveObserver(SearchModelObserver* observer);
81 92
82 private: 93 private:
83 // Current state of model. 94 // Current state of model.
84 State state_; 95 State state_;
85 96
86 // Observers. 97 // Observers.
87 ObserverList<SearchModelObserver> observers_; 98 ObserverList<SearchModelObserver> observers_;
88 99
89 DISALLOW_COPY_AND_ASSIGN(SearchModel); 100 DISALLOW_COPY_AND_ASSIGN(SearchModel);
90 }; 101 };
91 102
92 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_ 103 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/search/search_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698