Chromium Code Reviews| Index: chrome/browser/ui/ash/app_list/app_list_presenter_delegate_mus.cc |
| diff --git a/chrome/browser/ui/ash/app_list/app_list_presenter_delegate_mus.cc b/chrome/browser/ui/ash/app_list/app_list_presenter_delegate_mus.cc |
| index 979835f6d280510c829273f5b88028e2293c454f..c6d902ed60f388f5a8d7b630d51cc55a0f99fa30 100644 |
| --- a/chrome/browser/ui/ash/app_list/app_list_presenter_delegate_mus.cc |
| +++ b/chrome/browser/ui/ash/app_list/app_list_presenter_delegate_mus.cc |
| @@ -4,10 +4,13 @@ |
| #include "chrome/browser/ui/ash/app_list/app_list_presenter_delegate_mus.h" |
| +#include "ui/app_list/presenter/app_list_presenter.h" |
| #include "ui/app_list/presenter/app_list_view_delegate_factory.h" |
| #include "ui/app_list/views/app_list_view.h" |
| #include "ui/display/display.h" |
| #include "ui/display/screen.h" |
| +#include "ui/views/mus/pointer_watcher_event_router.h" |
| +#include "ui/views/mus/window_manager_connection.h" |
| namespace { |
| @@ -36,10 +39,26 @@ gfx::Point GetCenterOfDisplay(int64_t display_id, int minimum_height) { |
| } // namespace |
| AppListPresenterDelegateMus::AppListPresenterDelegateMus( |
| + app_list::AppListPresenter* presenter, |
| app_list::AppListViewDelegateFactory* view_delegate_factory) |
| - : view_delegate_factory_(view_delegate_factory) {} |
| + : presenter_(presenter), view_delegate_factory_(view_delegate_factory) { |
| + if (!is_visible_) { |
|
mfomitchev
2016/09/30 18:41:19
This will always be true
thanhph
2016/09/30 19:03:52
reverted
|
| + views::WindowManagerConnection::Get() |
|
mfomitchev
2016/09/30 18:41:19
Shouldn't do this here, the idea was to not regist
thanhph
2016/09/30 19:03:52
reverted
|
| + ->pointer_watcher_event_router() |
| + ->AddPointerWatcher(this, false); |
| + is_visible_ = true; |
|
mfomitchev
2016/09/30 18:41:19
Why?
thanhph
2016/09/30 19:03:52
reverted
|
| + } |
| +} |
| + |
| +AppListPresenterDelegateMus::~AppListPresenterDelegateMus() { |
| + if (is_visible_) { |
| + views::WindowManagerConnection::Get() |
| + ->pointer_watcher_event_router() |
| + ->RemovePointerWatcher(this); |
| -AppListPresenterDelegateMus::~AppListPresenterDelegateMus() {} |
| + is_visible_ = false; |
|
mfomitchev
2016/09/30 18:41:19
We don't need to update is_visible_ when destroyin
thanhph
2016/09/30 19:03:52
reverted
|
| + } |
| +} |
| app_list::AppListViewDelegate* AppListPresenterDelegateMus::GetViewDelegate() { |
| return view_delegate_factory_->GetDelegate(); |
| @@ -66,29 +85,49 @@ void AppListPresenterDelegateMus::Init(app_list::AppListView* view, |
| GetCenterOfDisplay(display_id, GetMinimumBoundsHeightForAppList(view))); |
| // TODO(mfomitchev): Setup updating bounds on keyboard bounds change. |
| - // TODO(mfomitchev): Setup dismissing on mouse/touch gesture anywhere outside |
| - // the bounds of the app list. |
| // TODO(mfomitchev): Setup dismissing on maximize (touch-view) mode start/end. |
| // TODO(mfomitchev): Setup DnD. |
| // TODO(mfomitchev): UpdateAutoHideState for shelf |
| } |
| void AppListPresenterDelegateMus::OnShown(int64_t display_id) { |
| - is_visible_ = true; |
| + if (!is_visible_) { |
|
mfomitchev
2016/09/30 18:41:19
I don't think OnShown can ever be called when is_v
thanhph
2016/09/30 19:03:52
reverted
|
| + views::WindowManagerConnection::Get() |
| + ->pointer_watcher_event_router() |
| + ->AddPointerWatcher(this, false); |
| + is_visible_ = true; |
| + } |
| } |
| void AppListPresenterDelegateMus::OnDismissed() { |
| - DCHECK(is_visible_); |
| - is_visible_ = false; |
| + if (is_visible_) { |
|
mfomitchev
2016/09/30 18:41:19
Why did you replace DCHECK with if? OnDismissed sh
thanhph
2016/09/30 19:03:52
Good to know this. Thanks!
|
| + views::WindowManagerConnection::Get() |
| + ->pointer_watcher_event_router() |
| + ->RemovePointerWatcher(this); |
| + is_visible_ = false; |
| + } |
| } |
| void AppListPresenterDelegateMus::UpdateBounds() { |
| if (!view_ || !is_visible_) |
| return; |
| - |
| view_->UpdateBounds(); |
| } |
| +void AppListPresenterDelegateMus::OnPointerEventObserved( |
|
mfomitchev
2016/09/30 18:41:19
Nit: Move this method to after GetVisibilityAnimat
thanhph
2016/09/30 19:03:52
done!
|
| + const ui::PointerEvent& event, |
| + const gfx::Point& location_in_screen, |
| + views::Widget* target) { |
| + DCHECK(is_visible_); |
| + |
| + // Dismiss app list on a mouse click or touch outside of the app list window. |
| + if (event.type() == ui::ET_TOUCH_PRESSED || |
| + event.type() == ui::ET_POINTER_DOWN) { |
| + if (!target || target != view_->GetWidget()) |
| + presenter_->Dismiss(); |
| + } |
| +} |
| + |
| gfx::Vector2d AppListPresenterDelegateMus::GetVisibilityAnimationOffset( |
| aura::Window* root_window) { |
| // TODO(mfomitchev): Classic ash does different animation here depending on |