Commit b3228771 authored by Joel Hockey's avatar Joel Hockey Committed by Commit Bot

Make single vs multiple window configurable for system app

Some system apps such as settings will only ever show in
a single window.  Others such as terminal allow multiple
windows of the app.

Bug: 1028861
Change-Id: Ifc4348a13f9f92c39e39e3c52e072bc0cfe97d93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1942598Reviewed-by: default avatarcalamity <calamity@chromium.org>
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720867}
parent 8f3060f7
...@@ -85,12 +85,22 @@ Browser* LaunchSystemWebApp(Profile* profile, ...@@ -85,12 +85,22 @@ Browser* LaunchSystemWebApp(Profile* profile,
const GURL& url, const GURL& url,
const apps::AppLaunchParams& params, const apps::AppLaunchParams& params,
bool* did_create) { bool* did_create) {
auto* provider = WebAppProvider::Get(profile);
if (!provider)
return nullptr;
DCHECK_EQ(params.app_id, *GetAppIdForSystemWebApp(profile, app_type));
if (did_create) if (did_create)
*did_create = false; *did_create = false;
// TODO(https://crbug.com/1027030): Better understand and improve SWA launch // TODO(https://crbug.com/1027030): Better understand and improve SWA launch
// behavior. Early exit here skips logic in ShowApplicationWindow. // behavior. Early exit here skips logic in ShowApplicationWindow.
Browser* browser = FindSystemWebAppBrowser(profile, app_type); Browser* browser = nullptr;
if (provider->system_web_app_manager().IsSingleWindow(app_type)) {
browser = FindSystemWebAppBrowser(profile, app_type);
}
if (browser) { if (browser) {
content::WebContents* web_contents = content::WebContents* web_contents =
browser->tab_strip_model()->GetWebContentsAt(0); browser->tab_strip_model()->GetWebContentsAt(0);
......
...@@ -84,6 +84,7 @@ base::flat_map<SystemAppType, SystemAppInfo> CreateSystemWebApps() { ...@@ -84,6 +84,7 @@ base::flat_map<SystemAppType, SystemAppInfo> CreateSystemWebApps() {
infos.emplace( infos.emplace(
SystemAppType::TERMINAL, SystemAppType::TERMINAL,
SystemAppInfo("Terminal", GURL("chrome://terminal/html/pwa.html"))); SystemAppInfo("Terminal", GURL("chrome://terminal/html/pwa.html")));
infos.at(SystemAppType::TERMINAL).single_window = false;
} }
if (SystemWebAppManager::IsAppEnabled(SystemAppType::HELP)) { if (SystemWebAppManager::IsAppEnabled(SystemAppType::HELP)) {
...@@ -243,6 +244,14 @@ bool SystemWebAppManager::IsSystemWebApp(const AppId& app_id) const { ...@@ -243,6 +244,14 @@ bool SystemWebAppManager::IsSystemWebApp(const AppId& app_id) const {
app_id, ExternalInstallSource::kSystemInstalled); app_id, ExternalInstallSource::kSystemInstalled);
} }
bool SystemWebAppManager::IsSingleWindow(SystemAppType type) const {
auto it = system_app_infos_.find(type);
if (it == system_app_infos_.end())
return false;
return it->second.single_window;
}
gfx::Size SystemWebAppManager::GetMinimumWindowSize(const AppId& app_id) const { gfx::Size SystemWebAppManager::GetMinimumWindowSize(const AppId& app_id) const {
auto app_type_it = app_id_to_app_type_.find(app_id); auto app_type_it = app_id_to_app_type_.find(app_id);
if (app_type_it == app_id_to_app_type_.end()) if (app_type_it == app_id_to_app_type_.end())
......
...@@ -66,6 +66,9 @@ struct SystemAppInfo { ...@@ -66,6 +66,9 @@ struct SystemAppInfo {
// TODO(https://github.com/w3c/manifest/issues/436): Replace with PWA manifest // TODO(https://github.com/w3c/manifest/issues/436): Replace with PWA manifest
// properties for window size. // properties for window size.
gfx::Size minimum_window_size; gfx::Size minimum_window_size;
// If set, we allow only a single window for this app.
bool single_window = true;
}; };
// Installs, uninstalls, and updates System Web Apps. // Installs, uninstalls, and updates System Web Apps.
...@@ -120,6 +123,9 @@ class SystemWebAppManager { ...@@ -120,6 +123,9 @@ class SystemWebAppManager {
// Returns whether |app_id| points to an installed System App. // Returns whether |app_id| points to an installed System App.
bool IsSystemWebApp(const AppId& app_id) const; bool IsSystemWebApp(const AppId& app_id) const;
// Returns whether the given System App |type| should use a single window.
bool IsSingleWindow(SystemAppType type) const;
// Returns the minimum window size for |app_id| or an empty size if the app // Returns the minimum window size for |app_id| or an empty size if the app
// doesn't specify a minimum. // doesn't specify a minimum.
gfx::Size GetMinimumWindowSize(const AppId& app_id) const; gfx::Size GetMinimumWindowSize(const AppId& app_id) const;
......
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