Commit 3afeb635 authored by nancy's avatar nancy Committed by Commit Bot

Replace InternalAppName with BuiltInAppName

This is the follow up for crrev.com/c/1816495. InternalAppName has been
moved to BuiltInAppName in AppService, so replace InternalAppName with
BuiltInAppName, otherwise we have duplicate enum, which could cause
confusing for the future change.

Although the app_list/internal_app will be replaced by AppService for
the long term goal, in short term(one or two months), they are still
there, so as the temporary solution, update it to use the AppService's
enum BuiltInAppName.

BUG=1005640

Change-Id: I0992d549c25a40087212baba0b8d8305b1136d0c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1852526
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705364}
parent 06a7f290
...@@ -15,21 +15,6 @@ ...@@ -15,21 +15,6 @@
namespace { namespace {
// The built-in app's histogram name. This is used for logging so do not change
// the order of this enum.
// This is the copy from
// src/chrome/browser/ui/app_list/internal_app/internal_app_metadata.h
enum class BuiltInAppName {
kKeyboardShortcutViewer = 0,
kSettings = 1,
kContinueReading = 2,
kCamera = 3,
kDiscover = 4,
kPluginVm = 5,
kReleaseNotes = 6,
kMaxValue = kReleaseNotes,
};
// The default Essential app's histogram name. This is used for logging so do // The default Essential app's histogram name. This is used for logging so do
// not change the order of this enum. // not change the order of this enum.
// https://docs.google.com/document/d/1WJ-BjlVOM87ygIsdDBCyXxdKw3iS5EtNGm1fWiWhfIs // https://docs.google.com/document/d/1WJ-BjlVOM87ygIsdDBCyXxdKw3iS5EtNGm1fWiWhfIs
...@@ -85,7 +70,7 @@ void RecordDefaultAppLaunch(DefaultAppName default_app_name, ...@@ -85,7 +70,7 @@ void RecordDefaultAppLaunch(DefaultAppName default_app_name,
} }
} }
void RecordBuiltInAppLaunch(BuiltInAppName built_in_app_name, void RecordBuiltInAppLaunch(apps::BuiltInAppName built_in_app_name,
apps::mojom::LaunchSource launch_source) { apps::mojom::LaunchSource launch_source) {
switch (launch_source) { switch (launch_source) {
case apps::mojom::LaunchSource::kUnknown: case apps::mojom::LaunchSource::kUnknown:
......
...@@ -12,6 +12,19 @@ ...@@ -12,6 +12,19 @@
namespace apps { namespace apps {
// The built-in app's histogram name. This is used for logging so do not change
// the order of this enum.
enum class BuiltInAppName {
kKeyboardShortcutViewer = 0,
kSettings = 1,
kContinueReading = 2,
kCamera = 3,
kDiscover = 4,
kPluginVm = 5,
kReleaseNotes = 6,
kMaxValue = kReleaseNotes,
};
void RecordAppLaunch(const std::string& app_id, void RecordAppLaunch(const std::string& app_id,
apps::mojom::LaunchSource launch_source); apps::mojom::LaunchSource launch_source);
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ash/public/cpp/app_list/app_list_metrics.h" #include "ash/public/cpp/app_list/app_list_metrics.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/apps/app_service/app_icon_factory.h" #include "chrome/browser/apps/app_service/app_icon_factory.h"
#include "chrome/browser/apps/app_service/app_service_metrics.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/internal_app/internal_app_item.h" #include "chrome/browser/ui/app_list/internal_app/internal_app_item.h"
#include "chrome/browser/ui/app_list/internal_app/internal_app_metadata.h" #include "chrome/browser/ui/app_list/internal_app/internal_app_metadata.h"
...@@ -108,16 +109,14 @@ void BuiltInChromeOsApps::Connect( ...@@ -108,16 +109,14 @@ void BuiltInChromeOsApps::Connect(
// moved here, it might mean calling sync_sessions::SessionSyncService's // moved here, it might mean calling sync_sessions::SessionSyncService's
// SubscribeToForeignSessionsChanged. See also app_search_provider.cc's // SubscribeToForeignSessionsChanged. See also app_search_provider.cc's
// InternalDataSource. // InternalDataSource.
if (internal_app.internal_app_name == if (internal_app.internal_app_name == BuiltInAppName::kContinueReading) {
app_list::InternalAppName::kContinueReading) {
continue; continue;
} }
apps::mojom::AppPtr app = Convert(internal_app); apps::mojom::AppPtr app = Convert(internal_app);
if (!app.is_null()) { if (!app.is_null()) {
if (hide_settings_app_for_testing_ && if (hide_settings_app_for_testing_ &&
(internal_app.internal_app_name == (internal_app.internal_app_name == BuiltInAppName::kSettings)) {
app_list::InternalAppName::kSettings)) {
app->show_in_search = apps::mojom::OptionalBool::kFalse; app->show_in_search = apps::mojom::OptionalBool::kFalse;
} }
apps.push_back(std::move(app)); apps.push_back(std::move(app));
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "chrome/browser/ui/app_list/internal_app/internal_app_context_menu.h" #include "chrome/browser/ui/app_list/internal_app/internal_app_context_menu.h"
#include "ash/public/cpp/app_menu_constants.h" #include "ash/public/cpp/app_menu_constants.h"
#include "chrome/browser/apps/app_service/app_service_metrics.h"
#include "chrome/browser/chromeos/plugin_vm/plugin_vm_manager.h" #include "chrome/browser/chromeos/plugin_vm/plugin_vm_manager.h"
#include "chrome/browser/chromeos/plugin_vm/plugin_vm_util.h" #include "chrome/browser/chromeos/plugin_vm/plugin_vm_util.h"
#include "chrome/browser/ui/app_list/internal_app/internal_app_metadata.h" #include "chrome/browser/ui/app_list/internal_app/internal_app_metadata.h"
...@@ -21,7 +22,7 @@ InternalAppContextMenu::~InternalAppContextMenu() = default; ...@@ -21,7 +22,7 @@ InternalAppContextMenu::~InternalAppContextMenu() = default;
bool InternalAppContextMenu::IsCommandIdEnabled(int command_id) const { bool InternalAppContextMenu::IsCommandIdEnabled(int command_id) const {
if (command_id == ash::STOP_APP) { if (command_id == ash::STOP_APP) {
DCHECK_EQ(app_list::FindInternalApp(app_id())->internal_app_name, DCHECK_EQ(app_list::FindInternalApp(app_id())->internal_app_name,
app_list::InternalAppName::kPluginVm); apps::BuiltInAppName::kPluginVm);
return plugin_vm::IsPluginVmRunning(profile()); return plugin_vm::IsPluginVmRunning(profile());
} }
return app_list::AppContextMenu::IsCommandIdEnabled(command_id); return app_list::AppContextMenu::IsCommandIdEnabled(command_id);
...@@ -31,7 +32,7 @@ void InternalAppContextMenu::ExecuteCommand(int command_id, int event_flags) { ...@@ -31,7 +32,7 @@ void InternalAppContextMenu::ExecuteCommand(int command_id, int event_flags) {
switch (command_id) { switch (command_id) {
case ash::STOP_APP: case ash::STOP_APP:
DCHECK_EQ(app_list::FindInternalApp(app_id())->internal_app_name, DCHECK_EQ(app_list::FindInternalApp(app_id())->internal_app_name,
app_list::InternalAppName::kPluginVm); apps::BuiltInAppName::kPluginVm);
plugin_vm::PluginVmManager::GetForProfile(profile())->StopPluginVm(); plugin_vm::PluginVmManager::GetForProfile(profile())->StopPluginVm();
return; return;
} }
...@@ -43,7 +44,7 @@ void InternalAppContextMenu::BuildMenu(ui::SimpleMenuModel* menu_model) { ...@@ -43,7 +44,7 @@ void InternalAppContextMenu::BuildMenu(ui::SimpleMenuModel* menu_model) {
const auto* internal_app = app_list::FindInternalApp(app_id()); const auto* internal_app = app_list::FindInternalApp(app_id());
DCHECK(internal_app); DCHECK(internal_app);
if (internal_app->internal_app_name == app_list::InternalAppName::kPluginVm) { if (internal_app->internal_app_name == apps::BuiltInAppName::kPluginVm) {
AddContextMenuOption(menu_model, ash::STOP_APP, AddContextMenuOption(menu_model, ash::STOP_APP,
IDS_PLUGIN_VM_SHUT_DOWN_MENU_ITEM); IDS_PLUGIN_VM_SHUT_DOWN_MENU_ITEM);
} }
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/apps/app_service/app_service_metrics.h"
#include "chrome/browser/apps/launch_service/launch_service.h" #include "chrome/browser/apps/launch_service/launch_service.h"
#include "chrome/browser/chromeos/plugin_vm/plugin_vm_manager.h" #include "chrome/browser/chromeos/plugin_vm/plugin_vm_manager.h"
#include "chrome/browser/chromeos/plugin_vm/plugin_vm_util.h" #include "chrome/browser/chromeos/plugin_vm/plugin_vm_util.h"
...@@ -68,21 +69,21 @@ const std::vector<InternalApp>& GetInternalAppListImpl(bool get_all, ...@@ -68,21 +69,21 @@ const std::vector<InternalApp>& GetInternalAppListImpl(bool get_all,
/*recommendable=*/false, /*recommendable=*/false,
/*searchable=*/true, /*searchable=*/true,
/*show_in_launcher=*/false, /*show_in_launcher=*/false,
InternalAppName::kKeyboardShortcutViewer, apps::BuiltInAppName::kKeyboardShortcutViewer,
IDS_LAUNCHER_SEARCHABLE_KEYBOARD_SHORTCUT_VIEWER}, IDS_LAUNCHER_SEARCHABLE_KEYBOARD_SHORTCUT_VIEWER},
{ash::kInternalAppIdContinueReading, {ash::kInternalAppIdContinueReading,
IDS_INTERNAL_APP_CONTINUOUS_READING, IDR_PRODUCT_LOGO_256, IDS_INTERNAL_APP_CONTINUOUS_READING, IDR_PRODUCT_LOGO_256,
/*recommendable=*/true, /*recommendable=*/true,
/*searchable=*/false, /*searchable=*/false,
/*show_in_launcher=*/false, InternalAppName::kContinueReading, /*show_in_launcher=*/false, apps::BuiltInAppName::kContinueReading,
/*searchable_string_resource_id=*/0}, /*searchable_string_resource_id=*/0},
{ash::kReleaseNotesAppId, IDS_RELEASE_NOTES_NOTIFICATION_TITLE, {ash::kReleaseNotesAppId, IDS_RELEASE_NOTES_NOTIFICATION_TITLE,
IDR_RELEASE_NOTES_APP_192, IDR_RELEASE_NOTES_APP_192,
/*recommendable=*/true, /*recommendable=*/true,
/*searchable=*/false, /*searchable=*/false,
/*show_in_launcher=*/false, InternalAppName::kReleaseNotes, /*show_in_launcher=*/false, apps::BuiltInAppName::kReleaseNotes,
/*searchable_string_resource_id=*/0}}); /*searchable_string_resource_id=*/0}});
static base::NoDestructor<std::vector<InternalApp>> internal_app_list; static base::NoDestructor<std::vector<InternalApp>> internal_app_list;
...@@ -98,7 +99,7 @@ const std::vector<InternalApp>& GetInternalAppListImpl(bool get_all, ...@@ -98,7 +99,7 @@ const std::vector<InternalApp>& GetInternalAppListImpl(bool get_all,
/*recommendable=*/true, /*recommendable=*/true,
/*searchable=*/true, /*searchable=*/true,
/*show_in_launcher=*/true, /*show_in_launcher=*/true,
InternalAppName::kCamera, apps::BuiltInAppName::kCamera,
/*searchable_string_resource_id=*/0}); /*searchable_string_resource_id=*/0});
} }
...@@ -111,7 +112,7 @@ const std::vector<InternalApp>& GetInternalAppListImpl(bool get_all, ...@@ -111,7 +112,7 @@ const std::vector<InternalApp>& GetInternalAppListImpl(bool get_all,
IDR_DISCOVER_APP_192, IDR_DISCOVER_APP_192,
/*recommendable=*/false, /*recommendable=*/false,
/*searchable=*/true, /*searchable=*/true,
/*show_in_launcher=*/true, InternalAppName::kDiscover, /*show_in_launcher=*/true, apps::BuiltInAppName::kDiscover,
/*searchable_string_resource_id=*/IDS_INTERNAL_APP_DISCOVER}); /*searchable_string_resource_id=*/IDS_INTERNAL_APP_DISCOVER});
} }
...@@ -124,7 +125,7 @@ const std::vector<InternalApp>& GetInternalAppListImpl(bool get_all, ...@@ -124,7 +125,7 @@ const std::vector<InternalApp>& GetInternalAppListImpl(bool get_all,
IDR_SETTINGS_LOGO_192, IDR_SETTINGS_LOGO_192,
/*recommendable=*/true, /*recommendable=*/true,
/*searchable=*/true, /*searchable=*/true,
/*show_in_launcher=*/true, InternalAppName::kSettings, /*show_in_launcher=*/true, apps::BuiltInAppName::kSettings,
/*searchable_string_resource_id=*/0}); /*searchable_string_resource_id=*/0});
} }
...@@ -134,7 +135,7 @@ const std::vector<InternalApp>& GetInternalAppListImpl(bool get_all, ...@@ -134,7 +135,7 @@ const std::vector<InternalApp>& GetInternalAppListImpl(bool get_all,
IDR_LOGO_PLUGIN_VM_DEFAULT_192, IDR_LOGO_PLUGIN_VM_DEFAULT_192,
/*recommendable=*/true, /*recommendable=*/true,
/*searchable=*/true, /*searchable=*/true,
/*show_in_launcher=*/true, InternalAppName::kPluginVm, /*show_in_launcher=*/true, apps::BuiltInAppName::kPluginVm,
/*searchable_string_resource_id=*/0}); /*searchable_string_resource_id=*/0});
} }
return *internal_app_list; return *internal_app_list;
...@@ -313,8 +314,7 @@ bool HasRecommendableForeignTab( ...@@ -313,8 +314,7 @@ bool HasRecommendableForeignTab(
return has_recommendation; return has_recommendation;
} }
InternalAppName GetInternalAppNameByAppId( apps::BuiltInAppName GetInternalAppNameByAppId(const std::string& app_id) {
const std::string& app_id) {
const auto* app = FindInternalApp(app_id); const auto* app = FindInternalApp(app_id);
DCHECK(app); DCHECK(app);
return app->internal_app_name; return app->internal_app_name;
......
...@@ -13,29 +13,16 @@ ...@@ -13,29 +13,16 @@
class Profile; class Profile;
class GURL; class GURL;
namespace apps {
enum class BuiltInAppName;
}
namespace sync_sessions { namespace sync_sessions {
class OpenTabsUIDelegate; class OpenTabsUIDelegate;
} // namespace sync_sessions } // namespace sync_sessions
namespace app_list { namespace app_list {
// The internal app's histogram name of the chrome search result. This is used
// for logging so do not change the order of this enum.
// It has been copied to chrome/browser/apps/app_service/app_service_metrics.cc,
// so please update in app_service_metrics.cc as well.
// TODO(crbug.com/1005640): delete this enum here, and use the enum in
// app_service_metrics.cc.
enum class InternalAppName {
kKeyboardShortcutViewer = 0,
kSettings = 1,
kContinueReading = 2,
kCamera = 3,
kDiscover = 4,
kPluginVm = 5,
kReleaseNotes = 6,
kMaxValue = kReleaseNotes,
};
// Metadata about an internal app. // Metadata about an internal app.
// Internal apps are these Chrome OS special apps, e.g. Settings, or these apps // Internal apps are these Chrome OS special apps, e.g. Settings, or these apps
// can run in Chrome OS directly, e.g. Keyboard Shortcut Viewer. // can run in Chrome OS directly, e.g. Keyboard Shortcut Viewer.
...@@ -56,7 +43,7 @@ struct InternalApp { ...@@ -56,7 +43,7 @@ struct InternalApp {
// Can show in launcher apps grid. // Can show in launcher apps grid.
bool show_in_launcher; bool show_in_launcher;
InternalAppName internal_app_name; apps::BuiltInAppName internal_app_name;
// The string used for search query in addition to the name. // The string used for search query in addition to the name.
int searchable_string_resource_id = 0; int searchable_string_resource_id = 0;
...@@ -106,9 +93,8 @@ bool HasRecommendableForeignTab( ...@@ -106,9 +93,8 @@ bool HasRecommendableForeignTab(
GURL* url, GURL* url,
sync_sessions::OpenTabsUIDelegate* test_delegate); sync_sessions::OpenTabsUIDelegate* test_delegate);
// Returns the InternalAppName of an internal app. // Returns the BuiltInAppName of an internal app.
InternalAppName GetInternalAppNameByAppId( apps::BuiltInAppName GetInternalAppNameByAppId(const std::string& app_id);
const std::string& app_id);
// Returns the number of internal apps which can show in launcher. // Returns the number of internal apps which can show in launcher.
// If |apps_name| is not nullptr, it will be the concatenated string of these // If |apps_name| is not nullptr, it will be the concatenated string of these
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "ash/public/cpp/app_menu_constants.h" #include "ash/public/cpp/app_menu_constants.h"
#include "ash/public/cpp/shelf_item.h" #include "ash/public/cpp/shelf_item.h"
#include "chrome/browser/apps/app_service/app_service_metrics.h"
#include "chrome/browser/chromeos/plugin_vm/plugin_vm_manager.h" #include "chrome/browser/chromeos/plugin_vm/plugin_vm_manager.h"
#include "chrome/browser/chromeos/plugin_vm/plugin_vm_util.h" #include "chrome/browser/chromeos/plugin_vm/plugin_vm_util.h"
#include "chrome/browser/ui/app_list/internal_app/internal_app_metadata.h" #include "chrome/browser/ui/app_list/internal_app/internal_app_metadata.h"
...@@ -43,8 +44,7 @@ void InternalAppShelfContextMenu::BuildMenu(ui::SimpleMenuModel* menu_model) { ...@@ -43,8 +44,7 @@ void InternalAppShelfContextMenu::BuildMenu(ui::SimpleMenuModel* menu_model) {
AddContextMenuOption(menu_model, ash::MENU_CLOSE, AddContextMenuOption(menu_model, ash::MENU_CLOSE,
IDS_LAUNCHER_CONTEXT_MENU_CLOSE); IDS_LAUNCHER_CONTEXT_MENU_CLOSE);
if (internal_app->internal_app_name == if (internal_app->internal_app_name == apps::BuiltInAppName::kPluginVm &&
app_list::InternalAppName::kPluginVm &&
plugin_vm::IsPluginVmRunning(controller()->profile())) { plugin_vm::IsPluginVmRunning(controller()->profile())) {
AddContextMenuOption(menu_model, ash::STOP_APP, AddContextMenuOption(menu_model, ash::STOP_APP,
IDS_PLUGIN_VM_SHUT_DOWN_MENU_ITEM); IDS_PLUGIN_VM_SHUT_DOWN_MENU_ITEM);
...@@ -59,8 +59,7 @@ void InternalAppShelfContextMenu::ExecuteCommand(int command_id, ...@@ -59,8 +59,7 @@ void InternalAppShelfContextMenu::ExecuteCommand(int command_id,
const auto* internal_app = app_list::FindInternalApp(item().id.app_id); const auto* internal_app = app_list::FindInternalApp(item().id.app_id);
DCHECK(internal_app); DCHECK(internal_app);
DCHECK_EQ(internal_app->internal_app_name, DCHECK_EQ(internal_app->internal_app_name, apps::BuiltInAppName::kPluginVm);
app_list::InternalAppName::kPluginVm);
if (command_id == ash::STOP_APP) { if (command_id == ash::STOP_APP) {
plugin_vm::PluginVmManager::GetForProfile(controller()->profile()) plugin_vm::PluginVmManager::GetForProfile(controller()->profile())
->StopPluginVm(); ->StopPluginVm();
......
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