Commit e54fc640 authored by Glen Robertson's avatar Glen Robertson Committed by Commit Bot

desktop-pwas: Add SetAppLaunchContainer method to AppRegistrar.

Only implemented for extensions for now.
Will be used in subsequent CL.

Bug: 989792
Change-Id: I9d15f7c007ecdf655c060d858122a7b3b3ed768a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1783679
Commit-Queue: Glen Robertson <glenrob@chromium.org>
Auto-Submit: Glen Robertson <glenrob@chromium.org>
Reviewed-by: default avatarAlexey Baskakov <loyso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692987}
parent 103da0a8
...@@ -90,6 +90,8 @@ class AppRegistrar { ...@@ -90,6 +90,8 @@ class AppRegistrar {
virtual const GURL& GetAppLaunchURL(const AppId& app_id) const = 0; virtual const GURL& GetAppLaunchURL(const AppId& app_id) const = 0;
virtual base::Optional<GURL> GetAppScope(const AppId& app_id) const = 0; virtual base::Optional<GURL> GetAppScope(const AppId& app_id) const = 0;
virtual LaunchContainer GetAppLaunchContainer(const AppId& app_id) const = 0; virtual LaunchContainer GetAppLaunchContainer(const AppId& app_id) const = 0;
virtual void SetAppLaunchContainer(const AppId& app_id,
LaunchContainer launch_container) = 0;
virtual std::vector<AppId> GetAppIds() const = 0; virtual std::vector<AppId> GetAppIds() const = 0;
......
...@@ -164,6 +164,29 @@ web_app::LaunchContainer BookmarkAppRegistrar::GetAppLaunchContainer( ...@@ -164,6 +164,29 @@ web_app::LaunchContainer BookmarkAppRegistrar::GetAppLaunchContainer(
} }
} }
void BookmarkAppRegistrar::SetAppLaunchContainer(
const web_app::AppId& app_id,
web_app::LaunchContainer launch_container) {
const Extension* extension = GetExtension(app_id);
DCHECK(extension);
if (!extension)
return;
switch (launch_container) {
case web_app::LaunchContainer::kWindow:
extensions::SetLaunchType(profile(), extension->id(),
extensions::LAUNCH_TYPE_WINDOW);
return;
case web_app::LaunchContainer::kTab:
extensions::SetLaunchType(profile(), extension->id(),
extensions::LAUNCH_TYPE_REGULAR);
return;
case web_app::LaunchContainer::kDefault:
NOTREACHED();
return;
}
}
std::vector<web_app::AppId> BookmarkAppRegistrar::GetAppIds() const { std::vector<web_app::AppId> BookmarkAppRegistrar::GetAppIds() const {
std::vector<web_app::AppId> app_ids; std::vector<web_app::AppId> app_ids;
for (scoped_refptr<const Extension> app : for (scoped_refptr<const Extension> app :
......
...@@ -42,6 +42,9 @@ class BookmarkAppRegistrar : public web_app::AppRegistrar, ...@@ -42,6 +42,9 @@ class BookmarkAppRegistrar : public web_app::AppRegistrar,
base::Optional<GURL> GetAppScope(const web_app::AppId& app_id) const override; base::Optional<GURL> GetAppScope(const web_app::AppId& app_id) const override;
web_app::LaunchContainer GetAppLaunchContainer( web_app::LaunchContainer GetAppLaunchContainer(
const web_app::AppId& app_id) const override; const web_app::AppId& app_id) const override;
void SetAppLaunchContainer(
const web_app::AppId& app_id,
web_app::LaunchContainer launch_container) override;
std::vector<web_app::AppId> GetAppIds() const override; std::vector<web_app::AppId> GetAppIds() const override;
// ExtensionRegistryObserver: // ExtensionRegistryObserver:
......
...@@ -137,6 +137,11 @@ LaunchContainer TestAppRegistrar::GetAppLaunchContainer( ...@@ -137,6 +137,11 @@ LaunchContainer TestAppRegistrar::GetAppLaunchContainer(
return LaunchContainer::kTab; return LaunchContainer::kTab;
} }
void TestAppRegistrar::SetAppLaunchContainer(const AppId& app_id,
LaunchContainer launch_container) {
NOTIMPLEMENTED();
}
std::vector<AppId> TestAppRegistrar::GetAppIds() const { std::vector<AppId> TestAppRegistrar::GetAppIds() const {
std::vector<AppId> result; std::vector<AppId> result;
for (const std::pair<AppId, AppInfo>& it : installed_apps_) { for (const std::pair<AppId, AppInfo>& it : installed_apps_) {
......
...@@ -60,6 +60,8 @@ class TestAppRegistrar : public AppRegistrar { ...@@ -60,6 +60,8 @@ class TestAppRegistrar : public AppRegistrar {
base::Optional<GURL> GetAppScope(const AppId& app_id) const override; base::Optional<GURL> GetAppScope(const AppId& app_id) const override;
web_app::LaunchContainer GetAppLaunchContainer( web_app::LaunchContainer GetAppLaunchContainer(
const web_app::AppId& app_id) const override; const web_app::AppId& app_id) const override;
void SetAppLaunchContainer(const AppId& app_id,
LaunchContainer launch_container) override;
std::vector<AppId> GetAppIds() const override; std::vector<AppId> GetAppIds() const override;
private: private:
......
...@@ -146,6 +146,11 @@ LaunchContainer WebAppRegistrar::GetAppLaunchContainer( ...@@ -146,6 +146,11 @@ LaunchContainer WebAppRegistrar::GetAppLaunchContainer(
return web_app ? web_app->launch_container() : LaunchContainer::kDefault; return web_app ? web_app->launch_container() : LaunchContainer::kDefault;
} }
void WebAppRegistrar::SetAppLaunchContainer(const AppId& app_id,
LaunchContainer launch_container) {
NOTIMPLEMENTED();
}
std::vector<AppId> WebAppRegistrar::GetAppIds() const { std::vector<AppId> WebAppRegistrar::GetAppIds() const {
std::vector<AppId> app_ids; std::vector<AppId> app_ids;
app_ids.reserve(registry_.size()); app_ids.reserve(registry_.size());
......
...@@ -50,6 +50,8 @@ class WebAppRegistrar : public AppRegistrar { ...@@ -50,6 +50,8 @@ class WebAppRegistrar : public AppRegistrar {
const GURL& GetAppLaunchURL(const AppId& app_id) const override; const GURL& GetAppLaunchURL(const AppId& app_id) const override;
base::Optional<GURL> GetAppScope(const AppId& app_id) const override; base::Optional<GURL> GetAppScope(const AppId& app_id) const override;
LaunchContainer GetAppLaunchContainer(const AppId& app_id) const override; LaunchContainer GetAppLaunchContainer(const AppId& app_id) const override;
void SetAppLaunchContainer(const AppId& app_id,
LaunchContainer launch_container) override;
std::vector<AppId> GetAppIds() const override; std::vector<AppId> GetAppIds() const override;
// Only range-based |for| loop supported. Don't use AppSet directly. // Only range-based |for| loop supported. Don't use AppSet directly.
......
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