| 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" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/profiler/scoped_tracker.h" | 12 #include "base/profiler/scoped_tracker.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/win/windows_version.h" | 14 #include "base/win/windows_version.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "ui/app_list/app_list_constants.h" | 16 #include "ui/app_list/app_list_constants.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/speech_ui_model.h" | 20 #include "ui/app_list/speech_ui_model.h" |
| 21 #include "ui/app_list/views/app_list_background.h" | |
| 22 #include "ui/app_list/views/app_list_folder_view.h" | 21 #include "ui/app_list/views/app_list_folder_view.h" |
| 23 #include "ui/app_list/views/app_list_main_view.h" | 22 #include "ui/app_list/views/app_list_main_view.h" |
| 24 #include "ui/app_list/views/app_list_view_observer.h" | |
| 25 #include "ui/app_list/views/apps_container_view.h" | 23 #include "ui/app_list/views/apps_container_view.h" |
| 26 #include "ui/app_list/views/contents_view.h" | 24 #include "ui/app_list/views/contents_view.h" |
| 27 #include "ui/app_list/views/custom_launcher_page_view.h" | 25 #include "ui/app_list/views/custom_launcher_page_view.h" |
| 28 #include "ui/app_list/views/search_box_view.h" | 26 #include "ui/app_list/views/search_box_view.h" |
| 29 #include "ui/app_list/views/speech_view.h" | 27 #include "ui/app_list/views/speech_view.h" |
| 30 #include "ui/app_list/views/start_page_view.h" | 28 #include "ui/app_list/views/start_page_view.h" |
| 29 #include "ui/aura/window.h" |
| 30 #include "ui/aura/window_tree_host.h" |
| 31 #include "ui/base/ui_base_switches.h" | 31 #include "ui/base/ui_base_switches.h" |
| 32 #include "ui/compositor/layer.h" | 32 #include "ui/compositor/layer.h" |
| 33 #include "ui/compositor/layer_animation_observer.h" | 33 #include "ui/compositor/layer_animation_observer.h" |
| 34 #include "ui/compositor/scoped_layer_animation_settings.h" | 34 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 35 #include "ui/gfx/canvas.h" | 35 #include "ui/gfx/canvas.h" |
| 36 #include "ui/gfx/geometry/insets.h" | 36 #include "ui/gfx/geometry/insets.h" |
| 37 #include "ui/gfx/image/image_skia.h" | 37 #include "ui/gfx/image/image_skia.h" |
| 38 #include "ui/gfx/path.h" | 38 #include "ui/gfx/path.h" |
| 39 #include "ui/gfx/skia_util.h" | 39 #include "ui/gfx/skia_util.h" |
| 40 #include "ui/resources/grit/ui_resources.h" | 40 #include "ui/resources/grit/ui_resources.h" |
| 41 #include "ui/views/bubble/bubble_frame_view.h" | 41 #include "ui/views/bubble/bubble_frame_view.h" |
| 42 #include "ui/views/bubble/bubble_window_targeter.h" |
| 42 #include "ui/views/controls/image_view.h" | 43 #include "ui/views/controls/image_view.h" |
| 43 #include "ui/views/controls/textfield/textfield.h" | 44 #include "ui/views/controls/textfield/textfield.h" |
| 44 #include "ui/views/layout/fill_layout.h" | 45 #include "ui/views/layout/fill_layout.h" |
| 45 #include "ui/views/views_delegate.h" | 46 #include "ui/views/views_delegate.h" |
| 46 #include "ui/views/widget/widget.h" | 47 #include "ui/views/widget/widget.h" |
| 47 | |
| 48 #if defined(USE_AURA) | |
| 49 #include "ui/aura/window.h" | |
| 50 #include "ui/aura/window_tree_host.h" | |
| 51 #include "ui/views/bubble/bubble_window_targeter.h" | |
| 52 #include "ui/wm/core/masked_window_targeter.h" | 48 #include "ui/wm/core/masked_window_targeter.h" |
| 53 #if !defined(OS_CHROMEOS) | |
| 54 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | |
| 55 #endif | |
| 56 #endif // defined(USE_AURA) | |
| 57 | 49 |
| 58 namespace app_list { | 50 namespace app_list { |
| 59 | 51 |
| 60 namespace { | 52 namespace { |
| 61 | 53 |
| 62 // The margin from the edge to the speech UI. | 54 // The margin from the edge to the speech UI. |
| 63 const int kSpeechUIMargin = 12; | 55 const int kSpeechUIMargin = 12; |
| 64 | 56 |
| 65 // The vertical position for the appearing animation of the speech UI. | 57 // The vertical position for the appearing animation of the speech UI. |
| 66 const float kSpeechUIAppearingPosition = 12; | 58 const float kSpeechUIAppearingPosition = 12; |
| 67 | 59 |
| 68 // The distance between the arrow tip and edge of the anchor view. | |
| 69 const int kArrowOffset = 10; | |
| 70 | |
| 71 // Determines whether the current environment supports shadows bubble borders. | |
| 72 bool SupportsShadow() { | |
| 73 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 74 // Shadows are not supported on (non-ChromeOS) Linux. | |
| 75 return false; | |
| 76 #endif | |
| 77 return true; | |
| 78 } | |
| 79 | |
| 80 // This view forwards the focus to the search box widget by providing it as a | 60 // This view forwards the focus to the search box widget by providing it as a |
| 81 // FocusTraversable when a focus search is provided. | 61 // FocusTraversable when a focus search is provided. |
| 82 class SearchBoxFocusHost : public views::View { | 62 class SearchBoxFocusHost : public views::View { |
| 83 public: | 63 public: |
| 84 explicit SearchBoxFocusHost(views::Widget* search_box_widget) | 64 explicit SearchBoxFocusHost(views::Widget* search_box_widget) |
| 85 : search_box_widget_(search_box_widget) {} | 65 : search_box_widget_(search_box_widget) {} |
| 86 | 66 |
| 87 ~SearchBoxFocusHost() override {} | 67 ~SearchBoxFocusHost() override {} |
| 88 | 68 |
| 89 views::FocusTraversable* GetFocusTraversable() override { | 69 views::FocusTraversable* GetFocusTraversable() override { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 116 paint.setColor(SK_ColorWHITE); | 96 paint.setColor(SK_ColorWHITE); |
| 117 canvas->DrawRoundRect(GetContentsBounds(), corner_radius_, paint); | 97 canvas->DrawRoundRect(GetContentsBounds(), corner_radius_, paint); |
| 118 } | 98 } |
| 119 | 99 |
| 120 private: | 100 private: |
| 121 const int corner_radius_; | 101 const int corner_radius_; |
| 122 | 102 |
| 123 DISALLOW_COPY_AND_ASSIGN(AppListOverlayView); | 103 DISALLOW_COPY_AND_ASSIGN(AppListOverlayView); |
| 124 }; | 104 }; |
| 125 | 105 |
| 126 #if defined(USE_AURA) | |
| 127 // An event targeter for the search box widget which will ignore events that | 106 // An event targeter for the search box widget which will ignore events that |
| 128 // are on the search box's shadow. | 107 // are on the search box's shadow. |
| 129 class SearchBoxWindowTargeter : public wm::MaskedWindowTargeter { | 108 class SearchBoxWindowTargeter : public wm::MaskedWindowTargeter { |
| 130 public: | 109 public: |
| 131 explicit SearchBoxWindowTargeter(views::View* search_box) | 110 explicit SearchBoxWindowTargeter(views::View* search_box) |
| 132 : wm::MaskedWindowTargeter(search_box->GetWidget()->GetNativeWindow()), | 111 : wm::MaskedWindowTargeter(search_box->GetWidget()->GetNativeWindow()), |
| 133 search_box_(search_box) {} | 112 search_box_(search_box) {} |
| 134 ~SearchBoxWindowTargeter() override {} | 113 ~SearchBoxWindowTargeter() override {} |
| 135 | 114 |
| 136 private: | 115 private: |
| 137 // wm::MaskedWindowTargeter: | 116 // wm::MaskedWindowTargeter: |
| 138 bool GetHitTestMask(aura::Window* window, gfx::Path* mask) const override { | 117 bool GetHitTestMask(aura::Window* window, gfx::Path* mask) const override { |
| 139 mask->addRect(gfx::RectToSkRect(search_box_->GetContentsBounds())); | 118 mask->addRect(gfx::RectToSkRect(search_box_->GetContentsBounds())); |
| 140 return true; | 119 return true; |
| 141 } | 120 } |
| 142 | 121 |
| 143 views::View* search_box_; | 122 views::View* search_box_; |
| 144 | 123 |
| 145 DISALLOW_COPY_AND_ASSIGN(SearchBoxWindowTargeter); | 124 DISALLOW_COPY_AND_ASSIGN(SearchBoxWindowTargeter); |
| 146 }; | 125 }; |
| 147 #endif | |
| 148 | 126 |
| 149 } // namespace | 127 } // namespace |
| 150 | 128 |
| 151 // An animation observer to hide the view at the end of the animation. | 129 // An animation observer to hide the view at the end of the animation. |
| 152 class HideViewAnimationObserver : public ui::ImplicitAnimationObserver { | 130 class HideViewAnimationObserver : public ui::ImplicitAnimationObserver { |
| 153 public: | 131 public: |
| 154 HideViewAnimationObserver() | 132 HideViewAnimationObserver() |
| 155 : frame_(NULL), | 133 : frame_(NULL), |
| 156 target_(NULL) { | 134 target_(NULL) { |
| 157 } | 135 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 delegate_->GetSpeechUI()->AddObserver(this); | 183 delegate_->GetSpeechUI()->AddObserver(this); |
| 206 } | 184 } |
| 207 | 185 |
| 208 AppListView::~AppListView() { | 186 AppListView::~AppListView() { |
| 209 delegate_->GetSpeechUI()->RemoveObserver(this); | 187 delegate_->GetSpeechUI()->RemoveObserver(this); |
| 210 animation_observer_.reset(); | 188 animation_observer_.reset(); |
| 211 // Remove child views first to ensure no remaining dependencies on delegate_. | 189 // Remove child views first to ensure no remaining dependencies on delegate_. |
| 212 RemoveAllChildViews(true); | 190 RemoveAllChildViews(true); |
| 213 } | 191 } |
| 214 | 192 |
| 215 void AppListView::InitAsBubbleAtFixedLocation( | 193 void AppListView::InitAsBubble(gfx::NativeView parent, int initial_apps_page) { |
| 216 gfx::NativeView parent, | 194 base::Time start_time = base::Time::Now(); |
| 217 int initial_apps_page, | 195 |
| 218 const gfx::Point& anchor_point_in_screen, | 196 InitContents(parent, initial_apps_page); |
| 219 views::BubbleBorder::Arrow arrow, | 197 |
| 220 bool border_accepts_events) { | 198 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); |
| 221 SetAnchorRect(gfx::Rect(anchor_point_in_screen, gfx::Size())); | 199 set_margins(gfx::Insets()); |
| 222 // TODO(mgiuca): Inline InitAsBubbleInternal, since there is only one caller. | 200 set_parent_window(parent); |
| 223 InitAsBubbleInternal( | 201 set_close_on_deactivate(false); |
| 224 parent, initial_apps_page, arrow, border_accepts_events, gfx::Vector2d()); | 202 set_shadow(views::BubbleBorder::NO_ASSETS); |
| 203 set_color(kContentsBackgroundColor); |
| 204 // This creates the app list widget. (Before this, child widgets cannot be |
| 205 // created.) |
| 206 views::BubbleDialogDelegateView::CreateBubble(this); |
| 207 |
| 208 SetBubbleArrow(views::BubbleBorder::FLOAT); |
| 209 // We can now create the internal widgets. |
| 210 InitChildWidgets(); |
| 211 |
| 212 aura::Window* window = GetWidget()->GetNativeWindow(); |
| 213 window->SetEventTargeter(base::MakeUnique<views::BubbleWindowTargeter>(this)); |
| 214 |
| 215 const int kOverlayCornerRadius = |
| 216 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius(); |
| 217 overlay_view_ = new AppListOverlayView(kOverlayCornerRadius); |
| 218 overlay_view_->SetBoundsRect(GetContentsBounds()); |
| 219 AddChildView(overlay_view_); |
| 220 |
| 221 if (delegate_) |
| 222 delegate_->ViewInitialized(); |
| 223 |
| 224 UMA_HISTOGRAM_TIMES("Apps.AppListCreationTime", |
| 225 base::Time::Now() - start_time); |
| 225 } | 226 } |
| 226 | 227 |
| 227 void AppListView::InitAsFramelessWindow(gfx::NativeView parent, | 228 void AppListView::InitAsFramelessWindow(gfx::NativeView parent, |
| 228 int initial_apps_page, | 229 int initial_apps_page, |
| 229 gfx::Rect bounds) { | 230 gfx::Rect bounds) { |
| 231 set_color(kContentsBackgroundColor); |
| 230 InitContents(parent, initial_apps_page); | 232 InitContents(parent, initial_apps_page); |
| 231 overlay_view_ = new AppListOverlayView(0 /* no corners */); | 233 overlay_view_ = new AppListOverlayView(0 /* no corners */); |
| 232 AddChildView(overlay_view_); | 234 AddChildView(overlay_view_); |
| 233 | 235 |
| 234 views::Widget* widget = new views::Widget(); | 236 views::Widget* widget = new views::Widget(); |
| 235 views::Widget::InitParams params( | 237 views::Widget::InitParams params( |
| 236 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 238 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 237 params.parent = parent; | 239 params.parent = parent; |
| 238 params.delegate = this; | 240 params.delegate = this; |
| 239 widget->Init(params); | 241 widget->Init(params); |
| 240 widget->SetBounds(bounds); | 242 widget->SetBounds(bounds); |
| 241 // This needs to be set *after* Widget::Init() because | |
| 242 // BubbleDialogDelegateView sets its own background at OnNativeThemeChanged(), | |
| 243 // which is called in View::AddChildView() which is called at | |
| 244 // Widget::SetContentsView() to build the views hierarchy in the widget. | |
| 245 set_background(new AppListBackground(0)); | |
| 246 | 243 |
| 247 InitChildWidgets(); | 244 InitChildWidgets(); |
| 248 } | 245 } |
| 249 | 246 |
| 250 void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) { | 247 void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) { |
| 251 GetBubbleFrameView()->bubble_border()->set_arrow(arrow); | 248 GetBubbleFrameView()->bubble_border()->set_arrow(arrow); |
| 252 SizeToContents(); // Recalcuates with new border. | 249 SizeToContents(); // Recalcuates with new border. |
| 253 GetBubbleFrameView()->SchedulePaint(); | 250 GetBubbleFrameView()->SchedulePaint(); |
| 254 } | 251 } |
| 255 | 252 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 341 |
| 345 return views::BubbleDialogDelegateView:: | 342 return views::BubbleDialogDelegateView:: |
| 346 ShouldDescendIntoChildForEventHandling(child, location); | 343 ShouldDescendIntoChildForEventHandling(child, location); |
| 347 } | 344 } |
| 348 | 345 |
| 349 void AppListView::SetProfileByPath(const base::FilePath& profile_path) { | 346 void AppListView::SetProfileByPath(const base::FilePath& profile_path) { |
| 350 delegate_->SetProfileByPath(profile_path); | 347 delegate_->SetProfileByPath(profile_path); |
| 351 app_list_main_view_->ModelChanged(); | 348 app_list_main_view_->ModelChanged(); |
| 352 } | 349 } |
| 353 | 350 |
| 354 void AppListView::AddObserver(AppListViewObserver* observer) { | |
| 355 observers_.AddObserver(observer); | |
| 356 } | |
| 357 | |
| 358 void AppListView::RemoveObserver(AppListViewObserver* observer) { | |
| 359 observers_.RemoveObserver(observer); | |
| 360 } | |
| 361 | |
| 362 PaginationModel* AppListView::GetAppsPaginationModel() { | 351 PaginationModel* AppListView::GetAppsPaginationModel() { |
| 363 return app_list_main_view_->contents_view() | 352 return app_list_main_view_->contents_view() |
| 364 ->apps_container_view() | 353 ->apps_container_view() |
| 365 ->apps_grid_view() | 354 ->apps_grid_view() |
| 366 ->pagination_model(); | 355 ->pagination_model(); |
| 367 } | 356 } |
| 368 | 357 |
| 369 void AppListView::InitContents(gfx::NativeView parent, int initial_apps_page) { | 358 void AppListView::InitContents(gfx::NativeView parent, int initial_apps_page) { |
| 370 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and | 359 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and |
| 371 // crbug.com/441028 are fixed. | 360 // crbug.com/441028 are fixed. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 | 419 |
| 431 // The search box will not naturally receive focus by itself (because it is in | 420 // The search box will not naturally receive focus by itself (because it is in |
| 432 // a separate widget). Create this SearchBoxFocusHost in the main widget to | 421 // a separate widget). Create this SearchBoxFocusHost in the main widget to |
| 433 // forward the focus search into to the search box. | 422 // forward the focus search into to the search box. |
| 434 search_box_focus_host_ = new SearchBoxFocusHost(search_box_widget_); | 423 search_box_focus_host_ = new SearchBoxFocusHost(search_box_widget_); |
| 435 AddChildView(search_box_focus_host_); | 424 AddChildView(search_box_focus_host_); |
| 436 search_box_widget_->SetFocusTraversableParentView(search_box_focus_host_); | 425 search_box_widget_->SetFocusTraversableParentView(search_box_focus_host_); |
| 437 search_box_widget_->SetFocusTraversableParent( | 426 search_box_widget_->SetFocusTraversableParent( |
| 438 GetWidget()->GetFocusTraversable()); | 427 GetWidget()->GetFocusTraversable()); |
| 439 | 428 |
| 440 #if defined(USE_AURA) | |
| 441 // Mouse events on the search box shadow should not be captured. | 429 // Mouse events on the search box shadow should not be captured. |
| 442 aura::Window* window = search_box_widget_->GetNativeWindow(); | 430 aura::Window* window = search_box_widget_->GetNativeWindow(); |
| 443 window->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( | 431 window->SetEventTargeter( |
| 444 new SearchBoxWindowTargeter(search_box_view_))); | 432 base::MakeUnique<SearchBoxWindowTargeter>(search_box_view_)); |
| 445 #endif | |
| 446 | 433 |
| 447 app_list_main_view_->contents_view()->Layout(); | 434 app_list_main_view_->contents_view()->Layout(); |
| 448 } | 435 } |
| 449 | 436 |
| 450 void AppListView::InitAsBubbleInternal(gfx::NativeView parent, | |
| 451 int initial_apps_page, | |
| 452 views::BubbleBorder::Arrow arrow, | |
| 453 bool border_accepts_events, | |
| 454 const gfx::Vector2d& anchor_offset) { | |
| 455 base::Time start_time = base::Time::Now(); | |
| 456 | |
| 457 InitContents(parent, initial_apps_page); | |
| 458 | |
| 459 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); | |
| 460 set_color(kContentsBackgroundColor); | |
| 461 set_margins(gfx::Insets()); | |
| 462 set_parent_window(parent); | |
| 463 set_close_on_deactivate(false); | |
| 464 set_anchor_view_insets(gfx::Insets(kArrowOffset + anchor_offset.y(), | |
| 465 kArrowOffset + anchor_offset.x(), | |
| 466 kArrowOffset - anchor_offset.y(), | |
| 467 kArrowOffset - anchor_offset.x())); | |
| 468 set_border_accepts_events(border_accepts_events); | |
| 469 set_shadow(SupportsShadow() ? views::BubbleBorder::BIG_SHADOW | |
| 470 : views::BubbleBorder::NO_SHADOW_OPAQUE_BORDER); | |
| 471 | |
| 472 { | |
| 473 // TODO(tapted): Remove ScopedTracker below once crbug.com/431326 is fixed. | |
| 474 tracked_objects::ScopedTracker tracking_profile( | |
| 475 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 476 "431326 views::BubbleDialogDelegateView::CreateBubble()")); | |
| 477 | |
| 478 // This creates the app list widget. (Before this, child widgets cannot be | |
| 479 // created.) | |
| 480 views::BubbleDialogDelegateView::CreateBubble(this); | |
| 481 } | |
| 482 | |
| 483 SetBubbleArrow(arrow); | |
| 484 | |
| 485 // We can now create the internal widgets. | |
| 486 InitChildWidgets(); | |
| 487 | |
| 488 #if defined(USE_AURA) | |
| 489 aura::Window* window = GetWidget()->GetNativeWindow(); | |
| 490 window->layer()->SetMasksToBounds(true); | |
| 491 GetBubbleFrameView()->set_background(new AppListBackground( | |
| 492 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius())); | |
| 493 set_background(NULL); | |
| 494 window->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( | |
| 495 new views::BubbleWindowTargeter(this))); | |
| 496 #else | |
| 497 set_background(new AppListBackground( | |
| 498 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius())); | |
| 499 | |
| 500 // On non-aura the bubble has two widgets, and it's possible for the border | |
| 501 // to be shown independently in odd situations. Explicitly hide the bubble | |
| 502 // widget to ensure that any WM_WINDOWPOSCHANGED messages triggered by the | |
| 503 // window manager do not have the SWP_SHOWWINDOW flag set which would cause | |
| 504 // the border to be shown. See http://crbug.com/231687 . | |
| 505 GetWidget()->Hide(); | |
| 506 #endif | |
| 507 | |
| 508 // On platforms that don't support a shadow, the rounded border of the app | |
| 509 // list is constructed _inside_ the view, so a rectangular background goes | |
| 510 // over the border in the rounded corners. To fix this, give the background a | |
| 511 // corner radius 1px smaller than the outer border, so it just reaches but | |
| 512 // doesn't cover it. | |
| 513 const int kOverlayCornerRadius = | |
| 514 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius(); | |
| 515 overlay_view_ = | |
| 516 new AppListOverlayView(kOverlayCornerRadius - (SupportsShadow() ? 0 : 1)); | |
| 517 overlay_view_->SetBoundsRect(GetContentsBounds()); | |
| 518 AddChildView(overlay_view_); | |
| 519 | |
| 520 if (delegate_) | |
| 521 delegate_->ViewInitialized(); | |
| 522 | |
| 523 UMA_HISTOGRAM_TIMES("Apps.AppListCreationTime", | |
| 524 base::Time::Now() - start_time); | |
| 525 } | |
| 526 | |
| 527 void AppListView::OnBeforeBubbleWidgetInit( | 437 void AppListView::OnBeforeBubbleWidgetInit( |
| 528 views::Widget::InitParams* params, | 438 views::Widget::InitParams* params, |
| 529 views::Widget* widget) const { | 439 views::Widget* widget) const { |
| 530 if (!params->native_widget) { | 440 if (!params->native_widget) { |
| 531 views::ViewsDelegate* views_delegate = views::ViewsDelegate::GetInstance(); | 441 views::ViewsDelegate* views_delegate = views::ViewsDelegate::GetInstance(); |
| 532 if (views_delegate && !views_delegate->native_widget_factory().is_null()) { | 442 if (views_delegate && !views_delegate->native_widget_factory().is_null()) { |
| 533 params->native_widget = | 443 params->native_widget = |
| 534 views_delegate->native_widget_factory().Run(*params, widget); | 444 views_delegate->native_widget_factory().Run(*params, widget); |
| 535 } | 445 } |
| 536 } | 446 } |
| 537 #if defined(USE_AURA) && !defined(OS_CHROMEOS) | 447 // Apply a WM-provided shadow (see ui/wm/core/). |
| 538 if (!params->native_widget && delegate_ && delegate_->ForceNativeDesktop()) | 448 params->shadow_type = views::Widget::InitParams::SHADOW_TYPE_DROP; |
| 539 params->native_widget = new views::DesktopNativeWidgetAura(widget); | |
| 540 #endif | |
| 541 #if defined(OS_LINUX) | |
| 542 // Set up a custom WM_CLASS for the app launcher window. This allows task | |
| 543 // switchers in X11 environments to distinguish it from main browser windows. | |
| 544 params->wm_class_name = kAppListWMClass; | |
| 545 // Show the window in the taskbar, even though it is a bubble, which would not | |
| 546 // normally be shown. | |
| 547 params->force_show_in_taskbar = true; | |
| 548 #endif | |
| 549 } | 449 } |
| 550 | 450 |
| 551 int AppListView::GetDialogButtons() const { | 451 int AppListView::GetDialogButtons() const { |
| 552 return ui::DIALOG_BUTTON_NONE; | 452 return ui::DIALOG_BUTTON_NONE; |
| 553 } | 453 } |
| 554 | 454 |
| 555 views::View* AppListView::GetInitiallyFocusedView() { | 455 views::View* AppListView::GetInitiallyFocusedView() { |
| 556 return app_list_main_view_->search_box_view()->search_box(); | 456 return app_list_main_view_->search_box_view()->search_box(); |
| 557 } | 457 } |
| 558 | 458 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 if (GetBubbleFrameView()) | 510 if (GetBubbleFrameView()) |
| 611 GetBubbleFrameView()->SchedulePaint(); | 511 GetBubbleFrameView()->SchedulePaint(); |
| 612 } | 512 } |
| 613 | 513 |
| 614 void AppListView::OnWidgetDestroying(views::Widget* widget) { | 514 void AppListView::OnWidgetDestroying(views::Widget* widget) { |
| 615 BubbleDialogDelegateView::OnWidgetDestroying(widget); | 515 BubbleDialogDelegateView::OnWidgetDestroying(widget); |
| 616 if (delegate_ && widget == GetWidget()) | 516 if (delegate_ && widget == GetWidget()) |
| 617 delegate_->ViewClosing(); | 517 delegate_->ViewClosing(); |
| 618 } | 518 } |
| 619 | 519 |
| 620 void AppListView::OnWidgetActivationChanged(views::Widget* widget, | |
| 621 bool active) { | |
| 622 // Do not called inherited function as the bubble delegate auto close | |
| 623 // functionality is not used. | |
| 624 if (widget == GetWidget()) { | |
| 625 for (auto& observer : observers_) | |
| 626 observer.OnActivationChanged(widget, active); | |
| 627 } | |
| 628 } | |
| 629 | |
| 630 void AppListView::OnWidgetVisibilityChanged(views::Widget* widget, | 520 void AppListView::OnWidgetVisibilityChanged(views::Widget* widget, |
| 631 bool visible) { | 521 bool visible) { |
| 632 BubbleDialogDelegateView::OnWidgetVisibilityChanged(widget, visible); | 522 BubbleDialogDelegateView::OnWidgetVisibilityChanged(widget, visible); |
| 633 | 523 |
| 634 if (widget != GetWidget()) | 524 if (widget != GetWidget()) |
| 635 return; | 525 return; |
| 636 | 526 |
| 637 if (!visible) | 527 if (!visible) |
| 638 app_list_main_view_->ResetForShow(); | 528 app_list_main_view_->ResetForShow(); |
| 639 } | 529 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 app_list_main_view_->SetVisible(true); | 590 app_list_main_view_->SetVisible(true); |
| 701 // Refocus the search box. However, if the app list widget does not have | 591 // Refocus the search box. However, if the app list widget does not have |
| 702 // focus, it means another window has already taken focus, and we *must not* | 592 // focus, it means another window has already taken focus, and we *must not* |
| 703 // focus the search box (or we would steal focus back into the app list). | 593 // focus the search box (or we would steal focus back into the app list). |
| 704 if (GetWidget()->IsActive()) | 594 if (GetWidget()->IsActive()) |
| 705 search_box_view_->search_box()->RequestFocus(); | 595 search_box_view_->search_box()->RequestFocus(); |
| 706 } | 596 } |
| 707 } | 597 } |
| 708 | 598 |
| 709 } // namespace app_list | 599 } // namespace app_list |
| OLD | NEW |