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