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

Side by Side Diff: ui/app_list/views/app_list_main_view.cc

Issue 185623002: Add Hide and Show to the app list SearchBoxView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ares_contents_switcher
Patch Set: Created 6 years, 9 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/views/app_list_main_view.h" 5 #include "ui/app_list/views/app_list_main_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "ui/app_list/app_list_constants.h" 14 #include "ui/app_list/app_list_constants.h"
15 #include "ui/app_list/app_list_folder_item.h" 15 #include "ui/app_list/app_list_folder_item.h"
16 #include "ui/app_list/app_list_item.h" 16 #include "ui/app_list/app_list_item.h"
17 #include "ui/app_list/app_list_model.h" 17 #include "ui/app_list/app_list_model.h"
18 #include "ui/app_list/app_list_switches.h" 18 #include "ui/app_list/app_list_switches.h"
19 #include "ui/app_list/app_list_view_delegate.h" 19 #include "ui/app_list/app_list_view_delegate.h"
20 #include "ui/app_list/pagination_model.h" 20 #include "ui/app_list/pagination_model.h"
21 #include "ui/app_list/search_box_model.h" 21 #include "ui/app_list/search_box_model.h"
22 #include "ui/app_list/views/app_list_item_view.h" 22 #include "ui/app_list/views/app_list_item_view.h"
23 #include "ui/app_list/views/app_list_view.h"
23 #include "ui/app_list/views/contents_switcher_view.h" 24 #include "ui/app_list/views/contents_switcher_view.h"
24 #include "ui/app_list/views/contents_view.h" 25 #include "ui/app_list/views/contents_view.h"
25 #include "ui/app_list/views/search_box_view.h" 26 #include "ui/app_list/views/search_box_view.h"
26 #include "ui/views/controls/textfield/textfield.h" 27 #include "ui/views/controls/textfield/textfield.h"
27 #include "ui/views/layout/box_layout.h" 28 #include "ui/views/layout/box_layout.h"
28 #include "ui/views/widget/widget.h" 29 #include "ui/views/widget/widget.h"
29 30
30 namespace app_list { 31 namespace app_list {
31 32
32 namespace { 33 namespace {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 73
73 AppListMainView* owner_; 74 AppListMainView* owner_;
74 AppListItem* item_; 75 AppListItem* item_;
75 76
76 DISALLOW_COPY_AND_ASSIGN(IconLoader); 77 DISALLOW_COPY_AND_ASSIGN(IconLoader);
77 }; 78 };
78 79
79 //////////////////////////////////////////////////////////////////////////////// 80 ////////////////////////////////////////////////////////////////////////////////
80 // AppListMainView: 81 // AppListMainView:
81 82
82 AppListMainView::AppListMainView(AppListViewDelegate* delegate, 83 AppListMainView::AppListMainView(AppListView* app_list_view,
84 AppListViewDelegate* delegate,
83 PaginationModel* pagination_model, 85 PaginationModel* pagination_model,
84 gfx::NativeView parent) 86 gfx::NativeView parent)
85 : delegate_(delegate), 87 : delegate_(delegate),
86 pagination_model_(pagination_model), 88 pagination_model_(pagination_model),
87 model_(delegate->GetModel()), 89 model_(delegate->GetModel()),
90 app_list_view_(app_list_view),
88 search_box_view_(NULL), 91 search_box_view_(NULL),
89 contents_view_(NULL), 92 contents_view_(NULL),
90 weak_ptr_factory_(this) { 93 weak_ptr_factory_(this) {
91 // Starts icon loading early. 94 // Starts icon loading early.
92 PreloadIcons(parent); 95 PreloadIcons(parent);
93 96
94 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 97 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical,
95 kInnerPadding, 98 kInnerPadding,
96 kInnerPadding, 99 kInnerPadding,
97 kInnerPadding)); 100 kInnerPadding));
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 TrimWhitespace(model_->search_box()->text(), TRIM_ALL, &query); 226 TrimWhitespace(model_->search_box()->text(), TRIM_ALL, &query);
224 bool should_show_search = !query.empty(); 227 bool should_show_search = !query.empty();
225 contents_view_->ShowSearchResults(should_show_search); 228 contents_view_->ShowSearchResults(should_show_search);
226 229
227 if (should_show_search) 230 if (should_show_search)
228 delegate_->StartSearch(); 231 delegate_->StartSearch();
229 else 232 else
230 delegate_->StopSearch(); 233 delegate_->StopSearch();
231 } 234 }
232 235
236 void AppListMainView::SearchBoxVisibilityChanged(SearchBoxView* sender) {
237 // Repaint the AppListView's background which will repaint the background for
238 // the search box.
239 if (app_list_view_)
240 app_list_view_->RepaintBackground();
241 }
242
233 void AppListMainView::OpenResult(SearchResult* result, 243 void AppListMainView::OpenResult(SearchResult* result,
234 bool auto_launch, 244 bool auto_launch,
235 int event_flags) { 245 int event_flags) {
236 delegate_->OpenSearchResult(result, auto_launch, event_flags); 246 delegate_->OpenSearchResult(result, auto_launch, event_flags);
237 } 247 }
238 248
239 void AppListMainView::InvokeResultAction(SearchResult* result, 249 void AppListMainView::InvokeResultAction(SearchResult* result,
240 int action_index, 250 int action_index,
241 int event_flags) { 251 int event_flags) {
242 delegate_->InvokeSearchResultAction(result, action_index, event_flags); 252 delegate_->InvokeSearchResultAction(result, action_index, event_flags);
243 } 253 }
244 254
245 void AppListMainView::OnResultInstalled(SearchResult* result) { 255 void AppListMainView::OnResultInstalled(SearchResult* result) {
246 // Clears the search to show the apps grid. The last installed app 256 // Clears the search to show the apps grid. The last installed app
247 // should be highlighted and made visible already. 257 // should be highlighted and made visible already.
248 search_box_view_->ClearSearch(); 258 search_box_view_->ClearSearch();
249 } 259 }
250 260
251 void AppListMainView::OnResultUninstalled(SearchResult* result) { 261 void AppListMainView::OnResultUninstalled(SearchResult* result) {
252 // Resubmit the query via a posted task so that all observers for the 262 // Resubmit the query via a posted task so that all observers for the
253 // uninstall notification are notified. 263 // uninstall notification are notified.
254 base::MessageLoop::current()->PostTask( 264 base::MessageLoop::current()->PostTask(
255 FROM_HERE, 265 FROM_HERE,
256 base::Bind(&AppListMainView::QueryChanged, 266 base::Bind(&AppListMainView::QueryChanged,
257 weak_ptr_factory_.GetWeakPtr(), 267 weak_ptr_factory_.GetWeakPtr(),
258 search_box_view_)); 268 search_box_view_));
259 } 269 }
260 270
261 } // namespace app_list 271 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698