Skip to content

Commit

Permalink
app_list: migrate AppList UI into Ash.
Browse files Browse the repository at this point in the history
Design doc: go/mustash
Design doc: go/move-applist

AppList consists of two parts: Apps and Search. Everything is currently
initiated in Chrome. This commit does a few things:

- initiates all AppList UI in Ash;
- removes all AppList UI from Chrome;
- bridges Ash and Chrome with AppListController and AppListClient in
  //ash/public/interfaces/app_list.mojom;
- modifies all affected tests to apply to the new AppList architecture;
- cleans up old AppList stuff, e.g. AppList presenter mojo interfaces.

With this commit we're expecting:

- all AppList models, views are initiated in Ash;
- all other AppList logic, e.g. sync and search, still live in Chrome
  since they depend on user profile data;
- in Mus+Ash mode, where Ash and Chrome are two different processes, we
  have Search disabled;
- in classic mode, where Ash and Chrome are in the same process, we get
  SearchModel from Ash in Chrome and have Search enabled.

Bug: 733662
Change-Id: I0e1e04e832ba74f8328af40deabf930b53d70bdd
Reviewed-on: https://chromium-review.googlesource.com/954355
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Jiaquan He <hejq@google.com>
Cr-Commit-Position: refs/heads/master@{#542310}
  • Loading branch information
JiaquanHe authored and Commit Bot committed Mar 10, 2018
1 parent 23c607b commit 9898756
Show file tree
Hide file tree
Showing 80 changed files with 744 additions and 1,414 deletions.
4 changes: 2 additions & 2 deletions ash/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ component("ash") {
"animation/animation_change_type.h",
"app_list/app_list_controller_impl.cc",
"app_list/app_list_controller_impl.h",
"app_list/app_list_delegate_impl.cc",
"app_list/app_list_delegate_impl.h",
"app_list/app_list_presenter_delegate.cc",
"app_list/app_list_presenter_delegate.h",
"app_list/app_list_presenter_delegate_factory.cc",
"app_list/app_list_presenter_delegate_factory.h",
"app_list/app_list_presenter_impl.cc",
"app_list/app_list_presenter_impl.h",
"app_list/app_list_view_delegate_mash.cc",
"app_list/app_list_view_delegate_mash.h",
"ash_constants.cc",
Expand Down
6 changes: 3 additions & 3 deletions ash/accelerators/accelerator_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "ash/accelerators/accelerator_commands.h"
#include "ash/accelerators/debug_commands.h"
#include "ash/accessibility/accessibility_controller.h"
#include "ash/app_list/presenter/app_list.h"
#include "ash/app_list/app_list_controller_impl.h"
#include "ash/debug.h"
#include "ash/display/display_configuration_controller.h"
#include "ash/display/display_move_window_util.h"
Expand Down Expand Up @@ -504,7 +504,7 @@ void HandleToggleAppList(const ui::Accelerator& accelerator) {
if (accelerator.key_code() == ui::VKEY_LWIN)
base::RecordAction(UserMetricsAction("Accel_Search_LWin"));

Shell::Get()->app_list()->ToggleAppList(
Shell::Get()->app_list_controller()->ToggleAppList(
display::Screen::GetScreen()
->GetDisplayNearestWindow(Shell::GetRootWindowForNewWindows())
.id(),
Expand Down Expand Up @@ -690,7 +690,7 @@ void HandleToggleVoiceInteraction(const ui::Accelerator& accelerator) {
break;
}

Shell::Get()->app_list()->ToggleVoiceInteractionSession();
Shell::Get()->app_list_controller()->ToggleVoiceInteractionSession();
}

void HandleSuspend() {
Expand Down
2 changes: 0 additions & 2 deletions ash/accelerators/accelerator_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include "ash/accelerators/accelerator_table.h"
#include "ash/accessibility/accessibility_controller.h"
#include "ash/accessibility/test_accessibility_controller_client.h"
#include "ash/app_list/presenter/app_list.h"
#include "ash/app_list/presenter/test/test_app_list_presenter.h"
#include "ash/app_list/test/app_list_test_helper.h"
#include "ash/ime/ime_controller.h"
#include "ash/ime/test_ime_controller_client.h"
Expand Down
4 changes: 2 additions & 2 deletions ash/accelerators/accelerator_router.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "ash/accelerators/accelerator_router.h"

#include "ash/accelerators/accelerator_controller.h"
#include "ash/app_list/presenter/app_list.h"
#include "ash/app_list/app_list_controller_impl.h"
#include "ash/shell.h"
#include "ash/wm/window_state.h"
#include "base/metrics/histogram_macros.h"
Expand Down Expand Up @@ -131,7 +131,7 @@ bool AcceleratorRouter::ShouldProcessAcceleratorNow(
if (accelerator_controller->IsPreferred(accelerator))
return true;

return Shell::Get()->app_list()->GetTargetVisibility();
return Shell::Get()->app_list_controller()->GetTargetVisibility();
}

} // namespace ash
122 changes: 120 additions & 2 deletions ash/app_list/app_list_controller_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "ash/public/cpp/config.h"
#include "ash/shell.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "extensions/common/constants.h"
#include "ui/app_list/views/app_list_main_view.h"
#include "ui/app_list/views/app_list_view.h"
Expand Down Expand Up @@ -49,10 +50,14 @@ class ViewDelegateFactoryImpl : public app_list::AppListViewDelegateFactory {

namespace ash {

// TODO(hejq): Get rid of AppListPresenterDelegateFactory and pass in
// ash::AppListPresenterDelegate directly.
AppListControllerImpl::AppListControllerImpl()
: view_delegate_(this),
presenter_(std::make_unique<AppListPresenterDelegateFactory>(
std::make_unique<ViewDelegateFactoryImpl>(&view_delegate_))) {
presenter_(
std::make_unique<AppListPresenterDelegateFactory>(
std::make_unique<ViewDelegateFactoryImpl>(&view_delegate_)),
this) {
model_.AddObserver(this);
}

Expand Down Expand Up @@ -278,6 +283,119 @@ void AppListControllerImpl::OnAppListItemUpdated(app_list::AppListItem* item) {
client_->OnItemUpdated(item->CloneMetadata());
}

////////////////////////////////////////////////////////////////////////////////
// Methods used in Ash

bool AppListControllerImpl::GetTargetVisibility() const {
return presenter_.GetTargetVisibility();
}

bool AppListControllerImpl::IsVisible() const {
return presenter_.IsVisible();
}

void AppListControllerImpl::Show(int64_t display_id,
app_list::AppListShowSource show_source) {
UMA_HISTOGRAM_ENUMERATION(app_list::kAppListToggleMethodHistogram,
show_source, app_list::kMaxAppListToggleMethod);
presenter_.Show(display_id);
}

void AppListControllerImpl::UpdateYPositionAndOpacity(
int y_position_in_screen,
float background_opacity) {
presenter_.UpdateYPositionAndOpacity(y_position_in_screen,
background_opacity);
}

void AppListControllerImpl::EndDragFromShelf(
app_list::AppListViewState app_list_state) {
presenter_.EndDragFromShelf(app_list_state);
}

void AppListControllerImpl::ProcessMouseWheelEvent(
const ui::MouseWheelEvent& event) {
presenter_.ProcessMouseWheelOffset(event.offset().y());
}

void AppListControllerImpl::ToggleAppList(
int64_t display_id,
app_list::AppListShowSource show_source) {
if (!IsVisible()) {
UMA_HISTOGRAM_ENUMERATION(app_list::kAppListToggleMethodHistogram,
show_source, app_list::kMaxAppListToggleMethod);
}
presenter_.ToggleAppList(display_id);
}

app_list::AppListViewState AppListControllerImpl::GetAppListViewState() {
return model_.state_fullscreen();
}

void AppListControllerImpl::FlushForTesting() {
bindings_.FlushForTesting();
}

////////////////////////////////////////////////////////////////////////////////
// Methods of |client_|:

void AppListControllerImpl::StartSearch(const base::string16& raw_query) {
client_->StartSearch(raw_query);
}

void AppListControllerImpl::OpenSearchResult(const std::string& result_id,
int event_flags) {
client_->OpenSearchResult(result_id, event_flags);
}

void AppListControllerImpl::InvokeSearchResultAction(
const std::string& result_id,
int action_index,
int event_flags) {
client_->InvokeSearchResultAction(result_id, action_index, event_flags);
}

void AppListControllerImpl::ViewShown(int64_t display_id) {
client_->ViewShown(display_id);
}

void AppListControllerImpl::ViewClosing() {
client_->ViewClosing();
}

void AppListControllerImpl::ActivateItem(const std::string& id,
int event_flags) {
client_->ActivateItem(id, event_flags);
}

void AppListControllerImpl::GetContextMenuModel(
const std::string& id,
GetContextMenuModelCallback callback) {
client_->GetContextMenuModel(id, std::move(callback));
}

void AppListControllerImpl::ContextMenuItemSelected(const std::string& id,
int command_id,
int event_flags) {
client_->ContextMenuItemSelected(id, command_id, event_flags);
}

void AppListControllerImpl::OnVisibilityChanged(bool visible) {
client_->OnAppListVisibilityChanged(visible);
}

void AppListControllerImpl::OnTargetVisibilityChanged(bool visible) {
client_->OnAppListTargetVisibilityChanged(visible);
}

void AppListControllerImpl::StartVoiceInteractionSession() {
client_->StartVoiceInteractionSession();
}

void AppListControllerImpl::ToggleVoiceInteractionSession() {
client_->ToggleVoiceInteractionSession();
}

////////////////////////////////////////////////////////////////////////////////
// Private used only:

Expand Down
45 changes: 42 additions & 3 deletions ash/app_list/app_list_controller_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,22 @@
#include <string>
#include <vector>

#include "ash/app_list/app_list_presenter_impl.h"
#include "ash/app_list/app_list_view_delegate_mash.h"
#include "ash/app_list/model/app_list_model.h"
#include "ash/app_list/model/app_list_model_observer.h"
#include "ash/app_list/model/app_list_view_state.h"
#include "ash/app_list/model/search/search_model.h"
#include "ash/app_list/presenter/app_list_presenter_impl.h"
#include "ash/ash_export.h"
#include "ash/public/interfaces/app_list.mojom.h"
#include "components/sync/model/string_ordinal.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/interface_ptr_set.h"
#include "ui/app_list/app_list_view_delegate.h"
#include "ui/app_list/app_list_constants.h"

namespace ui {
class MouseWheelEvent;
} // namespace ui

namespace ash {

Expand All @@ -39,7 +44,6 @@ class ASH_EXPORT AppListControllerImpl : public mojom::AppListController,
app_list::AppListModel* model() { return &model_; }
app_list::SearchModel* search_model() { return &search_model_; }
app_list::AppListPresenterImpl* presenter() { return &presenter_; }
mojom::AppListClient* client() { return client_.get(); }

// mojom::AppListController:
void SetClient(mojom::AppListClientPtr client_ptr) override;
Expand Down Expand Up @@ -90,6 +94,41 @@ class ASH_EXPORT AppListControllerImpl : public mojom::AppListController,
void OnAppListItemWillBeDeleted(app_list::AppListItem* item) override;
void OnAppListItemUpdated(app_list::AppListItem* item) override;

// Methods used in ash:
bool GetTargetVisibility() const;
bool IsVisible() const;
void Show(int64_t display_id, app_list::AppListShowSource show_source);
void UpdateYPositionAndOpacity(int y_position_in_screen,
float background_opacity);
void EndDragFromShelf(app_list::AppListViewState app_list_state);
void ProcessMouseWheelEvent(const ui::MouseWheelEvent& event);
void ToggleAppList(int64_t display_id,
app_list::AppListShowSource show_source);
app_list::AppListViewState GetAppListViewState();

// Methods of |client_|:
void StartSearch(const base::string16& raw_query);
void OpenSearchResult(const std::string& result_id, int event_flags);
void InvokeSearchResultAction(const std::string& result_id,
int action_index,
int event_flags);
void ViewShown(int64_t display_id);
void ViewClosing();
void ActivateItem(const std::string& id, int event_flags);
using GetContextMenuModelCallback =
AppListViewDelegateMash::GetContextMenuModelCallback;
void GetContextMenuModel(const std::string& id,
GetContextMenuModelCallback callback);
void ContextMenuItemSelected(const std::string& id,
int command_id,
int event_flags);
void OnVisibilityChanged(bool visible);
void OnTargetVisibilityChanged(bool visible);
void StartVoiceInteractionSession();
void ToggleVoiceInteractionSession();

void FlushForTesting();

private:
syncer::StringOrdinal GetOemFolderPos();
std::unique_ptr<app_list::AppListItem> CreateAppListItem(
Expand Down
28 changes: 0 additions & 28 deletions ash/app_list/app_list_delegate_impl.cc

This file was deleted.

28 changes: 0 additions & 28 deletions ash/app_list/app_list_delegate_impl.h

This file was deleted.

2 changes: 1 addition & 1 deletion ash/app_list/app_list_presenter_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "ash/app_list/app_list_presenter_delegate.h"

#include "ash/app_list/presenter/app_list_presenter_impl.h"
#include "ash/app_list/app_list_presenter_impl.h"
#include "ash/app_list/presenter/app_list_view_delegate_factory.h"
#include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/shelf_types.h"
Expand Down
1 change: 1 addition & 0 deletions ash/app_list/app_list_presenter_delegate_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <memory>

#include "ash/app_list/app_list_presenter_impl.h"
#include "ash/app_list/model/app_list_view_state.h"
#include "ash/app_list/test/app_list_test_helper.h"
#include "ash/public/cpp/ash_switches.h"
Expand Down
Loading

0 comments on commit 9898756

Please sign in to comment.