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

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: address comment Created 4 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 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();
373 if (contents_view->custom_page_view() && 357 if (contents_view->custom_page_view() &&
374 contents_view->GetActiveState() == AppListModel::STATE_START) 358 contents_view->GetActiveState() == AppListModel::STATE_START)
375 return !contents_view->custom_page_view() 359 return !contents_view->custom_page_view()
376 ->GetCollapsedLauncherPageBounds() 360 ->GetCollapsedLauncherPageBounds()
377 .Contains(location); 361 .Contains(location);
378 362
379 return views::BubbleDialogDelegateView:: 363 return views::BubbleDialogDelegateView::
380 ShouldDescendIntoChildForEventHandling(child, location); 364 ShouldDescendIntoChildForEventHandling(child, location);
381 } 365 }
382 366
383 void AppListView::Prerender() {
384 app_list_main_view_->Prerender();
385 }
386
387 void AppListView::OnProfilesChanged() { 367 void AppListView::OnProfilesChanged() {
388 app_list_main_view_->search_box_view()->InvalidateMenu(); 368 app_list_main_view_->search_box_view()->InvalidateMenu();
389 } 369 }
390 370
391 void AppListView::OnShutdown() { 371 void AppListView::OnShutdown() {
392 // Nothing to do on views - the widget will soon be closed, which will tear 372 // Nothing to do on views - the widget will soon be closed, which will tear
393 // everything down. 373 // everything down.
394 } 374 }
395 375
396 void AppListView::SetProfileByPath(const base::FilePath& profile_path) { 376 void AppListView::SetProfileByPath(const base::FilePath& profile_path) {
397 delegate_->SetProfileByPath(profile_path); 377 delegate_->SetProfileByPath(profile_path);
398 app_list_main_view_->ModelChanged(); 378 app_list_main_view_->ModelChanged();
399 } 379 }
400 380
401 void AppListView::AddObserver(AppListViewObserver* observer) { 381 void AppListView::AddObserver(AppListViewObserver* observer) {
402 observers_.AddObserver(observer); 382 observers_.AddObserver(observer);
403 } 383 }
404 384
405 void AppListView::RemoveObserver(AppListViewObserver* observer) { 385 void AppListView::RemoveObserver(AppListViewObserver* observer) {
406 observers_.RemoveObserver(observer); 386 observers_.RemoveObserver(observer);
407 } 387 }
408 388
409 // static
410 void AppListView::SetNextPaintCallback(const base::Closure& callback) {
411 next_paint_callback_ = callback;
412 }
413
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() { 389 PaginationModel* AppListView::GetAppsPaginationModel() {
423 return app_list_main_view_->contents_view() 390 return app_list_main_view_->contents_view()
424 ->apps_container_view() 391 ->apps_container_view()
425 ->apps_grid_view() 392 ->apps_grid_view()
426 ->pagination_model(); 393 ->pagination_model();
427 } 394 }
428 395
429 void AppListView::InitContents(gfx::NativeView parent, int initial_apps_page) { 396 void AppListView::InitContents(gfx::NativeView parent, int initial_apps_page) {
430 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and 397 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and
431 // crbug.com/441028 are fixed. 398 // 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(); 560 views::ViewsDelegate* views_delegate = views::ViewsDelegate::GetInstance();
594 if (views_delegate && !views_delegate->native_widget_factory().is_null()) { 561 if (views_delegate && !views_delegate->native_widget_factory().is_null()) {
595 params->native_widget = 562 params->native_widget =
596 views_delegate->native_widget_factory().Run(*params, widget); 563 views_delegate->native_widget_factory().Run(*params, widget);
597 } 564 }
598 } 565 }
599 #if defined(USE_AURA) && !defined(OS_CHROMEOS) 566 #if defined(USE_AURA) && !defined(OS_CHROMEOS)
600 if (!params->native_widget && delegate_ && delegate_->ForceNativeDesktop()) 567 if (!params->native_widget && delegate_ && delegate_->ForceNativeDesktop())
601 params->native_widget = new views::DesktopNativeWidgetAura(widget); 568 params->native_widget = new views::DesktopNativeWidgetAura(widget);
602 #endif 569 #endif
603 #if defined(OS_WIN) 570 #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 571 // 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. 572 // switchers in X11 environments to distinguish it from main browser windows.
612 params->wm_class_name = kAppListWMClass; 573 params->wm_class_name = kAppListWMClass;
613 // Show the window in the taskbar, even though it is a bubble, which would not 574 // Show the window in the taskbar, even though it is a bubble, which would not
614 // normally be shown. 575 // normally be shown.
615 params->force_show_in_taskbar = true; 576 params->force_show_in_taskbar = true;
616 #endif 577 #endif
617 } 578 }
618 579
619 int AppListView::GetDialogButtons() const { 580 int AppListView::GetDialogButtons() const {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 app_list_main_view_->SetVisible(true); 740 app_list_main_view_->SetVisible(true);
780 // Refocus the search box. However, if the app list widget does not have 741 // 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* 742 // 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). 743 // focus the search box (or we would steal focus back into the app list).
783 if (GetWidget()->IsActive()) 744 if (GetWidget()->IsActive())
784 search_box_view_->search_box()->RequestFocus(); 745 search_box_view_->search_box()->RequestFocus();
785 } 746 }
786 } 747 }
787 748
788 } // namespace app_list 749 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698