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

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

Issue 2143893002: Purge the App Launcher code from Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 (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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "ui/views/controls/textfield/textfield.h" 43 #include "ui/views/controls/textfield/textfield.h"
44 #include "ui/views/layout/fill_layout.h" 44 #include "ui/views/layout/fill_layout.h"
45 #include "ui/views/views_delegate.h" 45 #include "ui/views/views_delegate.h"
46 #include "ui/views/widget/widget.h" 46 #include "ui/views/widget/widget.h"
47 47
48 #if defined(USE_AURA) 48 #if defined(USE_AURA)
49 #include "ui/aura/window.h" 49 #include "ui/aura/window.h"
50 #include "ui/aura/window_tree_host.h" 50 #include "ui/aura/window_tree_host.h"
51 #include "ui/views/bubble/bubble_window_targeter.h" 51 #include "ui/views/bubble/bubble_window_targeter.h"
52 #include "ui/wm/core/masked_window_targeter.h" 52 #include "ui/wm/core/masked_window_targeter.h"
53 #if defined(OS_WIN)
54 #include "ui/base/win/shell.h"
55 #endif
56 #if !defined(OS_CHROMEOS) 53 #if !defined(OS_CHROMEOS)
57 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 54 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
58 #endif 55 #endif
59 #endif // defined(USE_AURA) 56 #endif // defined(USE_AURA)
60 57
61 namespace app_list { 58 namespace app_list {
62 59
63 namespace { 60 namespace {
64 61
65 // The margin from the edge to the speech UI. 62 // The margin from the edge to the speech UI.
66 const int kSpeechUIMargin = 12; 63 const int kSpeechUIMargin = 12;
67 64
68 // The vertical position for the appearing animation of the speech UI. 65 // The vertical position for the appearing animation of the speech UI.
69 const float kSpeechUIAppearingPosition = 12; 66 const float kSpeechUIAppearingPosition = 12;
70 67
71 // The distance between the arrow tip and edge of the anchor view. 68 // The distance between the arrow tip and edge of the anchor view.
72 const int kArrowOffset = 10; 69 const int kArrowOffset = 10;
73 70
74 // Determines whether the current environment supports shadows bubble borders. 71 // Determines whether the current environment supports shadows bubble borders.
75 bool SupportsShadow() { 72 bool SupportsShadow() {
76 #if defined(OS_WIN) 73 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
77 // Shadows are not supported on Windows without Aero Glass.
78 if (!ui::win::IsAeroGlassEnabled() ||
79 base::CommandLine::ForCurrentProcess()->HasSwitch(
80 ::switches::kDisableDwmComposition)) {
81 return false;
82 }
83 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS)
84 // Shadows are not supported on (non-ChromeOS) Linux. 74 // Shadows are not supported on (non-ChromeOS) Linux.
85 return false; 75 return false;
86 #endif 76 #endif
87 return true; 77 return true;
88 } 78 }
89 79
90 // This view forwards the focus to the search box widget by providing it as a 80 // This view forwards the focus to the search box widget by providing it as a
91 // FocusTraversable when a focus search is provided. 81 // FocusTraversable when a focus search is provided.
92 class SearchBoxFocusHost : public views::View { 82 class SearchBoxFocusHost : public views::View {
93 public: 83 public:
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 } 337 }
348 338
349 void AppListView::OnPaint(gfx::Canvas* canvas) { 339 void AppListView::OnPaint(gfx::Canvas* canvas) {
350 views::BubbleDialogDelegateView::OnPaint(canvas); 340 views::BubbleDialogDelegateView::OnPaint(canvas);
351 if (!next_paint_callback_.is_null()) { 341 if (!next_paint_callback_.is_null()) {
352 next_paint_callback_.Run(); 342 next_paint_callback_.Run();
353 next_paint_callback_.Reset(); 343 next_paint_callback_.Reset();
354 } 344 }
355 } 345 }
356 346
357 void AppListView::OnThemeChanged() {
358 #if defined(OS_WIN)
359 GetWidget()->Close();
360 #endif
361 }
362
363 bool AppListView::ShouldHandleSystemCommands() const { 347 bool AppListView::ShouldHandleSystemCommands() const {
364 return true; 348 return true;
365 } 349 }
366 350
367 bool AppListView::ShouldDescendIntoChildForEventHandling( 351 bool AppListView::ShouldDescendIntoChildForEventHandling(
368 gfx::NativeView child, 352 gfx::NativeView child,
369 const gfx::Point& location) { 353 const gfx::Point& location) {
370 // While on the start page, don't descend into the custom launcher page. Since 354 // While on the start page, don't descend into the custom launcher page. Since
371 // the only valid action is to open it. 355 // the only valid action is to open it.
372 ContentsView* contents_view = app_list_main_view_->contents_view(); 356 ContentsView* contents_view = app_list_main_view_->contents_view();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 388
405 void AppListView::RemoveObserver(AppListViewObserver* observer) { 389 void AppListView::RemoveObserver(AppListViewObserver* observer) {
406 observers_.RemoveObserver(observer); 390 observers_.RemoveObserver(observer);
407 } 391 }
408 392
409 // static 393 // static
410 void AppListView::SetNextPaintCallback(const base::Closure& callback) { 394 void AppListView::SetNextPaintCallback(const base::Closure& callback) {
411 next_paint_callback_ = callback; 395 next_paint_callback_ = callback;
412 } 396 }
413 397
414 #if defined(OS_WIN)
415 HWND AppListView::GetHWND() const {
416 gfx::NativeWindow window =
417 GetWidget()->GetTopLevelWidget()->GetNativeWindow();
418 return window->GetHost()->GetAcceleratedWidget();
419 }
420 #endif
421
422 PaginationModel* AppListView::GetAppsPaginationModel() { 398 PaginationModel* AppListView::GetAppsPaginationModel() {
423 return app_list_main_view_->contents_view() 399 return app_list_main_view_->contents_view()
424 ->apps_container_view() 400 ->apps_container_view()
425 ->apps_grid_view() 401 ->apps_grid_view()
426 ->pagination_model(); 402 ->pagination_model();
427 } 403 }
428 404
429 void AppListView::InitContents(gfx::NativeView parent, int initial_apps_page) { 405 void AppListView::InitContents(gfx::NativeView parent, int initial_apps_page) {
430 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and 406 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and
431 // crbug.com/441028 are fixed. 407 // crbug.com/441028 are fixed.
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 views::ViewsDelegate* views_delegate = views::ViewsDelegate::GetInstance(); 569 views::ViewsDelegate* views_delegate = views::ViewsDelegate::GetInstance();
594 if (views_delegate && !views_delegate->native_widget_factory().is_null()) { 570 if (views_delegate && !views_delegate->native_widget_factory().is_null()) {
595 params->native_widget = 571 params->native_widget =
596 views_delegate->native_widget_factory().Run(*params, widget); 572 views_delegate->native_widget_factory().Run(*params, widget);
597 } 573 }
598 } 574 }
599 #if defined(USE_AURA) && !defined(OS_CHROMEOS) 575 #if defined(USE_AURA) && !defined(OS_CHROMEOS)
600 if (!params->native_widget && delegate_ && delegate_->ForceNativeDesktop()) 576 if (!params->native_widget && delegate_ && delegate_->ForceNativeDesktop())
601 params->native_widget = new views::DesktopNativeWidgetAura(widget); 577 params->native_widget = new views::DesktopNativeWidgetAura(widget);
602 #endif 578 #endif
603 #if defined(OS_WIN) 579 #if defined(OS_LINUX)
604 // Windows 7 and higher offer pinning to the taskbar, but we need presence
605 // on the taskbar for the user to be able to pin us. So, show the window on
606 // the taskbar for these versions of Windows.
607 if (base::win::GetVersion() >= base::win::VERSION_WIN7)
608 params->force_show_in_taskbar = true;
609 #elif defined(OS_LINUX)
610 // Set up a custom WM_CLASS for the app launcher window. This allows task 580 // Set up a custom WM_CLASS for the app launcher window. This allows task
611 // switchers in X11 environments to distinguish it from main browser windows. 581 // switchers in X11 environments to distinguish it from main browser windows.
612 params->wm_class_name = kAppListWMClass; 582 params->wm_class_name = kAppListWMClass;
613 // Show the window in the taskbar, even though it is a bubble, which would not 583 // Show the window in the taskbar, even though it is a bubble, which would not
614 // normally be shown. 584 // normally be shown.
615 params->force_show_in_taskbar = true; 585 params->force_show_in_taskbar = true;
tapted 2016/07/20 01:15:34 we should delete Widget::InitParams::force_show_in
calamity 2016/07/25 02:34:22 Acknowledged.
616 #endif 586 #endif
617 } 587 }
618 588
619 int AppListView::GetDialogButtons() const { 589 int AppListView::GetDialogButtons() const {
620 return ui::DIALOG_BUTTON_NONE; 590 return ui::DIALOG_BUTTON_NONE;
621 } 591 }
622 592
623 views::View* AppListView::GetInitiallyFocusedView() { 593 views::View* AppListView::GetInitiallyFocusedView() {
624 return app_list_main_view_->search_box_view()->search_box(); 594 return app_list_main_view_->search_box_view()->search_box();
625 } 595 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 app_list_main_view_->SetVisible(true); 749 app_list_main_view_->SetVisible(true);
780 // Refocus the search box. However, if the app list widget does not have 750 // Refocus the search box. However, if the app list widget does not have
781 // focus, it means another window has already taken focus, and we *must not* 751 // focus, it means another window has already taken focus, and we *must not*
782 // focus the search box (or we would steal focus back into the app list). 752 // focus the search box (or we would steal focus back into the app list).
783 if (GetWidget()->IsActive()) 753 if (GetWidget()->IsActive())
784 search_box_view_->search_box()->RequestFocus(); 754 search_box_view_->search_box()->RequestFocus();
785 } 755 }
786 } 756 }
787 757
788 } // namespace app_list 758 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698