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

Unified Diff: ui/app_list/views/search_box_view.cc

Issue 22354002: Remove SetModel in ContentsView and SearchBoxView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove AppListModel stuff from SearchBoxView Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/views/search_box_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/views/search_box_view.cc
diff --git a/ui/app_list/views/search_box_view.cc b/ui/app_list/views/search_box_view.cc
index 73a04a60ac294bef55569be699f5c86ce75d871f..12d166ac32d7c6dcce2cbec72fba36e71637b370 100644
--- a/ui/app_list/views/search_box_view.cc
+++ b/ui/app_list/views/search_box_view.cc
@@ -7,6 +7,7 @@
#include <algorithm>
#include "grit/ui_resources.h"
+#include "ui/app_list/app_list_model.h"
#include "ui/app_list/search_box_model.h"
#include "ui/app_list/search_box_view_delegate.h"
#include "ui/app_list/views/app_list_menu_views.h"
@@ -31,13 +32,15 @@ const SkColor kHintTextColor = SkColorSetRGB(0xA0, 0xA0, 0xA0);
} // namespace
SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate,
- AppListViewDelegate* view_delegate)
+ AppListViewDelegate* view_delegate,
+ AppListModel* model)
: delegate_(delegate),
view_delegate_(view_delegate),
- model_(NULL),
+ model_(model->search_box()),
icon_view_(new views::ImageView),
search_box_(new views::Textfield),
contents_view_(NULL) {
+ DCHECK(model_);
AddChildView(icon_view_);
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
@@ -57,26 +60,14 @@ SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate,
search_box_->set_placeholder_text_color(kHintTextColor);
search_box_->SetController(this);
AddChildView(search_box_);
-}
-SearchBoxView::~SearchBoxView() {
- if (model_)
- model_->RemoveObserver(this);
+ model_->AddObserver(this);
+ IconChanged();
+ HintTextChanged();
}
-void SearchBoxView::SetModel(SearchBoxModel* model) {
- if (model_ == model)
- return;
-
- if (model_)
- model_->RemoveObserver(this);
-
- model_ = model;
- if (model_) {
- model_->AddObserver(this);
- IconChanged();
- HintTextChanged();
- }
+SearchBoxView::~SearchBoxView() {
+ model_->RemoveObserver(this);
}
bool SearchBoxView::HasSearch() const {
« no previous file with comments | « ui/app_list/views/search_box_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698