Commit 3d019d5f authored by Jiaquan He's avatar Jiaquan He Committed by Commit Bot

app_list: decouple AppListService from mac.

AppList will be available only with Ash.

Some mac machines still have apps shortcut in the dock, and Apple do not
have an API to remove things from the Dock. This commit hard codes the
shim handler into AppShimHandler so that we can clean up AppListService
classes.

This commit:
- moves InitAppsPageLegacyShimHandler for mac out of AppListService;
- removes references to AppListService from mac.

Bug: 733662
Change-Id: I66bca8851bf2427a5cd16f3046680e304d1ee368
Reviewed-on: https://chromium-review.googlesource.com/963684Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Commit-Queue: Jiaquan He <hejq@google.com>
Cr-Commit-Position: refs/heads/master@{#543863}
parent 7214884d
...@@ -12,6 +12,8 @@ source_set("app_shim") { ...@@ -12,6 +12,8 @@ source_set("app_shim") {
"app_shim_host_mac.h", "app_shim_host_mac.h",
"app_shim_host_manager_mac.h", "app_shim_host_manager_mac.h",
"app_shim_host_manager_mac.mm", "app_shim_host_manager_mac.mm",
"apps_page_shim_handler.h",
"apps_page_shim_handler.mm",
"extension_app_shim_handler_mac.cc", "extension_app_shim_handler_mac.cc",
"extension_app_shim_handler_mac.h", "extension_app_shim_handler_mac.h",
"unix_domain_socket_acceptor.cc", "unix_domain_socket_acceptor.cc",
......
...@@ -13,10 +13,11 @@ ...@@ -13,10 +13,11 @@
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/apps/app_shim/apps_page_shim_handler.h"
#include "chrome/browser/apps/app_window_registry_util.h" #include "chrome/browser/apps/app_window_registry_util.h"
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/ui/app_list/app_list_service.h" #include "chrome/common/mac/app_mode_common.h"
#include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
...@@ -28,7 +29,7 @@ namespace { ...@@ -28,7 +29,7 @@ namespace {
void TerminateIfNoAppWindows() { void TerminateIfNoAppWindows() {
bool app_windows_left = bool app_windows_left =
AppWindowRegistryUtil::IsAppWindowVisibleInAnyProfile(0); AppWindowRegistryUtil::IsAppWindowVisibleInAnyProfile(0);
if (!app_windows_left && !AppListService::Get()->IsAppListVisible()) { if (!app_windows_left) {
chrome::AttemptExit(); chrome::AttemptExit();
} }
} }
...@@ -91,6 +92,7 @@ class AppShimHandlerRegistry : public content::NotificationObserver { ...@@ -91,6 +92,7 @@ class AppShimHandlerRegistry : public content::NotificationObserver {
registrar_.Add( registrar_.Add(
this, chrome::NOTIFICATION_BROWSER_CLOSE_CANCELLED, this, chrome::NOTIFICATION_BROWSER_CLOSE_CANCELLED,
content::NotificationService::AllBrowserContextsAndSources()); content::NotificationService::AllBrowserContextsAndSources());
SetForAppMode(app_mode::kAppListModeId, &apps_page_shim_handler_);
} }
~AppShimHandlerRegistry() override {} ~AppShimHandlerRegistry() override {}
...@@ -114,6 +116,7 @@ class AppShimHandlerRegistry : public content::NotificationObserver { ...@@ -114,6 +116,7 @@ class AppShimHandlerRegistry : public content::NotificationObserver {
HandlerMap handlers_; HandlerMap handlers_;
AppShimHandler* default_handler_; AppShimHandler* default_handler_;
AppsPageShimHandler apps_page_shim_handler_;
content::NotificationRegistrar registrar_; content::NotificationRegistrar registrar_;
bool browser_session_running_; bool browser_session_running_;
......
// Copyright 2016 The Chromium Authors. All rights reserved. // Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/ui/app_list/app_list_service_disabled_mac.h" #ifndef CHROME_BROWSER_APPS_APP_SHIM_APPS_PAGE_SHIM_HANDLER_H_
#define CHROME_BROWSER_APPS_APP_SHIM_APPS_PAGE_SHIM_HANDLER_H_
#include "base/compiler_specific.h" #include <vector>
#import "base/mac/foundation_util.h"
#import "chrome/browser/app_controller_mac.h"
#include "chrome/browser/apps/app_shim/app_shim_handler_mac.h"
#include "chrome/common/mac/app_mode_common.h"
namespace { #include "base/macros.h"
#include "chrome/browser/apps/app_shim/app_shim_handler_mac.h"
// Stub handler for the old app_list shim that opens chrome://apps when a copy // Stub handler for the old app_list shim that opens chrome://apps when a copy
// of the App Launcher .app bundle created with Chrome < m52 tries to connect. // of the App Launcher .app bundle created with Chrome < m52 tries to connect.
class AppsPageShimHandler : public apps::AppShimHandler { class AppsPageShimHandler : public apps::AppShimHandler {
public: public:
explicit AppsPageShimHandler(void (*action)(Profile*)) : action_(action) {} AppsPageShimHandler() {}
private:
// AppShimHandler: // AppShimHandler:
void OnShimLaunch(apps::AppShimHandler::Host* host, void OnShimLaunch(apps::AppShimHandler::Host* host,
apps::AppShimLaunchType launch_type, apps::AppShimLaunchType launch_type,
const std::vector<base::FilePath>& files) override { const std::vector<base::FilePath>& files) override;
AppController* controller = void OnShimClose(apps::AppShimHandler::Host* host) override;
base::mac::ObjCCastStrict<AppController>([NSApp delegate]);
action_([controller lastProfile]);
// Always close the shim process immediately.
host->OnAppLaunchComplete(apps::APP_SHIM_LAUNCH_DUPLICATE_HOST);
}
void OnShimClose(apps::AppShimHandler::Host* host) override {}
void OnShimFocus(apps::AppShimHandler::Host* host, void OnShimFocus(apps::AppShimHandler::Host* host,
apps::AppShimFocusType focus_type, apps::AppShimFocusType focus_type,
const std::vector<base::FilePath>& files) override {} const std::vector<base::FilePath>& files) override;
void OnShimSetHidden(apps::AppShimHandler::Host* host, bool hidden) override { void OnShimSetHidden(apps::AppShimHandler::Host* host, bool hidden) override;
} void OnShimQuit(apps::AppShimHandler::Host* host) override;
void OnShimQuit(apps::AppShimHandler::Host* host) override {}
void (*action_)(Profile*);
private:
DISALLOW_COPY_AND_ASSIGN(AppsPageShimHandler); DISALLOW_COPY_AND_ASSIGN(AppsPageShimHandler);
}; };
} // namespace #endif // CHROME_BROWSER_APPS_APP_SHIM_APPS_PAGE_SHIM_HANDLER_H_
void InitAppsPageLegacyShimHandler(void (*action)(Profile*)) {
static AppsPageShimHandler* handler = nullptr;
if (!handler) {
handler = new AppsPageShimHandler(action);
apps::AppShimHandler::RegisterHandler(app_mode::kAppListModeId, handler);
}
}
// Copyright 2013 The Chromium Authors. All rights reserved. // Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "base/files/file_path.h" #include "chrome/browser/apps/app_shim/apps_page_shim_handler.h"
#include "base/macros.h"
#include "base/memory/singleton.h"
#include "build/build_config.h"
#include "chrome/browser/ui/app_list/app_list_service.h"
#if defined(TOOLKIT_VIEWS) #import "base/mac/foundation_util.h"
#include "base/command_line.h" #import "chrome/browser/app_controller_mac.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_attributes_entry.h" #include "chrome/browser/profiles/profile_attributes_entry.h"
#include "chrome/browser/profiles/profile_attributes_storage.h" #include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
...@@ -22,58 +19,9 @@ ...@@ -22,58 +19,9 @@
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "ui/base/page_transition_types.h" #include "ui/base/page_transition_types.h"
#endif
#if defined(OS_MACOSX)
#include "chrome/browser/ui/app_list/app_list_service_disabled_mac.h"
#endif
namespace { namespace {
class AppListServiceDisabled : public AppListService {
public:
static AppListServiceDisabled* GetInstance() {
return base::Singleton<
AppListServiceDisabled,
base::LeakySingletonTraits<AppListServiceDisabled>>::get();
}
private:
friend struct base::DefaultSingletonTraits<AppListServiceDisabled>;
AppListServiceDisabled() {}
// AppListService overrides:
void SetAppListNextPaintCallback(void (*callback)()) override {}
void Init(Profile* initial_profile) override {}
base::FilePath GetProfilePath(const base::FilePath& user_data_dir) override {
return base::FilePath();
}
void SetProfilePath(const base::FilePath& profile_path) override {}
void Show() override {}
void ShowForProfile(Profile* profile) override {}
void ShowForAppInstall(Profile* profile,
const std::string& extension_id,
bool start_discovery_tracking) override {}
void DismissAppList() override {}
Profile* GetCurrentAppListProfile() override { return nullptr; }
bool IsAppListVisible() const override { return false; }
bool GetTargetVisibility() const override { return false; }
void EnableAppList(Profile* initial_profile,
AppListEnableSource enable_source) override {}
AppListControllerDelegate* GetControllerDelegate() override {
return nullptr;
}
void CreateShortcut() override {}
void FlushForTesting() override {}
DISALLOW_COPY_AND_ASSIGN(AppListServiceDisabled);
};
#if defined(TOOLKIT_VIEWS)
bool IsProfileSignedOut(Profile* profile) { bool IsProfileSignedOut(Profile* profile) {
ProfileAttributesEntry* entry; ProfileAttributesEntry* entry;
bool has_entry = bool has_entry =
...@@ -101,29 +49,29 @@ void OpenAppsPage(Profile* fallback_profile) { ...@@ -101,29 +49,29 @@ void OpenAppsPage(Profile* fallback_profile) {
ui::PAGE_TRANSITION_AUTO_BOOKMARK); ui::PAGE_TRANSITION_AUTO_BOOKMARK);
Navigate(&params); Navigate(&params);
} }
#endif
} // namespace } // namespace
// static void AppsPageShimHandler::OnShimLaunch(
AppListService* AppListService::Get() { apps::AppShimHandler::Host* host,
return AppListServiceDisabled::GetInstance(); apps::AppShimLaunchType launch_type,
const std::vector<base::FilePath>& files) {
AppController* controller =
base::mac::ObjCCastStrict<AppController>([NSApp delegate]);
OpenAppsPage([controller lastProfile]);
// Always close the shim process immediately.
host->OnAppLaunchComplete(apps::APP_SHIM_LAUNCH_DUPLICATE_HOST);
} }
// static void AppsPageShimHandler::OnShimClose(apps::AppShimHandler::Host* host) {}
void AppListService::RegisterPrefs(PrefRegistrySimple* registry) {}
// static void AppsPageShimHandler::OnShimFocus(
bool AppListService::HandleLaunchCommandLine( apps::AppShimHandler::Host* host,
const base::CommandLine& command_line, apps::AppShimFocusType focus_type,
Profile* launch_profile) { const std::vector<base::FilePath>& files) {}
#if defined(TOOLKIT_VIEWS)
if (!command_line.HasSwitch(switches::kShowAppList))
return false;
OpenAppsPage(launch_profile); void AppsPageShimHandler::OnShimSetHidden(apps::AppShimHandler::Host* host,
return true; bool hidden) {}
#else
return false; void AppsPageShimHandler::OnShimQuit(apps::AppShimHandler::Host* host) {}
#endif
}
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <stddef.h> #include <stddef.h>
#include <utility> #include <utility>
#include <vector>
#include "base/bind.h" #include "base/bind.h"
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
...@@ -22,7 +23,6 @@ ...@@ -22,7 +23,6 @@
#include "chrome/browser/extensions/install_tracker.h" #include "chrome/browser/extensions/install_tracker.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/ui/app_list/app_list_service.h"
#include "chrome/browser/ui/app_list/app_list_util.h" #include "chrome/browser/ui/app_list/app_list_util.h"
#include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
...@@ -496,9 +496,8 @@ WebstorePrivateEnableAppLauncherFunction:: ...@@ -496,9 +496,8 @@ WebstorePrivateEnableAppLauncherFunction::
ExtensionFunction::ResponseAction ExtensionFunction::ResponseAction
WebstorePrivateEnableAppLauncherFunction::Run() { WebstorePrivateEnableAppLauncherFunction::Run() {
AppListService* app_list_service = AppListService::Get(); // TODO(crbug.com/822900): Check if this API is still in use and whether we
app_list_service->EnableAppList(chrome_details_.GetProfile(), // can remove it.
AppListService::ENABLE_VIA_WEBSTORE_LINK);
return RespondNow(NoArguments()); return RespondNow(NoArguments());
} }
......
...@@ -54,7 +54,6 @@ ...@@ -54,7 +54,6 @@
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/task_manager/task_manager_interface.h" #include "chrome/browser/task_manager/task_manager_interface.h"
#include "chrome/browser/tracing/chrome_tracing_delegate.h" #include "chrome/browser/tracing/chrome_tracing_delegate.h"
#include "chrome/browser/ui/app_list/app_list_service.h"
#include "chrome/browser/ui/blocked_content/safe_browsing_triggered_popup_blocker.h" #include "chrome/browser/ui/blocked_content/safe_browsing_triggered_popup_blocker.h"
#include "chrome/browser/ui/browser_ui_prefs.h" #include "chrome/browser/ui/browser_ui_prefs.h"
#include "chrome/browser/ui/navigation_correction_tab_observer.h" #include "chrome/browser/ui/navigation_correction_tab_observer.h"
...@@ -349,7 +348,6 @@ void RegisterProfilePrefsForMigration( ...@@ -349,7 +348,6 @@ void RegisterProfilePrefsForMigration(
void RegisterLocalState(PrefRegistrySimple* registry) { void RegisterLocalState(PrefRegistrySimple* registry) {
// Please keep this list alphabetized. // Please keep this list alphabetized.
AppListService::RegisterPrefs(registry);
browser_shutdown::RegisterPrefs(registry); browser_shutdown::RegisterPrefs(registry);
BrowserProcessImpl::RegisterPrefs(registry); BrowserProcessImpl::RegisterPrefs(registry);
ChromeContentBrowserClient::RegisterLocalStatePrefs(registry); ChromeContentBrowserClient::RegisterLocalStatePrefs(registry);
......
...@@ -3609,13 +3609,6 @@ split_static_library("ui") { ...@@ -3609,13 +3609,6 @@ split_static_library("ui") {
] ]
deps += [ "//mash/common" ] deps += [ "//mash/common" ]
} }
} else {
sources += [
"app_list/app_list_service.h",
"app_list/app_list_service_disabled.cc",
"app_list/app_list_service_disabled_mac.h",
"app_list/app_list_service_disabled_mac.mm",
]
} }
if (enable_extensions) { if (enable_extensions) {
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include "chrome/browser/profiles/profile_io_data.h" #include "chrome/browser/profiles/profile_io_data.h"
#include "chrome/browser/sessions/session_service.h" #include "chrome/browser/sessions/session_service.h"
#include "chrome/browser/sessions/session_service_factory.h" #include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/ui/app_list/app_list_service.h"
#include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
...@@ -374,9 +373,6 @@ bool StartupBrowserCreatorImpl::Launch(Profile* profile, ...@@ -374,9 +373,6 @@ bool StartupBrowserCreatorImpl::Launch(Profile* profile,
DCHECK(profile); DCHECK(profile);
profile_ = profile; profile_ = profile;
if (AppListService::HandleLaunchCommandLine(command_line_, profile))
return true;
if (command_line_.HasSwitch(switches::kAppId)) { if (command_line_.HasSwitch(switches::kAppId)) {
std::string app_id = command_line_.GetSwitchValueASCII(switches::kAppId); std::string app_id = command_line_.GetSwitchValueASCII(switches::kAppId);
const Extension* extension = GetPlatformApp(profile, app_id); const Extension* extension = GetPlatformApp(profile, app_id);
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include "chrome/browser/profiles/profiles_state.h" #include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/signin/local_auth.h" #include "chrome/browser/signin/local_auth.h"
#include "chrome/browser/signin/signin_util.h" #include "chrome/browser/signin/signin_util.h"
#include "chrome/browser/ui/app_list/app_list_service.h"
#include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_finder.h"
...@@ -167,8 +166,8 @@ void UrlHashHelper::OnBrowserRemoved(Browser* browser) { ...@@ -167,8 +166,8 @@ void UrlHashHelper::OnBrowserRemoved(Browser* browser) {
void UrlHashHelper::ExecuteUrlHash() { void UrlHashHelper::ExecuteUrlHash() {
if (hash_ == profiles::kUserManagerSelectProfileAppLauncher) { if (hash_ == profiles::kUserManagerSelectProfileAppLauncher) {
AppListService* app_list_service = AppListService::Get(); // TODO(crbug/821659): Clean up the desktop UserManager webui.
app_list_service->ShowForProfile(profile_); NOTIMPLEMENTED();
return; return;
} }
......
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/shell_integration.h" #include "chrome/browser/shell_integration.h"
#include "chrome/browser/ui/app_list/app_list_service.h"
#include "chrome/common/channel_info.h" #include "chrome/common/channel_info.h"
#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
...@@ -287,12 +286,9 @@ void UpdateAndLaunchShim(std::unique_ptr<web_app::ShortcutInfo> shortcut_info) { ...@@ -287,12 +286,9 @@ void UpdateAndLaunchShim(std::unique_ptr<web_app::ShortcutInfo> shortcut_info) {
void RebuildAppAndLaunch(std::unique_ptr<web_app::ShortcutInfo> shortcut_info) { void RebuildAppAndLaunch(std::unique_ptr<web_app::ShortcutInfo> shortcut_info) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (shortcut_info->extension_id == app_mode::kAppListModeId) { // TODO(crbug/821659): Clean up the desktop UserManager webui.
AppListService* app_list_service = AppListService::Get(); if (shortcut_info->extension_id == app_mode::kAppListModeId)
app_list_service->CreateShortcut();
app_list_service->Show();
return; return;
}
ProfileManager* profile_manager = g_browser_process->profile_manager(); ProfileManager* profile_manager = g_browser_process->profile_manager();
Profile* profile = Profile* profile =
......
...@@ -5,11 +5,16 @@ ...@@ -5,11 +5,16 @@
#ifndef CHROME_COMMON_MAC_APP_MODE_COMMON_H_ #ifndef CHROME_COMMON_MAC_APP_MODE_COMMON_H_
#define CHROME_COMMON_MAC_APP_MODE_COMMON_H_ #define CHROME_COMMON_MAC_APP_MODE_COMMON_H_
#import <Foundation/Foundation.h> #include <CoreServices/CoreServices.h>
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#ifdef __OBJC__
@class NSString;
#else
class NSString;
#endif
// This file contains constants, interfaces, etc. which are common to the // This file contains constants, interfaces, etc. which are common to the
// browser application and the app mode loader (a.k.a. shim). // browser application and the app mode loader (a.k.a. shim).
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "chrome/common/mac/app_mode_common.h" #include "chrome/common/mac/app_mode_common.h"
#import <Foundation/Foundation.h>
#include "base/files/file_util.h" #include "base/files/file_util.h"
namespace app_mode { namespace app_mode {
......
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