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

Side by Side Diff: ui/app_list/search_box_model.cc

Issue 2422873002: Remove usage of FOR_EACH_OBSERVER macro in ui/app_list (Closed)
Patch Set: Created 4 years, 2 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 | « ui/app_list/search/history_data.cc ('k') | ui/app_list/search_result.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 #include "ui/app_list/search_box_model.h" 5 #include "ui/app_list/search_box_model.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "ui/app_list/search_box_model_observer.h" 10 #include "ui/app_list/search_box_model_observer.h"
(...skipping 18 matching lines...) Expand all
29 29
30 SearchBoxModel::SearchBoxModel() { 30 SearchBoxModel::SearchBoxModel() {
31 } 31 }
32 32
33 SearchBoxModel::~SearchBoxModel() { 33 SearchBoxModel::~SearchBoxModel() {
34 } 34 }
35 35
36 void SearchBoxModel::SetSpeechRecognitionButton( 36 void SearchBoxModel::SetSpeechRecognitionButton(
37 std::unique_ptr<SearchBoxModel::SpeechButtonProperty> speech_button) { 37 std::unique_ptr<SearchBoxModel::SpeechButtonProperty> speech_button) {
38 speech_button_ = std::move(speech_button); 38 speech_button_ = std::move(speech_button);
39 FOR_EACH_OBSERVER(SearchBoxModelObserver, 39 for (auto& observer : observers_)
40 observers_, 40 observer.SpeechRecognitionButtonPropChanged();
41 SpeechRecognitionButtonPropChanged());
42 } 41 }
43 42
44 void SearchBoxModel::SetHintText(const base::string16& hint_text) { 43 void SearchBoxModel::SetHintText(const base::string16& hint_text) {
45 if (hint_text_ == hint_text) 44 if (hint_text_ == hint_text)
46 return; 45 return;
47 46
48 hint_text_ = hint_text; 47 hint_text_ = hint_text;
49 FOR_EACH_OBSERVER(SearchBoxModelObserver, observers_, HintTextChanged()); 48 for (auto& observer : observers_)
49 observer.HintTextChanged();
50 } 50 }
51 51
52 void SearchBoxModel::SetAccessibleName(const base::string16& accessible_name) { 52 void SearchBoxModel::SetAccessibleName(const base::string16& accessible_name) {
53 if (accessible_name_ == accessible_name) 53 if (accessible_name_ == accessible_name)
54 return; 54 return;
55 55
56 accessible_name_ = accessible_name; 56 accessible_name_ = accessible_name;
57 FOR_EACH_OBSERVER(SearchBoxModelObserver, observers_, HintTextChanged()); 57 for (auto& observer : observers_)
58 observer.HintTextChanged();
58 } 59 }
59 60
60 void SearchBoxModel::SetSelectionModel(const gfx::SelectionModel& sel) { 61 void SearchBoxModel::SetSelectionModel(const gfx::SelectionModel& sel) {
61 if (selection_model_ == sel) 62 if (selection_model_ == sel)
62 return; 63 return;
63 64
64 selection_model_ = sel; 65 selection_model_ = sel;
65 FOR_EACH_OBSERVER(SearchBoxModelObserver, 66 for (auto& observer : observers_)
66 observers_, 67 observer.SelectionModelChanged();
67 SelectionModelChanged());
68 } 68 }
69 69
70 void SearchBoxModel::SetText(const base::string16& text) { 70 void SearchBoxModel::SetText(const base::string16& text) {
71 if (text_ == text) 71 if (text_ == text)
72 return; 72 return;
73 73
74 // Log that a new search has been commenced whenever the text box text 74 // Log that a new search has been commenced whenever the text box text
75 // transitions from empty to non-empty. 75 // transitions from empty to non-empty.
76 if (text_.empty() && !text.empty()) { 76 if (text_.empty() && !text.empty()) {
77 UMA_HISTOGRAM_ENUMERATION("Apps.AppListSearchCommenced", 1, 2); 77 UMA_HISTOGRAM_ENUMERATION("Apps.AppListSearchCommenced", 1, 2);
78 } 78 }
79 text_ = text; 79 text_ = text;
80 FOR_EACH_OBSERVER(SearchBoxModelObserver, observers_, TextChanged()); 80 for (auto& observer : observers_)
81 observer.TextChanged();
81 } 82 }
82 83
83 void SearchBoxModel::AddObserver(SearchBoxModelObserver* observer) { 84 void SearchBoxModel::AddObserver(SearchBoxModelObserver* observer) {
84 observers_.AddObserver(observer); 85 observers_.AddObserver(observer);
85 } 86 }
86 87
87 void SearchBoxModel::RemoveObserver(SearchBoxModelObserver* observer) { 88 void SearchBoxModel::RemoveObserver(SearchBoxModelObserver* observer) {
88 observers_.RemoveObserver(observer); 89 observers_.RemoveObserver(observer);
89 } 90 }
90 91
91 } // namespace app_list 92 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/search/history_data.cc ('k') | ui/app_list/search_result.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698