OLD | NEW |
---|---|
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/views/app_list_view.h" | 5 #include "ui/app_list/views/app_list_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 bool GetHitTestMask(aura::Window* window, gfx::Path* mask) const override { | 117 bool GetHitTestMask(aura::Window* window, gfx::Path* mask) const override { |
118 mask->addRect(gfx::RectToSkRect(search_box_->GetContentsBounds())); | 118 mask->addRect(gfx::RectToSkRect(search_box_->GetContentsBounds())); |
119 return true; | 119 return true; |
120 } | 120 } |
121 | 121 |
122 views::View* search_box_; | 122 views::View* search_box_; |
123 | 123 |
124 DISALLOW_COPY_AND_ASSIGN(SearchBoxWindowTargeter); | 124 DISALLOW_COPY_AND_ASSIGN(SearchBoxWindowTargeter); |
125 }; | 125 }; |
126 | 126 |
127 // Checks to see if the fullscreen app list has been enabled via cmd line switch | |
vadimt
2017/04/13 21:48:34
add '.'
newcomer
2017/04/18 21:12:33
Done.
| |
128 bool IsFullscreenAppListEnabled() { | |
129 return base::CommandLine::ForCurrentProcess()->HasSwitch( | |
130 switches::kEnableFullscreenAppList); | |
131 } | |
132 | |
127 } // namespace | 133 } // namespace |
128 | 134 |
129 // An animation observer to hide the view at the end of the animation. | 135 // An animation observer to hide the view at the end of the animation. |
130 class HideViewAnimationObserver : public ui::ImplicitAnimationObserver { | 136 class HideViewAnimationObserver : public ui::ImplicitAnimationObserver { |
131 public: | 137 public: |
132 HideViewAnimationObserver() | 138 HideViewAnimationObserver() |
133 : frame_(NULL), | 139 : frame_(NULL), |
134 target_(NULL) { | 140 target_(NULL) { |
135 } | 141 } |
136 | 142 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 delegate_->GetSpeechUI()->AddObserver(this); | 189 delegate_->GetSpeechUI()->AddObserver(this); |
184 } | 190 } |
185 | 191 |
186 AppListView::~AppListView() { | 192 AppListView::~AppListView() { |
187 delegate_->GetSpeechUI()->RemoveObserver(this); | 193 delegate_->GetSpeechUI()->RemoveObserver(this); |
188 animation_observer_.reset(); | 194 animation_observer_.reset(); |
189 // Remove child views first to ensure no remaining dependencies on delegate_. | 195 // Remove child views first to ensure no remaining dependencies on delegate_. |
190 RemoveAllChildViews(true); | 196 RemoveAllChildViews(true); |
191 } | 197 } |
192 | 198 |
199 void AppListView::Initialize(gfx::NativeView parent, | |
200 int initial_apps_page, | |
201 const gfx::Point ¢er_of_display_window, | |
202 const gfx::Rect display_work_area_bounds) { | |
203 base::Time start_time = base::Time::Now(); | |
204 | |
205 InitContents(parent, initial_apps_page); | |
206 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); | |
207 | |
208 if (IsFullscreenAppListEnabled()) { | |
209 set_color(kContentsBackgroundColor); | |
210 views::Widget *widget = new views::Widget; | |
211 views::Widget::InitParams app_list_overlay_view_params( | |
212 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | |
213 | |
214 app_list_overlay_view_params.parent = parent; | |
215 app_list_overlay_view_params.delegate = this; | |
216 | |
217 widget->Init(app_list_overlay_view_params); | |
218 widget->SetBounds(display_work_area_bounds); | |
219 widget->GetLayer()->SetFillsBoundsOpaquely(false); | |
220 widget->GetLayer()->SetBackgroundBlur(10); | |
221 | |
222 InitChildWidgets(); | |
223 overlay_view_ = new AppListOverlayView(0 /* no corners */); | |
224 AddChildView(overlay_view_); | |
vadimt
2017/04/13 21:48:34
Would it be possible to move this out of 'if'?
newcomer
2017/04/18 21:12:33
I refactored this, and we talked about duplicated
| |
225 | |
226 } else { | |
227 set_margins(gfx::Insets()); | |
228 set_parent_window(parent); | |
229 set_close_on_deactivate(false); | |
230 set_shadow(views::BubbleBorder::NO_ASSETS); | |
231 set_color(kContentsBackgroundColor); | |
232 | |
233 // This creates the app list widget. (Before this, child widgets cannot be | |
234 // created.) | |
235 views::BubbleDialogDelegateView::CreateBubble(this); | |
236 | |
237 SetBubbleArrow(views::BubbleBorder::FLOAT); | |
238 // We can now create the internal widgets. | |
239 | |
240 InitChildWidgets(); | |
241 aura::Window *window = GetWidget()->GetNativeWindow(); | |
242 window->SetEventTargeter( | |
243 base::MakeUnique<views::BubbleWindowTargeter>(this)); | |
244 | |
245 const int kOverlayCornerRadius = | |
246 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius(); | |
247 overlay_view_ = new AppListOverlayView(kOverlayCornerRadius); | |
248 overlay_view_->SetBoundsRect(GetContentsBounds()); | |
249 AddChildView(overlay_view_); | |
250 SetAnchorPoint(center_of_display_window); | |
251 } | |
252 | |
253 if (delegate_) | |
254 delegate_->ViewInitialized(); | |
255 | |
256 UMA_HISTOGRAM_TIMES("Apps.AppListCreationTime", | |
257 base::Time::Now() - start_time); | |
258 } | |
259 | |
193 void AppListView::InitAsBubble(gfx::NativeView parent, int initial_apps_page) { | 260 void AppListView::InitAsBubble(gfx::NativeView parent, int initial_apps_page) { |
194 base::Time start_time = base::Time::Now(); | 261 base::Time start_time = base::Time::Now(); |
195 | 262 |
196 InitContents(parent, initial_apps_page); | 263 InitContents(parent, initial_apps_page); |
197 | 264 |
198 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); | 265 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); |
199 set_margins(gfx::Insets()); | 266 set_margins(gfx::Insets()); |
200 set_parent_window(parent); | 267 set_parent_window(parent); |
201 set_close_on_deactivate(false); | 268 set_close_on_deactivate(false); |
202 set_shadow(views::BubbleBorder::NO_ASSETS); | 269 set_shadow(views::BubbleBorder::NO_ASSETS); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 } | 364 } |
298 | 365 |
299 void AppListView::OnPaint(gfx::Canvas* canvas) { | 366 void AppListView::OnPaint(gfx::Canvas* canvas) { |
300 views::BubbleDialogDelegateView::OnPaint(canvas); | 367 views::BubbleDialogDelegateView::OnPaint(canvas); |
301 if (!next_paint_callback_.is_null()) { | 368 if (!next_paint_callback_.is_null()) { |
302 next_paint_callback_.Run(); | 369 next_paint_callback_.Run(); |
303 next_paint_callback_.Reset(); | 370 next_paint_callback_.Reset(); |
304 } | 371 } |
305 } | 372 } |
306 | 373 |
374 const char* AppListView::GetClassName() const { | |
375 return "AppListView"; | |
376 } | |
377 | |
307 bool AppListView::ShouldHandleSystemCommands() const { | 378 bool AppListView::ShouldHandleSystemCommands() const { |
308 return true; | 379 return true; |
309 } | 380 } |
310 | 381 |
311 bool AppListView::ShouldDescendIntoChildForEventHandling( | 382 bool AppListView::ShouldDescendIntoChildForEventHandling( |
312 gfx::NativeView child, | 383 gfx::NativeView child, |
313 const gfx::Point& location) { | 384 const gfx::Point& location) { |
314 // While on the start page, don't descend into the custom launcher page. Since | 385 // While on the start page, don't descend into the custom launcher page. Since |
315 // the only valid action is to open it. | 386 // the only valid action is to open it. |
316 ContentsView* contents_view = app_list_main_view_->contents_view(); | 387 ContentsView* contents_view = app_list_main_view_->contents_view(); |
(...skipping 19 matching lines...) Expand all Loading... | |
336 // crbug.com/441028 are fixed. | 407 // crbug.com/441028 are fixed. |
337 tracked_objects::ScopedTracker tracking_profile( | 408 tracked_objects::ScopedTracker tracking_profile( |
338 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 409 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
339 "440224, 441028 AppListView::InitContents")); | 410 "440224, 441028 AppListView::InitContents")); |
340 | 411 |
341 app_list_main_view_ = new AppListMainView(delegate_); | 412 app_list_main_view_ = new AppListMainView(delegate_); |
342 AddChildView(app_list_main_view_); | 413 AddChildView(app_list_main_view_); |
343 app_list_main_view_->SetPaintToLayer(); | 414 app_list_main_view_->SetPaintToLayer(); |
344 app_list_main_view_->layer()->SetFillsBoundsOpaquely(false); | 415 app_list_main_view_->layer()->SetFillsBoundsOpaquely(false); |
345 app_list_main_view_->layer()->SetMasksToBounds(true); | 416 app_list_main_view_->layer()->SetMasksToBounds(true); |
346 | |
347 // This will be added to the |search_box_widget_| after the app list widget is | 417 // This will be added to the |search_box_widget_| after the app list widget is |
348 // initialized. | 418 // initialized. |
349 search_box_view_ = new SearchBoxView(app_list_main_view_, delegate_); | 419 search_box_view_ = new SearchBoxView(app_list_main_view_, delegate_); |
350 search_box_view_->SetPaintToLayer(); | 420 search_box_view_->SetPaintToLayer(); |
351 search_box_view_->layer()->SetFillsBoundsOpaquely(false); | 421 search_box_view_->layer()->SetFillsBoundsOpaquely(false); |
352 search_box_view_->layer()->SetMasksToBounds(true); | 422 search_box_view_->layer()->SetMasksToBounds(true); |
353 | 423 |
354 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and | 424 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and |
355 // crbug.com/441028 are fixed. | 425 // crbug.com/441028 are fixed. |
356 tracked_objects::ScopedTracker tracking_profile1( | 426 tracked_objects::ScopedTracker tracking_profile1( |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
567 app_list_main_view_->SetVisible(true); | 637 app_list_main_view_->SetVisible(true); |
568 // Refocus the search box. However, if the app list widget does not have | 638 // Refocus the search box. However, if the app list widget does not have |
569 // focus, it means another window has already taken focus, and we *must not* | 639 // focus, it means another window has already taken focus, and we *must not* |
570 // focus the search box (or we would steal focus back into the app list). | 640 // focus the search box (or we would steal focus back into the app list). |
571 if (GetWidget()->IsActive()) | 641 if (GetWidget()->IsActive()) |
572 search_box_view_->search_box()->RequestFocus(); | 642 search_box_view_->search_box()->RequestFocus(); |
573 } | 643 } |
574 } | 644 } |
575 | 645 |
576 } // namespace app_list | 646 } // namespace app_list |
OLD | NEW |