diff options
author | calamity <calamity@chromium.org> | 2014-12-18 20:44:43 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-19 04:45:32 +0000 |
commit | 73c209621e823e68ef57a00bd15f5599bbf1ddd2 (patch) | |
tree | 7ac2231487cc9a1c48c2a83536a1da172fb44236 /chrome/browser | |
parent | 3bdc678e0725846de1761aa1cfd37f05ea110923 (diff) | |
download | chromium_src-73c209621e823e68ef57a00bd15f5599bbf1ddd2.zip chromium_src-73c209621e823e68ef57a00bd15f5599bbf1ddd2.tar.gz chromium_src-73c209621e823e68ef57a00bd15f5599bbf1ddd2.tar.bz2 |
Show the apps page on app install in experimental app list.
This CL fixes an issue where the experimental app list would pop up on
app install but be showing the start page rather than the apps page.
BUG=391348
Review URL: https://codereview.chromium.org/803933002
Cr-Commit-Position: refs/heads/master@{#309149}
Diffstat (limited to 'chrome/browser')
5 files changed, 87 insertions, 19 deletions
diff --git a/chrome/browser/ui/app_list/app_list_service_views.cc b/chrome/browser/ui/app_list/app_list_service_views.cc index 52dc016b..13770b2 100644 --- a/chrome/browser/ui/app_list/app_list_service_views.cc +++ b/chrome/browser/ui/app_list/app_list_service_views.cc @@ -6,6 +6,7 @@ #include "chrome/browser/apps/scoped_keep_alive.h" #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" +#include "ui/app_list/app_list_switches.h" #include "ui/app_list/views/app_list_main_view.h" #include "ui/app_list/views/app_list_view.h" #include "ui/app_list/views/contents_view.h" @@ -33,6 +34,16 @@ void AppListServiceViews::ShowForProfile(Profile* requested_profile) { app_list::AppListModel::INVALID_STATE); } +void AppListServiceViews::ShowForAppInstall(Profile* profile, + const std::string& extension_id, + bool start_discovery_tracking) { + if (app_list::switches::IsExperimentalAppListEnabled()) + ShowForProfileInternal(profile, app_list::AppListModel::STATE_APPS); + + AppListServiceImpl::ShowForAppInstall(profile, extension_id, + start_discovery_tracking); +} + void AppListServiceViews::ShowForCustomLauncherPage(Profile* profile) { ShowForProfileInternal(profile, app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE); diff --git a/chrome/browser/ui/app_list/app_list_service_views.h b/chrome/browser/ui/app_list/app_list_service_views.h index 5724d74..60cd10a 100644 --- a/chrome/browser/ui/app_list/app_list_service_views.h +++ b/chrome/browser/ui/app_list/app_list_service_views.h @@ -34,6 +34,9 @@ class AppListServiceViews : public AppListServiceImpl, // AppListService overrides: void Init(Profile* initial_profile) override; void ShowForProfile(Profile* requested_profile) override; + void ShowForAppInstall(Profile* profile, + const std::string& extension_id, + bool start_discovery_tracking) override; void ShowForCustomLauncherPage(Profile* profile) override; void DismissAppList() override; bool IsAppListVisible() const override; diff --git a/chrome/browser/ui/app_list/app_list_service_views_browsertest.cc b/chrome/browser/ui/app_list/app_list_service_views_browsertest.cc index 44ab3bb..b9ad2cb5 100644 --- a/chrome/browser/ui/app_list/app_list_service_views_browsertest.cc +++ b/chrome/browser/ui/app_list/app_list_service_views_browsertest.cc @@ -17,7 +17,9 @@ #include "content/public/browser/notification_service.h" #include "content/public/test/test_utils.h" #include "ui/app_list/app_list_switches.h" +#include "ui/app_list/views/app_list_main_view.h" #include "ui/app_list/views/app_list_view.h" +#include "ui/app_list/views/contents_view.h" #include "ui/events/test/event_generator.h" #include "ui/views/widget/widget.h" @@ -122,7 +124,7 @@ IN_PROC_BROWSER_TEST_F(AppListServiceViewsBrowserTest, AcceleratorClose) { // Browser Test for AppListController that ensures the App Info dialog opens // correctly. -typedef ExtensionBrowserTest AppListControllerAppInfoDialogBrowserTest; +using AppListControllerAppInfoDialogBrowserTest = ExtensionBrowserTest; // Test the DoShowAppInfoFlow function of the controller delegate. // flaky: http://crbug.com/378251 @@ -175,3 +177,31 @@ IN_PROC_BROWSER_TEST_F(AppListControllerAppInfoDialogBrowserTest, EXPECT_EQ(0U, owned_widgets.size()); EXPECT_FALSE(test_api.is_overlay_visible()); } + +using AppListServiceViewsExtensionBrowserTest = ExtensionBrowserTest; + +IN_PROC_BROWSER_TEST_F(AppListServiceViewsExtensionBrowserTest, + ShowForAppInstall) { + // Install an extension to open the dialog for. + base::FilePath test_extension_path; + ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_extension_path)); + test_extension_path = test_extension_path.AppendASCII("extensions") + .AppendASCII("platform_apps") + .AppendASCII("minimal"); + const extensions::Extension* extension = InstallExtension( + test_extension_path, 1 /* expected_change: new install */); + ASSERT_TRUE(extension); + + // Open the app list window for the app. + AppListService* service = test::GetAppListService(); + EXPECT_FALSE(service->GetAppListWindow()); + + service->ShowForAppInstall(browser()->profile(), extension->id(), false); + app_list::AppListView* app_list_view = GetAppListView(service); + ASSERT_TRUE(app_list_view); + + app_list::ContentsView* contents_view = + app_list_view->app_list_main_view()->contents_view(); + + EXPECT_TRUE(contents_view->IsStateActive(app_list::AppListModel::STATE_APPS)); +} diff --git a/chrome/browser/ui/ash/app_list/app_list_service_ash.cc b/chrome/browser/ui/ash/app_list/app_list_service_ash.cc index c8036ab..0034b57 100644 --- a/chrome/browser/ui/ash/app_list/app_list_service_ash.cc +++ b/chrome/browser/ui/ash/app_list/app_list_service_ash.cc @@ -10,7 +10,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/ash/app_list/app_list_controller_ash.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" -#include "ui/app_list/app_list_model.h" +#include "ui/app_list/app_list_switches.h" #include "ui/app_list/views/app_list_main_view.h" #include "ui/app_list/views/app_list_view.h" #include "ui/app_list/views/contents_view.h" @@ -28,19 +28,8 @@ AppListServiceAsh::AppListServiceAsh() AppListServiceAsh::~AppListServiceAsh() { } -base::FilePath AppListServiceAsh::GetProfilePath( - const base::FilePath& user_data_dir) { - return ChromeLauncherController::instance()->profile()->GetPath(); -} - -void AppListServiceAsh::ShowForProfile(Profile* default_profile) { - // This may not work correctly if the profile passed in is different from the - // one the ash Shell is currently using. - // TODO(ananta): Handle profile changes correctly when !defined(OS_CHROMEOS). - ash::Shell::GetInstance()->ShowAppList(NULL); -} - -void AppListServiceAsh::ShowForCustomLauncherPage(Profile* profile) { +void AppListServiceAsh::ShowAndSwitchToState( + app_list::AppListModel::State state) { bool app_list_was_open = true; app_list::AppListView* app_list_view = ash::Shell::GetInstance()->GetAppListView(); @@ -54,12 +43,39 @@ void AppListServiceAsh::ShowForCustomLauncherPage(Profile* profile) { DCHECK(app_list_view); } + if (state == app_list::AppListModel::INVALID_STATE) + return; + app_list::ContentsView* contents_view = app_list_view->app_list_main_view()->contents_view(); - contents_view->SetActivePage( - contents_view->GetPageIndexForState( - app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE), - app_list_was_open /* animate */); + contents_view->SetActivePage(contents_view->GetPageIndexForState(state), + app_list_was_open /* animate */); +} + +base::FilePath AppListServiceAsh::GetProfilePath( + const base::FilePath& user_data_dir) { + return ChromeLauncherController::instance()->profile()->GetPath(); +} + +void AppListServiceAsh::ShowForProfile(Profile* /*default_profile*/) { + // This may not work correctly if the profile passed in is different from the + // one the ash Shell is currently using. + // TODO(ananta): Handle profile changes correctly when !defined(OS_CHROMEOS). + ash::Shell::GetInstance()->ShowAppList(NULL); +} + +void AppListServiceAsh::ShowForAppInstall(Profile* profile, + const std::string& extension_id, + bool start_discovery_tracking) { + if (app_list::switches::IsExperimentalAppListEnabled()) + ShowAndSwitchToState(app_list::AppListModel::STATE_APPS); + + AppListServiceImpl::ShowForAppInstall(profile, extension_id, + start_discovery_tracking); +} + +void AppListServiceAsh::ShowForCustomLauncherPage(Profile* /*profile*/) { + ShowAndSwitchToState(app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE); } bool AppListServiceAsh::IsAppListVisible() const { diff --git a/chrome/browser/ui/ash/app_list/app_list_service_ash.h b/chrome/browser/ui/ash/app_list/app_list_service_ash.h index 69141ed..3f5d198 100644 --- a/chrome/browser/ui/ash/app_list/app_list_service_ash.h +++ b/chrome/browser/ui/ash/app_list/app_list_service_ash.h @@ -7,6 +7,7 @@ #include "base/memory/scoped_ptr.h" #include "chrome/browser/ui/app_list/app_list_service_impl.h" +#include "ui/app_list/app_list_model.h" class AppListControllerDelegateAsh; template <typename T> struct DefaultSingletonTraits; @@ -23,9 +24,16 @@ class AppListServiceAsh : public AppListServiceImpl { AppListServiceAsh(); ~AppListServiceAsh() override; + // Shows the app list if it isn't already showing and Switches to |state|, + // unless it is |INVALID_STATE| (in which case, opens on the default state). + void ShowAndSwitchToState(app_list::AppListModel::State state); + // AppListService overrides: base::FilePath GetProfilePath(const base::FilePath& user_data_dir) override; void ShowForProfile(Profile* default_profile) override; + void ShowForAppInstall(Profile* profile, + const std::string& extension_id, + bool start_discovery_tracking) override; void ShowForCustomLauncherPage(Profile* profile) override; bool IsAppListVisible() const override; void DismissAppList() override; |