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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 | 369 |
370 void AppListView::InitChildWidgets() { | 370 void AppListView::InitChildWidgets() { |
371 DCHECK(search_box_view_); | 371 DCHECK(search_box_view_); |
372 | 372 |
373 // Create the search box widget. | 373 // Create the search box widget. |
374 views::Widget::InitParams search_box_widget_params( | 374 views::Widget::InitParams search_box_widget_params( |
375 views::Widget::InitParams::TYPE_CONTROL); | 375 views::Widget::InitParams::TYPE_CONTROL); |
376 search_box_widget_params.parent = GetWidget()->GetNativeView(); | 376 search_box_widget_params.parent = GetWidget()->GetNativeView(); |
377 search_box_widget_params.opacity = | 377 search_box_widget_params.opacity = |
378 views::Widget::InitParams::TRANSLUCENT_WINDOW; | 378 views::Widget::InitParams::TRANSLUCENT_WINDOW; |
379 search_box_widget_params.name = "SearchBoxView"; | |
xiyuan
2017/05/04 23:08:14
nit: SearchBoxView -> SearchBoxWidget to avoid dup
| |
379 | 380 |
380 // Create a widget for the SearchBoxView to live in. This allows the | 381 // Create a widget for the SearchBoxView to live in. This allows the |
381 // SearchBoxView to be on top of the custom launcher page's WebContents | 382 // SearchBoxView to be on top of the custom launcher page's WebContents |
382 // (otherwise the search box events will be captured by the WebContents). | 383 // (otherwise the search box events will be captured by the WebContents). |
383 search_box_widget_ = new views::Widget; | 384 search_box_widget_ = new views::Widget; |
384 search_box_widget_->Init(search_box_widget_params); | 385 search_box_widget_->Init(search_box_widget_params); |
385 search_box_widget_->SetContentsView(search_box_view_); | 386 search_box_widget_->SetContentsView(search_box_view_); |
386 | 387 |
387 // The search box will not naturally receive focus by itself (because it is in | 388 // The search box will not naturally receive focus by itself (because it is in |
388 // a separate widget). Create this SearchBoxFocusHost in the main widget to | 389 // a separate widget). Create this SearchBoxFocusHost in the main widget to |
389 // forward the focus search into to the search box. | 390 // forward the focus search into to the search box. |
390 search_box_focus_host_ = new SearchBoxFocusHost(search_box_widget_); | 391 search_box_focus_host_ = new SearchBoxFocusHost(search_box_widget_); |
391 AddChildView(search_box_focus_host_); | 392 AddChildView(search_box_focus_host_); |
392 search_box_widget_->SetFocusTraversableParentView(search_box_focus_host_); | 393 search_box_widget_->SetFocusTraversableParentView(search_box_focus_host_); |
393 search_box_widget_->SetFocusTraversableParent( | 394 search_box_widget_->SetFocusTraversableParent( |
394 GetWidget()->GetFocusTraversable()); | 395 GetWidget()->GetFocusTraversable()); |
395 | 396 |
396 // Mouse events on the search box shadow should not be captured. | 397 // Mouse events on the search box shadow should not be captured. |
397 aura::Window* window = search_box_widget_->GetNativeWindow(); | 398 aura::Window* window = search_box_widget_->GetNativeWindow(); |
398 window->SetEventTargeter( | 399 window->SetEventTargeter( |
399 base::MakeUnique<SearchBoxWindowTargeter>(search_box_view_)); | 400 base::MakeUnique<SearchBoxWindowTargeter>(search_box_view_)); |
400 | 401 |
401 app_list_main_view_->contents_view()->Layout(); | 402 app_list_main_view_->contents_view()->Layout(); |
402 } | 403 } |
403 | 404 |
404 void AppListView::InitializeFullscreen(gfx::NativeView parent, | 405 void AppListView::InitializeFullscreen(gfx::NativeView parent, |
405 int initial_apps_page) { | 406 int initial_apps_page) { |
406 | |
407 views::Widget* widget = new views::Widget; | 407 views::Widget* widget = new views::Widget; |
408 views::Widget::InitParams app_list_overlay_view_params( | 408 views::Widget::InitParams app_list_overlay_view_params( |
409 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 409 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
410 | 410 |
411 app_list_overlay_view_params.parent = parent; | 411 app_list_overlay_view_params.parent = parent; |
412 app_list_overlay_view_params.delegate = this; | 412 app_list_overlay_view_params.delegate = this; |
413 app_list_overlay_view_params.opacity = | 413 app_list_overlay_view_params.opacity = |
414 views::Widget::InitParams::TRANSLUCENT_WINDOW; | 414 views::Widget::InitParams::TRANSLUCENT_WINDOW; |
415 app_list_overlay_view_params.bounds = | 415 app_list_overlay_view_params.bounds = |
416 display::Screen::GetScreen()-> | 416 display::Screen::GetScreen()-> |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
597 app_list_main_view_->SetVisible(true); | 597 app_list_main_view_->SetVisible(true); |
598 // Refocus the search box. However, if the app list widget does not have | 598 // Refocus the search box. However, if the app list widget does not have |
599 // focus, it means another window has already taken focus, and we *must not* | 599 // focus, it means another window has already taken focus, and we *must not* |
600 // focus the search box (or we would steal focus back into the app list). | 600 // focus the search box (or we would steal focus back into the app list). |
601 if (GetWidget()->IsActive()) | 601 if (GetWidget()->IsActive()) |
602 search_box_view_->search_box()->RequestFocus(); | 602 search_box_view_->search_box()->RequestFocus(); |
603 } | 603 } |
604 } | 604 } |
605 | 605 |
606 } // namespace app_list | 606 } // namespace app_list |
OLD | NEW |