Commit 3924f9be authored by Daniel Erat's avatar Daniel Erat Committed by Commit Bot

chromeos: Remove VmApplicationsServiceProvider::Delegate.

Now that VmApplicationsServiceProvider lives in
//chrome/browser/chromeos/dbus, it no longer needs a
Delegate interface.

Bug: 843392
Change-Id: I1c9a0cf0a251d12bf3a0c33a58b0d6e177859618
Reviewed-on: https://chromium-review.googlesource.com/1184142Reviewed-by: default avatarTimothy Loh <timloh@chromium.org>
Commit-Queue: Dan Erat <derat@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584931}
parent be6556aa
......@@ -609,8 +609,6 @@ source_set("chromeos") {
"dbus/virtual_file_request_service_provider.h",
"dbus/vm_applications_service_provider.cc",
"dbus/vm_applications_service_provider.h",
"dbus/vm_applications_service_provider_delegate.cc",
"dbus/vm_applications_service_provider_delegate.h",
"device_sync/device_sync_client_factory.cc",
"device_sync/device_sync_client_factory.h",
"display/output_protection_controller_ash.cc",
......
......@@ -56,7 +56,6 @@
#include "chrome/browser/chromeos/dbus/screen_lock_service_provider.h"
#include "chrome/browser/chromeos/dbus/virtual_file_request_service_provider.h"
#include "chrome/browser/chromeos/dbus/vm_applications_service_provider.h"
#include "chrome/browser/chromeos/dbus/vm_applications_service_provider_delegate.h"
#include "chrome/browser/chromeos/display/quirks_manager_delegate_impl.h"
#include "chrome/browser/chromeos/events/event_rewriter_delegate_impl.h"
#include "chrome/browser/chromeos/extensions/default_app_order.h"
......@@ -371,8 +370,7 @@ class DBusServices {
vm_tools::apps::kVmApplicationsServiceName,
dbus::ObjectPath(vm_tools::apps::kVmApplicationsServicePath),
CrosDBusService::CreateServiceProviderList(
std::make_unique<VmApplicationsServiceProvider>(
std::make_unique<VmApplicationsServiceProviderDelegate>())));
std::make_unique<VmApplicationsServiceProvider>()));
drive_file_stream_service_ = CrosDBusService::Create(
drivefs::kDriveFileStreamServiceName,
......
......@@ -4,7 +4,16 @@
#include "chrome/browser/chromeos/dbus/vm_applications_service_provider.h"
#include <string>
#include <vector>
#include "base/bind.h"
#include "chrome/browser/chromeos/crostini/crostini_manager.h"
#include "chrome/browser/chromeos/crostini/crostini_registry_service.h"
#include "chrome/browser/chromeos/crostini/crostini_registry_service_factory.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chromeos/dbus/vm_applications/apps.pb.h"
#include "dbus/bus.h"
#include "dbus/message.h"
......@@ -12,9 +21,8 @@
namespace chromeos {
VmApplicationsServiceProvider::VmApplicationsServiceProvider(
std::unique_ptr<Delegate> delegate)
: delegate_(std::move(delegate)), weak_ptr_factory_(this) {}
VmApplicationsServiceProvider::VmApplicationsServiceProvider()
: weak_ptr_factory_(this) {}
VmApplicationsServiceProvider::~VmApplicationsServiceProvider() = default;
......@@ -60,7 +68,13 @@ void VmApplicationsServiceProvider::UpdateApplicationList(
return;
}
delegate_->UpdateApplicationList(request);
Profile* profile = ProfileManager::GetPrimaryUserProfile();
if (ProfileHelper::IsPrimaryProfile(profile)) {
crostini::CrostiniRegistryService* registry_service =
crostini::CrostiniRegistryServiceFactory::GetForProfile(profile);
registry_service->UpdateApplicationList(request);
}
response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
......@@ -80,7 +94,15 @@ void VmApplicationsServiceProvider::LaunchTerminal(
return;
}
delegate_->LaunchTerminal(request);
Profile* profile = ProfileManager::GetPrimaryUserProfile();
if (ProfileHelper::IsPrimaryProfile(profile) &&
request.owner_id() == CryptohomeIdForProfile(profile)) {
crostini::CrostiniManager::GetInstance()->LaunchContainerTerminal(
profile, request.vm_name(), request.container_name(),
std::vector<std::string>(request.params().begin(),
request.params().end()));
}
response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
......
......@@ -5,8 +5,6 @@
#ifndef CHROME_BROWSER_CHROMEOS_DBUS_VM_APPLICATIONS_SERVICE_PROVIDER_H_
#define CHROME_BROWSER_CHROMEOS_DBUS_VM_APPLICATIONS_SERVICE_PROVIDER_H_
#include <memory>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
......@@ -17,13 +15,6 @@ namespace dbus {
class MethodCall;
} // namespace dbus
namespace vm_tools {
namespace apps {
class ApplicationList;
class TerminalParams;
} // namespace apps
} // namespace vm_tools
namespace chromeos {
// This class exports D-Bus methods for functions that we want to be available
......@@ -31,24 +22,7 @@ namespace chromeos {
class VmApplicationsServiceProvider
: public CrosDBusService::ServiceProviderInterface {
public:
// Delegate interface providing additional resources to
// VmApplicationsServiceProvider.
// TODO(derat): Move the delegate into this class.
class Delegate {
public:
Delegate() = default;
virtual ~Delegate() = default;
virtual void UpdateApplicationList(
const vm_tools::apps::ApplicationList& app_list) = 0;
virtual void LaunchTerminal(
const vm_tools::apps::TerminalParams& terminal_params) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(Delegate);
};
explicit VmApplicationsServiceProvider(std::unique_ptr<Delegate> delegate);
VmApplicationsServiceProvider();
~VmApplicationsServiceProvider() override;
// CrosDBusService::ServiceProviderInterface overrides:
......@@ -68,8 +42,6 @@ class VmApplicationsServiceProvider
void LaunchTerminal(dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender);
std::unique_ptr<Delegate> delegate_;
base::WeakPtrFactory<VmApplicationsServiceProvider> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(VmApplicationsServiceProvider);
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/dbus/vm_applications_service_provider_delegate.h"
#include "chrome/browser/chromeos/crostini/crostini_manager.h"
#include "chrome/browser/chromeos/crostini/crostini_registry_service.h"
#include "chrome/browser/chromeos/crostini/crostini_registry_service_factory.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chromeos/dbus/vm_applications/apps.pb.h"
namespace chromeos {
VmApplicationsServiceProviderDelegate::VmApplicationsServiceProviderDelegate() =
default;
VmApplicationsServiceProviderDelegate::
~VmApplicationsServiceProviderDelegate() = default;
void VmApplicationsServiceProviderDelegate::UpdateApplicationList(
const vm_tools::apps::ApplicationList& app_list) {
Profile* profile = ProfileManager::GetPrimaryUserProfile();
if (!ProfileHelper::IsPrimaryProfile(profile))
return;
crostini::CrostiniRegistryService* registry_service =
crostini::CrostiniRegistryServiceFactory::GetForProfile(profile);
registry_service->UpdateApplicationList(app_list);
}
void VmApplicationsServiceProviderDelegate::LaunchTerminal(
const vm_tools::apps::TerminalParams& terminal_params) {
Profile* profile = ProfileManager::GetPrimaryUserProfile();
if (!ProfileHelper::IsPrimaryProfile(profile) ||
terminal_params.owner_id() != CryptohomeIdForProfile(profile))
return;
crostini::CrostiniManager::GetInstance()->LaunchContainerTerminal(
profile, terminal_params.vm_name(), terminal_params.container_name(),
std::vector<std::string>(terminal_params.params().begin(),
terminal_params.params().end()));
}
} // namespace chromeos
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_DBUS_VM_APPLICATIONS_SERVICE_PROVIDER_DELEGATE_H_
#define CHROME_BROWSER_CHROMEOS_DBUS_VM_APPLICATIONS_SERVICE_PROVIDER_DELEGATE_H_
#include "base/macros.h"
#include "chrome/browser/chromeos/dbus/vm_applications_service_provider.h"
namespace chromeos {
class VmApplicationsServiceProviderDelegate
: public VmApplicationsServiceProvider::Delegate {
public:
VmApplicationsServiceProviderDelegate();
~VmApplicationsServiceProviderDelegate() override;
// VmApplicationsServiceProvider::Delegate:
void UpdateApplicationList(
const vm_tools::apps::ApplicationList& app_list) override;
void LaunchTerminal(
const vm_tools::apps::TerminalParams& terminal_params) override;
private:
DISALLOW_COPY_AND_ASSIGN(VmApplicationsServiceProviderDelegate);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_DBUS_VM_APPLICATIONS_SERVICE_PROVIDER_DELEGATE_H_
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