Commit 41a6fca4 authored by Tim Song's avatar Tim Song Committed by Commit Bot

app_list: Open app info dialog modally with AppList window as parent.

This fixes the problem of the launcher closing after clicking on the\
app info drop down menu item on ChromeOS.

Note this CL partially reverts the mash changes made in
https://chromium-review.googlesource.com/c/chromium/src/+/897470

TEST=unit test + manually verified
BUG=987304

Change-Id: If92559f5d205d41db94c63aaf01090011552ff2f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1726756
Commit-Queue: Tim Song <tengs@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683426}
parent 027bd952
...@@ -122,6 +122,27 @@ IN_PROC_BROWSER_TEST_F(AppListClientImplBrowserTest, UninstallApp) { ...@@ -122,6 +122,27 @@ IN_PROC_BROWSER_TEST_F(AppListClientImplBrowserTest, UninstallApp) {
EXPECT_TRUE(client->GetAppListWindow()); EXPECT_TRUE(client->GetAppListWindow());
} }
IN_PROC_BROWSER_TEST_F(AppListClientImplBrowserTest, ShowAppInfo) {
AppListClientImpl* client = AppListClientImpl::GetInstance();
const extensions::Extension* app = InstallPlatformApp("minimal");
// Bring up the app list.
EXPECT_FALSE(client->GetAppListWindow());
client->ShowAppList();
EXPECT_TRUE(client->GetAppListWindow());
EXPECT_TRUE(wm::GetTransientChildren(client->GetAppListWindow()).empty());
// Open the app info dialog.
base::RunLoop run_loop;
client->DoShowAppInfoFlow(profile(), app->id());
run_loop.RunUntilIdle();
EXPECT_FALSE(wm::GetTransientChildren(client->GetAppListWindow()).empty());
// The app list should not be dismissed when the dialog is shown.
EXPECT_TRUE(client->app_list_visible());
EXPECT_TRUE(client->GetAppListWindow());
}
// Test the CreateNewWindow function of the controller delegate. // Test the CreateNewWindow function of the controller delegate.
IN_PROC_BROWSER_TEST_F(AppListClientImplBrowserTest, CreateNewWindow) { IN_PROC_BROWSER_TEST_F(AppListClientImplBrowserTest, CreateNewWindow) {
AppListClientImpl* client = AppListClientImpl::GetInstance(); AppListClientImpl* client = AppListClientImpl::GetInstance();
......
...@@ -118,7 +118,8 @@ void AppListControllerDelegate::DoShowAppInfoFlow( ...@@ -118,7 +118,8 @@ void AppListControllerDelegate::DoShowAppInfoFlow(
const extensions::Extension* extension = const extensions::Extension* extension =
GetExtension(profile, extension_id); GetExtension(profile, extension_id);
DCHECK(extension); DCHECK(extension);
ShowAppInfoInAppList(bounds, profile, extension); ShowAppInfoInAppList(self->GetAppListWindow(), bounds, profile,
extension);
}, },
weak_ptr_factory_.GetWeakPtr(), profile, extension_id)); weak_ptr_factory_.GetWeakPtr(), profile, extension_id));
} }
......
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
#include "base/callback_forward.h" #include "base/callback_forward.h"
#include "chrome/common/buildflags.h" #include "chrome/common/buildflags.h"
#if BUILDFLAG(ENABLE_APP_LIST)
#include "ui/gfx/native_widget_types.h"
#endif
class Profile; class Profile;
namespace content { namespace content {
...@@ -37,7 +41,8 @@ bool CanShowAppInfoDialog(); ...@@ -37,7 +41,8 @@ bool CanShowAppInfoDialog();
#if BUILDFLAG(ENABLE_APP_LIST) #if BUILDFLAG(ENABLE_APP_LIST)
// Shows the chrome app information as a frameless window for the given |app| // Shows the chrome app information as a frameless window for the given |app|
// and |profile| at the given |app_info_bounds|. // and |profile| at the given |app_info_bounds|.
void ShowAppInfoInAppList(const gfx::Rect& app_info_bounds, void ShowAppInfoInAppList(gfx::NativeWindow parent,
const gfx::Rect& app_info_bounds,
Profile* profile, Profile* profile,
const extensions::Extension* app); const extensions::Extension* app);
#endif #endif
......
...@@ -45,21 +45,12 @@ ...@@ -45,21 +45,12 @@
#include "chrome/browser/ui/views/apps/app_info_dialog/arc_app_info_links_panel.h" #include "chrome/browser/ui/views/apps/app_info_dialog/arc_app_info_links_panel.h"
#endif #endif
#if BUILDFLAG(ENABLE_APP_LIST)
#include "ui/aura/window.h"
#endif
namespace { namespace {
// The color of the separator used inside the dialog - should match the app // The color of the separator used inside the dialog - should match the app
// list's app_list::kDialogSeparatorColor // list's app_list::kDialogSeparatorColor
constexpr SkColor kDialogSeparatorColor = SkColorSetRGB(0xD1, 0xD1, 0xD1); constexpr SkColor kDialogSeparatorColor = SkColorSetRGB(0xD1, 0xD1, 0xD1);
#if BUILDFLAG(ENABLE_APP_LIST)
// The elevation used for dialog shadow effect.
constexpr int kDialogShadowElevation = 24;
#endif
} // namespace } // namespace
bool CanShowAppInfoDialog() { bool CanShowAppInfoDialog() {
...@@ -71,20 +62,16 @@ bool CanShowAppInfoDialog() { ...@@ -71,20 +62,16 @@ bool CanShowAppInfoDialog() {
} }
#if BUILDFLAG(ENABLE_APP_LIST) #if BUILDFLAG(ENABLE_APP_LIST)
void ShowAppInfoInAppList(const gfx::Rect& app_info_bounds, void ShowAppInfoInAppList(gfx::NativeWindow parent,
const gfx::Rect& app_info_bounds,
Profile* profile, Profile* profile,
const extensions::Extension* app) { const extensions::Extension* app) {
views::DialogDelegate* dialog = CreateAppListContainerForView( views::DialogDelegate* dialog = CreateAppListContainerForView(
std::make_unique<AppInfoDialog>(profile, app)); std::make_unique<AppInfoDialog>(profile, app));
views::Widget* dialog_widget = new views::Widget();
views::Widget::InitParams params = views::Widget* dialog_widget =
views::DialogDelegate::GetDialogWidgetInitParams(dialog, nullptr, nullptr, constrained_window::CreateBrowserModalDialogViews(dialog, parent);
app_info_bounds); dialog_widget->SetBounds(app_info_bounds);
params.shadow_type = views::Widget::InitParams::SHADOW_TYPE_DEFAULT;
params.shadow_elevation = kDialogShadowElevation;
dialog_widget->Init(std::move(params));
// The title is not shown on the dialog, but it is used for overview mode.
dialog_widget->GetNativeWindow()->SetTitle(base::UTF8ToUTF16(app->name()));
dialog_widget->Show(); dialog_widget->Show();
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment