Commit b9ce31a1 authored by nancy's avatar nancy Committed by Commit Bot

Add context menus mojom interface in AppService.

BUG=1038487

Change-Id: I0b6239c3fb2361fc25b6990f2529a1c1ec8025e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2010231
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733529}
parent cefdcae7
......@@ -294,19 +294,18 @@ void AppServiceProxy::UnpauseApps(const std::set<std::string>& app_ids) {
}
}
void AppServiceProxy::GetMenuModel(const std::string& app_id,
apps::mojom::MenuType menu_type,
int64_t display_id,
GetMenuModelCallback callback) {
void AppServiceProxy::GetMenuModel(
const std::string& app_id,
apps::mojom::MenuType menu_type,
int64_t display_id,
apps::mojom::Publisher::GetMenuModelCallback callback) {
if (!app_service_.is_connected()) {
return;
}
// TODO(crbug.com/1038487): change to use below code to call
// AppService->GetMenuModel when GetMenuModel is added to mojom.
// apps::mojom::AppType app_type = cache_.GetAppType(app_id);
// app_service_->GetMenuModel(app_type, app_id, menu_type, display_id,
// std::move(callback));
apps::mojom::AppType app_type = cache_.GetAppType(app_id);
app_service_->GetMenuModel(app_type, app_id, menu_type, display_id,
std::move(callback));
}
void AppServiceProxy::OpenNativeSettings(const std::string& app_id) {
......
......@@ -57,8 +57,6 @@ class AppServiceProxy : public KeyedService,
public apps::mojom::Subscriber,
public apps::AppRegistryCache::Observer {
public:
using GetMenuModelCallback =
base::OnceCallback<void(apps::mojom::MenuItemsPtr)>;
using OnPauseDialogClosedCallback = base::OnceCallback<void()>;
explicit AppServiceProxy(Profile* profile);
......@@ -140,7 +138,7 @@ class AppServiceProxy : public KeyedService,
void GetMenuModel(const std::string& app_id,
apps::mojom::MenuType menu_type,
int64_t display_id,
GetMenuModelCallback callback);
apps::mojom::Publisher::GetMenuModelCallback callback);
// Opens native settings for the app with |app_id|.
void OpenNativeSettings(const std::string& app_id);
......
......@@ -52,8 +52,6 @@ class ArcApps : public KeyedService,
private:
using AppIdToTaskIds = std::map<std::string, std::set<int>>;
using GetMenuModelCallback =
base::OnceCallback<void(apps::mojom::MenuItemsPtr)>;
using TaskIdToAppId = std::map<int, std::string>;
ArcApps(Profile* profile, apps::AppServiceProxy* proxy);
......@@ -89,7 +87,7 @@ class ArcApps : public KeyedService,
void GetMenuModel(const std::string& app_id,
apps::mojom::MenuType menu_type,
int64_t display_id,
GetMenuModelCallback callback);
GetMenuModelCallback callback) override;
void OpenNativeSettings(const std::string& app_id) override;
void OnPreferredAppSet(const std::string& app_id,
apps::mojom::IntentFilterPtr intent_filter,
......
......@@ -31,9 +31,6 @@ class BuiltInChromeOsApps : public apps::mojom::Publisher {
static bool SetHideSettingsAppForTesting(bool hide);
private:
using GetMenuModelCallback =
base::OnceCallback<void(::apps::mojom::MenuItemsPtr)>;
void Initialize(const mojo::Remote<apps::mojom::AppService>& app_service);
// apps::mojom::Publisher overrides.
......@@ -64,7 +61,7 @@ class BuiltInChromeOsApps : public apps::mojom::Publisher {
void GetMenuModel(const std::string& app_id,
apps::mojom::MenuType menu_type,
int64_t display_id,
GetMenuModelCallback callback);
GetMenuModelCallback callback) override;
void OpenNativeSettings(const std::string& app_id) override;
void OnPreferredAppSet(const std::string& app_id,
apps::mojom::IntentFilterPtr intent_filter,
......
......@@ -43,9 +43,6 @@ class CrostiniApps : public KeyedService,
Profile* profile);
private:
using GetMenuModelCallback =
base::OnceCallback<void(apps::mojom::MenuItemsPtr)>;
enum class PublishAppIDType {
kInstall,
kUninstall,
......@@ -82,7 +79,7 @@ class CrostiniApps : public KeyedService,
void GetMenuModel(const std::string& app_id,
apps::mojom::MenuType menu_type,
int64_t display_id,
GetMenuModelCallback callback);
GetMenuModelCallback callback) override;
void OpenNativeSettings(const std::string& app_id) override;
void OnPreferredAppSet(const std::string& app_id,
apps::mojom::IntentFilterPtr intent_filter,
......
......@@ -72,9 +72,6 @@ class ExtensionApps : public apps::mojom::Publisher,
void ObserveArc();
private:
using GetMenuModelCallback =
base::OnceCallback<void(apps::mojom::MenuItemsPtr)>;
void Initialize(const mojo::Remote<apps::mojom::AppService>& app_service);
// Determines whether the given extension should be treated as type app_type_,
......@@ -109,7 +106,7 @@ class ExtensionApps : public apps::mojom::Publisher,
void GetMenuModel(const std::string& app_id,
apps::mojom::MenuType menu_type,
int64_t display_id,
GetMenuModelCallback callback);
GetMenuModelCallback callback) override;
void OpenNativeSettings(const std::string& app_id) override;
void OnPreferredAppSet(const std::string& app_id,
apps::mojom::IntentFilterPtr intent_filter,
......
......@@ -53,9 +53,6 @@ class WebApps : public apps::mojom::Publisher,
void ObserveArc();
private:
using GetMenuModelCallback =
base::OnceCallback<void(apps::mojom::MenuItemsPtr)>;
void Initialize(const mojo::Remote<apps::mojom::AppService>& app_service);
const web_app::WebApp* GetWebApp(const web_app::AppId& app_id) const;
......@@ -89,7 +86,7 @@ class WebApps : public apps::mojom::Publisher,
void GetMenuModel(const std::string& app_id,
apps::mojom::MenuType menu_type,
int64_t display_id,
GetMenuModelCallback callback);
GetMenuModelCallback callback) override;
void OpenNativeSettings(const std::string& app_id) override;
void OnPreferredAppSet(const std::string& app_id,
apps::mojom::IntentFilterPtr intent_filter,
......
......@@ -195,10 +195,8 @@ void AppServiceImpl::GetMenuModel(apps::mojom::AppType app_type,
return;
}
// TODO(crbug.com/1038487): change to use below code to call
// AppServiceProxy->GetMenuModel when GetMenuModel is added to mojom.
// iter->second->GetMenuModel(app_id, menu_type, display_id,
// std::move(callback));
iter->second->GetMenuModel(app_id, menu_type, display_id,
std::move(callback));
}
void AppServiceImpl::OpenNativeSettings(apps::mojom::AppType app_type,
......
......@@ -27,9 +27,6 @@ namespace apps {
// See chrome/services/app_service/README.md.
class AppServiceImpl : public apps::mojom::AppService {
public:
using GetMenuModelCallback =
base::OnceCallback<void(apps::mojom::MenuItemsPtr)>;
explicit AppServiceImpl(PrefService* profile_prefs);
~AppServiceImpl() override;
......@@ -80,7 +77,7 @@ class AppServiceImpl : public apps::mojom::AppService {
const std::string& app_id,
apps::mojom::MenuType menu_type,
int64_t display_id,
GetMenuModelCallback callback);
GetMenuModelCallback callback) override;
void OpenNativeSettings(apps::mojom::AppType app_type,
const std::string& app_id) override;
void AddPreferredApp(apps::mojom::AppType app_type,
......
......@@ -96,12 +96,10 @@ class FakePublisher : public apps::mojom::Publisher {
bool clear_site_data,
bool report_abuse) override {}
using GetMenuModelCallback =
base::OnceCallback<void(apps::mojom::MenuItemsPtr)>;
void GetMenuModel(const std::string& app_id,
apps::mojom::MenuType menu_type,
int64_t display_id,
GetMenuModelCallback callback) {}
GetMenuModelCallback callback) override {}
void PauseApp(const std::string& app_id) override {}
void UnpauseApps(const std::string& app_id) override {}
......
......@@ -81,11 +81,19 @@ interface AppService {
AppType app_type,
string app_id);
// Returns the menu items for an app with |app_id|.
GetMenuModel(
AppType app_type,
string app_id,
MenuType menu_type,
int64 display_id) => (MenuItems menu_items);
// Opens native settings for the app with |app_id|.
OpenNativeSettings(
AppType app_type,
string app_id);
// Set app identified by |app_id| as preferred app for |intent_filter|.
// Sets app identified by |app_id| as preferred app for |intent_filter|.
// |intent| is needed to set the preferred app in ARC.
// If the request is |from_publisher|, we would not sync the preferred
// app back to the publisher.
......@@ -96,10 +104,10 @@ interface AppService {
Intent? intent,
bool from_publisher);
// Remove all preferred app setting for an |app_id|.
// Removes all preferred app setting for an |app_id|.
RemovePreferredApp(AppType app_type, string app_id);
// Reset app identified by |app_id| as preferred app for |intent_filter|.
// Resets app identified by |app_id| as preferred app for |intent_filter|.
RemovePreferredAppForFilter(
AppType app_type,
string app_id,
......@@ -160,6 +168,13 @@ interface Publisher {
UnpauseApps(
string app_id);
// Returns the menu items for an app with |app_id|.
GetMenuModel(
string app_id,
MenuType menu_type,
int64 display_id) => (MenuItems menu_items);
// Opens native settings for the app with |app_id|.
OpenNativeSettings(
string app_id);
......
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