Commit 418db2f4 authored by Jason Lin's avatar Jason Lin Committed by Commit Bot

Rename two names in plugin_vm_util.h

* kPluginVmAppId -> kPluginVmShelfAppId: This id is also used by Plugin
  VM installer as the shelf id on the window. Rename to make it clearer.
* IsPluginVmWindow() -> IsPluginVmAppWindow(): This function only return
  true for the Plugin VM app window but not the installer window. Rename
  to make it clearer.

Bug: 1087726
Change-Id: Ib7cf899133ed970bd795c859ac740f5c15f77b23
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2247460Reviewed-by: default avatarTimothy Loh <timloh@chromium.org>
Reviewed-by: default avatarNancy Wang <nancylingwang@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Jason Lin <lxj@google.com>
Cr-Commit-Position: refs/heads/master@{#779549}
parent f40b218b
......@@ -246,7 +246,7 @@ void RecordAppLaunch(const std::string& app_id,
} else if (app_id == ash::kInternalAppIdDiscover) {
RecordBuiltInAppLaunch(BuiltInAppName::kDiscover, launch_source);
#if defined(OS_CHROMEOS)
} else if (app_id == plugin_vm::kPluginVmAppId) {
} else if (app_id == plugin_vm::kPluginVmShelfAppId) {
RecordBuiltInAppLaunch(BuiltInAppName::kPluginVm, launch_source);
#endif // OS_CHROMEOS
} else if (app_id == ash::kReleaseNotesAppId) {
......@@ -268,7 +268,7 @@ void RecordBuiltInAppSearchResult(const std::string& app_id) {
base::UmaHistogramEnumeration("Apps.AppListSearchResultInternalApp.Show",
BuiltInAppName::kDiscover);
#if defined(OS_CHROMEOS)
} else if (app_id == plugin_vm::kPluginVmAppId) {
} else if (app_id == plugin_vm::kPluginVmShelfAppId) {
base::UmaHistogramEnumeration("Apps.AppListSearchResultInternalApp.Show",
BuiltInAppName::kPluginVm);
#endif // OS_CHROMEOS
......
......@@ -87,7 +87,7 @@ void PopulatePermissions(apps::mojom::App* app, Profile* profile) {
apps::mojom::AppPtr GetPluginVmApp(Profile* profile, bool allowed) {
apps::mojom::AppPtr app = apps::PublisherBase::MakeApp(
apps::mojom::AppType::kPluginVm, plugin_vm::kPluginVmAppId,
apps::mojom::AppType::kPluginVm, plugin_vm::kPluginVmShelfAppId,
allowed ? apps::mojom::Readiness::kReady
: apps::mojom::Readiness::kDisabledByPolicy,
l10n_util::GetStringUTF8(IDS_PLUGIN_VM_APP_NAME),
......@@ -167,7 +167,7 @@ void PluginVmApps::Launch(const std::string& app_id,
int32_t event_flags,
apps::mojom::LaunchSource launch_source,
int64_t display_id) {
DCHECK_EQ(plugin_vm::kPluginVmAppId, app_id);
DCHECK_EQ(plugin_vm::kPluginVmShelfAppId, app_id);
if (plugin_vm::IsPluginVmEnabled(profile_)) {
plugin_vm::PluginVmManagerFactory::GetForProfile(profile_)->LaunchPluginVm(
base::DoNothing());
......@@ -189,7 +189,7 @@ void PluginVmApps::SetPermission(const std::string& app_id,
apps::mojom::AppPtr app = apps::mojom::App::New();
app->app_type = apps::mojom::AppType::kPluginVm;
app->app_id = plugin_vm::kPluginVmAppId;
app->app_id = plugin_vm::kPluginVmShelfAppId;
PopulatePermissions(app.get(), profile_);
Publish(std::move(app), subscribers_);
}
......@@ -216,7 +216,7 @@ void PluginVmApps::GetMenuModel(const std::string& app_id,
AddCommandItem(ash::MENU_CLOSE, IDS_SHELF_CONTEXT_MENU_CLOSE, &menu_items);
}
if (app_id == plugin_vm::kPluginVmAppId &&
if (app_id == plugin_vm::kPluginVmShelfAppId &&
plugin_vm::IsPluginVmRunning(profile_)) {
AddCommandItem(ash::SHUTDOWN_GUEST_OS, IDS_PLUGIN_VM_SHUT_DOWN_MENU_ITEM,
&menu_items);
......@@ -232,7 +232,7 @@ void PluginVmApps::OnPluginVmAllowedChanged(bool is_allowed) {
apps::mojom::AppPtr app = apps::mojom::App::New();
app->app_type = apps::mojom::AppType::kPluginVm;
app->app_id = plugin_vm::kPluginVmAppId;
app->app_id = plugin_vm::kPluginVmShelfAppId;
SetAppAllowed(app.get(), is_allowed);
Publish(std::move(app), subscribers_);
}
......@@ -241,7 +241,7 @@ void PluginVmApps::OnPluginVmConfiguredChanged() {
// Only changed fields need to be republished.
apps::mojom::AppPtr app = apps::mojom::App::New();
app->app_type = apps::mojom::AppType::kPluginVm;
app->app_id = plugin_vm::kPluginVmAppId;
app->app_id = plugin_vm::kPluginVmShelfAppId;
SetShowInAppManagement(app.get(), plugin_vm::IsPluginVmConfigured(profile_));
Publish(std::move(app), subscribers_);
}
......
......@@ -104,7 +104,7 @@ void PluginVmServiceProvider::ShowSettingsPage(
Profile* profile = ProfileManager::GetPrimaryUserProfile();
if (request.subpage_path() == kShowSettingsPageDetails) {
chrome::ShowAppManagementPage(
profile, plugin_vm::kPluginVmAppId,
profile, plugin_vm::kPluginVmShelfAppId,
AppManagementEntryPoint::kDBusServicePluginVm);
} else if (request.subpage_path() == kShowSettingsPageSharedPaths) {
chrome::SettingsWindowManager::GetInstance()->ShowOSSettings(
......
......@@ -57,7 +57,7 @@ PluginVmEngagementMetricsService::PluginVmEngagementMetricsService(
return;
guest_os_engagement_metrics_ =
std::make_unique<guest_os::GuestOsEngagementMetrics>(
profile->GetPrefs(), base::BindRepeating(IsPluginVmWindow),
profile->GetPrefs(), base::BindRepeating(IsPluginVmAppWindow),
prefs::kEngagementPrefsPrefix, kUmaPrefix);
}
......
......@@ -66,7 +66,7 @@ void FocusAllPluginVmWindows() {
DCHECK(shelf_model);
AppWindowLauncherItemController* launcher_item_controller =
shelf_model->GetAppWindowLauncherItemController(
ash::ShelfID(kPluginVmAppId));
ash::ShelfID(kPluginVmShelfAppId));
if (!launcher_item_controller) {
return;
}
......
......@@ -155,10 +155,10 @@ TEST_F(PluginVmFilesTest, LaunchPluginVmApp) {
auto launcher_item_controller =
std::make_unique<AppWindowLauncherItemController>(
ash::ShelfID(kPluginVmAppId));
ash::ShelfID(kPluginVmShelfAppId));
ui::test::MockBaseWindow mock_window;
launcher_item_controller->AddWindow(&mock_window);
shelf_model.SetShelfItemDelegate(ash::ShelfID(kPluginVmAppId),
shelf_model.SetShelfItemDelegate(ash::ShelfID(kPluginVmShelfAppId),
std::move(launcher_item_controller));
vm_tools::cicerone::LaunchContainerApplicationResponse response;
response.set_success(true);
......
......@@ -133,8 +133,8 @@ void PluginVmManagerImpl::LaunchPluginVm(LaunchPluginVmCallback callback) {
ChromeLauncherController::instance()
->GetShelfSpinnerController()
->AddSpinnerToShelf(
kPluginVmAppId,
std::make_unique<ShelfSpinnerItemController>(kPluginVmAppId));
kPluginVmShelfAppId,
std::make_unique<ShelfSpinnerItemController>(kPluginVmShelfAppId));
}
// Launching Plugin Vm goes through the following steps:
......@@ -243,7 +243,8 @@ void PluginVmManagerImpl::OnVmStateChanged(
// The previous seneschal handle is no longer valid.
seneschal_server_handle_ = 0;
ChromeLauncherController::instance()->Close(ash::ShelfID(kPluginVmAppId));
ChromeLauncherController::instance()->Close(
ash::ShelfID(kPluginVmShelfAppId));
}
auto* engagement_metrics_service =
......@@ -514,7 +515,7 @@ void PluginVmManagerImpl::LaunchFailed(PluginVmLaunchResult result) {
ChromeLauncherController::instance()
->GetShelfSpinnerController()
->CloseSpinner(kPluginVmAppId);
->CloseSpinner(kPluginVmShelfAppId);
pending_start_vm_ = false;
pending_vm_tools_installed_ = false;
......
......@@ -232,7 +232,7 @@ TEST_F(PluginVmManagerImplTest, OnStateChangedRunningStoppedSuspended) {
// Signals for RUNNING, then STOPPED.
test_helper_->OpenShelfItem();
EXPECT_TRUE(
chrome_launcher_controller_->IsOpen(ash::ShelfID(kPluginVmAppId)));
chrome_launcher_controller_->IsOpen(ash::ShelfID(kPluginVmShelfAppId)));
NotifyVmStateChanged(vm_tools::plugin_dispatcher::VmState::VM_STATE_RUNNING);
task_environment_.RunUntilIdle();
......@@ -246,7 +246,7 @@ TEST_F(PluginVmManagerImplTest, OnStateChangedRunningStoppedSuspended) {
task_environment_.RunUntilIdle();
EXPECT_EQ(plugin_vm_manager_->seneschal_server_handle(), 0ul);
EXPECT_FALSE(
chrome_launcher_controller_->IsOpen(ash::ShelfID(kPluginVmAppId)));
chrome_launcher_controller_->IsOpen(ash::ShelfID(kPluginVmShelfAppId)));
// Signals for RUNNING, then SUSPENDED.
NotifyVmStateChanged(vm_tools::plugin_dispatcher::VmState::VM_STATE_RUNNING);
......@@ -264,7 +264,7 @@ TEST_F(PluginVmManagerImplTest, LaunchPluginVmSpinner) {
EXPECT_TRUE(IsPluginVmAllowedForProfile(testing_profile_.get()));
// No spinner before doing anything
EXPECT_FALSE(SpinnerController()->HasApp(kPluginVmAppId));
EXPECT_FALSE(SpinnerController()->HasApp(kPluginVmShelfAppId));
SetListVmsResponse(vm_tools::plugin_dispatcher::VmState::VM_STATE_STOPPED);
......@@ -272,17 +272,17 @@ TEST_F(PluginVmManagerImplTest, LaunchPluginVmSpinner) {
task_environment_.RunUntilIdle();
// Spinner exists for first launch.
EXPECT_TRUE(SpinnerController()->HasApp(kPluginVmAppId));
EXPECT_TRUE(SpinnerController()->HasApp(kPluginVmShelfAppId));
// The actual flow would've launched a real window.
test_helper_->OpenShelfItem();
EXPECT_FALSE(SpinnerController()->HasApp(kPluginVmAppId));
EXPECT_FALSE(SpinnerController()->HasApp(kPluginVmShelfAppId));
test_helper_->CloseShelfItem();
plugin_vm_manager_->LaunchPluginVm(base::DoNothing());
task_environment_.RunUntilIdle();
// A second launch shouldn't show a spinner.
EXPECT_FALSE(SpinnerController()->HasApp(kPluginVmAppId));
EXPECT_FALSE(SpinnerController()->HasApp(kPluginVmShelfAppId));
}
TEST_F(PluginVmManagerImplTest, LaunchPluginVmFromSuspending) {
......@@ -301,7 +301,7 @@ TEST_F(PluginVmManagerImplTest, LaunchPluginVmFromSuspending) {
EXPECT_TRUE(VmPluginDispatcherClient().list_vms_called());
EXPECT_FALSE(VmPluginDispatcherClient().start_vm_called());
EXPECT_FALSE(VmPluginDispatcherClient().show_vm_called());
EXPECT_TRUE(SpinnerController()->HasApp(kPluginVmAppId));
EXPECT_TRUE(SpinnerController()->HasApp(kPluginVmShelfAppId));
// The launch process continues once the operation completes.
NotifyVmStateChanged(
......
......@@ -41,7 +41,7 @@ class FakeShelfItemDelegate : public ash::ShelfItemDelegate {
int64_t display_id) override {}
void Close() override {
ChromeLauncherController::instance()->CloseLauncherItem(
ash::ShelfID(kPluginVmAppId));
ash::ShelfID(kPluginVmShelfAppId));
}
};
......@@ -139,7 +139,7 @@ void PluginVmTestHelper::AllowPluginVm() {
}
void PluginVmTestHelper::OpenShelfItem() {
ash::ShelfID shelf_id(kPluginVmAppId);
ash::ShelfID shelf_id(kPluginVmShelfAppId);
std::unique_ptr<ash::ShelfItemDelegate> delegate =
std::make_unique<FakeShelfItemDelegate>(shelf_id);
ChromeLauncherController* laucher_controller =
......@@ -157,7 +157,8 @@ void PluginVmTestHelper::OpenShelfItem() {
}
void PluginVmTestHelper::CloseShelfItem() {
ChromeLauncherController::instance()->Close(ash::ShelfID(kPluginVmAppId));
ChromeLauncherController::instance()->Close(
ash::ShelfID(kPluginVmShelfAppId));
}
} // namespace plugin_vm
......@@ -123,10 +123,10 @@ bool IsPluginVmRunning(Profile* profile) {
->vm_state() ==
vm_tools::plugin_dispatcher::VmState::VM_STATE_RUNNING &&
ChromeLauncherController::instance()->IsOpen(
ash::ShelfID(kPluginVmAppId));
ash::ShelfID(kPluginVmShelfAppId));
}
bool IsPluginVmWindow(const aura::Window* window) {
bool IsPluginVmAppWindow(const aura::Window* window) {
const std::string* app_id = exo::GetShellApplicationId(window);
if (!app_id)
return false;
......
......@@ -28,7 +28,7 @@ class PluginVmPolicySubscription;
// This is used by both the Plugin VM app and its installer.
// Generated as crx_file::id_util::GenerateId("org.chromium.plugin_vm");
constexpr char kPluginVmAppId[] = "lgjpclljbbmphhnalkeplcmnjpfmmaek";
constexpr char kPluginVmShelfAppId[] = "lgjpclljbbmphhnalkeplcmnjpfmmaek";
// Name of the Plugin VM.
constexpr char kPluginVmName[] = "PvmDefault";
......@@ -74,7 +74,7 @@ void ShowPluginVmInstallerView(Profile* profile);
// Checks if an window is for the Plugin VM app. Note that it returns false for
// the Plugin VM installer.
bool IsPluginVmWindow(const aura::Window* window);
bool IsPluginVmAppWindow(const aura::Window* window);
// Retrieves the license key to be used for Plugin VM. If
// none is set this will return an empty string.
......
......@@ -130,7 +130,7 @@ void AppServiceContextMenu::ExecuteCommand(int command_id, int event_flags) {
if (app_id() == crostini::GetTerminalId()) {
crostini::CrostiniManager::GetForProfile(profile())->StopVm(
crostini::kCrostiniDefaultVmName, base::DoNothing());
} else if (app_id() == plugin_vm::kPluginVmAppId) {
} else if (app_id() == plugin_vm::kPluginVmShelfAppId) {
plugin_vm::PluginVmManagerFactory::GetForProfile(profile())
->StopPluginVm(plugin_vm::kPluginVmName, /*force=*/false);
} else {
......
......@@ -83,7 +83,7 @@ void AppServiceAppWindowCrostiniTracker::OnWindowVisibilityChanged(
// Crostini shouldn't need to know about ARC app windows.
if (wm::GetTransientParent(window) ||
arc::GetWindowTaskId(window) != arc::kNoTaskId ||
plugin_vm::IsPluginVmWindow(window)) {
plugin_vm::IsPluginVmAppWindow(window)) {
return;
}
......@@ -202,7 +202,7 @@ std::string AppServiceAppWindowCrostiniTracker::GetShelfAppId(
// Crostini shouldn't need to know about ARC app windows.
if (wm::GetTransientParent(window) ||
arc::GetWindowTaskId(window) != arc::kNoTaskId ||
plugin_vm::IsPluginVmWindow(window)) {
plugin_vm::IsPluginVmAppWindow(window)) {
return std::string();
}
......
......@@ -221,7 +221,7 @@ void AppServiceAppWindowLauncherController::OnWindowVisibilityChanged(
crostini_tracker_->OnWindowVisibilityChanged(window, shelf_id.app_id);
// This will match both the Plugin VM App window and installer.
if (shelf_id.app_id == plugin_vm::kPluginVmAppId) {
if (shelf_id.app_id == plugin_vm::kPluginVmShelfAppId) {
// Plugin VM can only be used on the primary profile.
MultiUserWindowManagerHelper::GetWindowManager()->SetWindowOwner(
window,
......@@ -564,8 +564,8 @@ ash::ShelfID AppServiceAppWindowLauncherController::GetShelfId(
return ash::ShelfID(shelf_app_id);
}
if (plugin_vm::IsPluginVmWindow(window))
return ash::ShelfID(plugin_vm::kPluginVmAppId);
if (plugin_vm::IsPluginVmAppWindow(window))
return ash::ShelfID(plugin_vm::kPluginVmShelfAppId);
ash::ShelfID shelf_id;
if (arc_tracker_)
......
......@@ -146,7 +146,7 @@ void AppServiceShelfContextMenu::ExecuteCommand(int command_id,
if (item().id.app_id == crostini::GetTerminalId()) {
crostini::CrostiniManager::GetForProfile(controller()->profile())
->StopVm(crostini::kCrostiniDefaultVmName, base::DoNothing());
} else if (item().id.app_id == plugin_vm::kPluginVmAppId) {
} else if (item().id.app_id == plugin_vm::kPluginVmShelfAppId) {
plugin_vm::PluginVmManagerFactory::GetForProfile(
controller()->profile())
->StopPluginVm(plugin_vm::kPluginVmName, /*force=*/false);
......
......@@ -176,7 +176,7 @@ void CrostiniAppWindowShelfController::OnWindowVisibilityChanging(
// know about them.
if (wm::GetTransientParent(window) ||
arc::GetWindowTaskId(window) != arc::kNoTaskId ||
plugin_vm::IsPluginVmWindow(window)) {
plugin_vm::IsPluginVmAppWindow(window)) {
DCHECK(aura_window_to_app_window_.find(window) ==
aura_window_to_app_window_.end());
auto it = observed_windows_.find(window);
......
......@@ -99,9 +99,9 @@ void InternalAppWindowShelfController::OnWindowVisibilityChanging(
ash::ShelfID::Deserialize(window->GetProperty(ash::kShelfIDKey));
if (shelf_id.IsNull()) {
if (!plugin_vm::IsPluginVmWindow(window))
if (!plugin_vm::IsPluginVmAppWindow(window))
return;
shelf_id = ash::ShelfID(plugin_vm::kPluginVmAppId);
shelf_id = ash::ShelfID(plugin_vm::kPluginVmShelfAppId);
window->SetProperty(ash::kShelfIDKey,
new std::string(shelf_id.Serialize()));
window->SetProperty(ash::kAppIDKey, new std::string(shelf_id.app_id));
......@@ -147,7 +147,7 @@ void InternalAppWindowShelfController::RegisterAppWindow(
// Plugin VM is only allowed on the primary profile. If the user switches
// profile while it is launching, we associate it with the primary profile,
// which hides the window, and don't show it on the shelf.
if (shelf_id.app_id == plugin_vm::kPluginVmAppId)
if (shelf_id.app_id == plugin_vm::kPluginVmShelfAppId)
window_owner = user_manager::UserManager::Get()->GetPrimaryUser();
else
window_owner = user_manager::UserManager::Get()->GetActiveUser();
......
......@@ -77,7 +77,8 @@ void plugin_vm::ShowPluginVmInstallerView(Profile* profile) {
views::DialogDelegate::CreateDialogWidget(g_plugin_vm_installer_view,
nullptr, nullptr);
g_plugin_vm_installer_view->GetWidget()->GetNativeWindow()->SetProperty(
ash::kShelfIDKey, ash::ShelfID(plugin_vm::kPluginVmAppId).Serialize());
ash::kShelfIDKey,
ash::ShelfID(plugin_vm::kPluginVmShelfAppId).Serialize());
}
g_plugin_vm_installer_view->SetButtonRowInsets(kButtonRowInsets);
g_plugin_vm_installer_view->GetWidget()->Show();
......
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