Commit 37c2c20f authored by dsodman's avatar dsodman Committed by Commit bot

Support transition between chrome and user mode console

Freon supports a user mode console that is drm based.  So,
to transition between the user console and chrome, we will
initiate dbus messages to effect the transition.  This change
is the chromeos/dbus part.

BUG=406031
TEST=test with user mode console

Review URL: https://codereview.chromium.org/697493002

Cr-Commit-Position: refs/heads/master@{#302666}
parent eeee2a4c
...@@ -423,7 +423,7 @@ deps_os = { ...@@ -423,7 +423,7 @@ deps_os = {
# For Linux and Chromium OS. # For Linux and Chromium OS.
'src/third_party/cros_system_api': 'src/third_party/cros_system_api':
Var('chromium_git') + '/chromiumos/platform/system_api.git' + '@' + '7d5f30c6bd012260e5266c6e9624f4fed91eb852', Var('chromium_git') + '/chromiumos/platform/system_api.git' + '@' + '6c4df7fe9cb9270256b7f474b77b9e29b096c707',
# Note that this is different from Android's freetype repo. # Note that this is different from Android's freetype repo.
'src/third_party/freetype2/src': 'src/third_party/freetype2/src':
......
// Copyright 2014 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/console_service_provider.h"
#include "ash/shell.h"
#include "base/bind.h"
#include "dbus/message.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
#include "ui/display/chromeos/display_configurator.h"
namespace chromeos {
ConsoleServiceProvider::ConsoleServiceProvider() : weak_ptr_factory_(this) {
}
ConsoleServiceProvider::~ConsoleServiceProvider() {
}
void ConsoleServiceProvider::Start(
scoped_refptr<dbus::ExportedObject> exported_object) {
exported_object->ExportMethod(
kLibCrosServiceInterface, kTakeDisplayOwnership,
base::Bind(&ConsoleServiceProvider::TakeDisplayOwnership,
weak_ptr_factory_.GetWeakPtr()),
base::Bind(&ConsoleServiceProvider::OnExported,
weak_ptr_factory_.GetWeakPtr()));
exported_object->ExportMethod(
kLibCrosServiceInterface, kReleaseDisplayOwnership,
base::Bind(&ConsoleServiceProvider::ReleaseDisplayOwnership,
weak_ptr_factory_.GetWeakPtr()),
base::Bind(&ConsoleServiceProvider::OnExported,
weak_ptr_factory_.GetWeakPtr()));
}
void ConsoleServiceProvider::TakeDisplayOwnership(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) {
ash::Shell::GetInstance()->display_configurator()->TakeControl();
response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
void ConsoleServiceProvider::ReleaseDisplayOwnership(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) {
ash::Shell::GetInstance()->display_configurator()->RelinquishControl();
response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
void ConsoleServiceProvider::OnExported(const std::string& interface_name,
const std::string& method_name,
bool success) {
if (!success)
LOG(ERROR) << "failed to export " << interface_name << "." << method_name;
}
} // namespace chromeos
// Copyright 2014 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_CONSOLE_SERVICE_PROVIDER_H_
#define CHROME_BROWSER_CHROMEOS_DBUS_CONSOLE_SERVICE_PROVIDER_H_
#include <string>
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/dbus/cros_dbus_service.h"
#include "dbus/exported_object.h"
namespace chromeos {
// This class provides an API for external apps to notify
// chrome that it should release control of the display server.
// The main client is the console application. This can
// also be used by crouton to take over the display.
class ConsoleServiceProvider
: public CrosDBusService::ServiceProviderInterface {
public:
ConsoleServiceProvider();
~ConsoleServiceProvider() override;
// CrosDBusService::ServiceProviderInterface overrides:
void Start(scoped_refptr<dbus::ExportedObject> exported_object) override;
private:
// This method will get called when a external process no longer needs
// control of the display and Chrome can take ownership.
void TakeDisplayOwnership(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender);
// This method will get called when a external process needs control of
// the display and needs Chrome to release ownership.
void ReleaseDisplayOwnership(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender);
// This method is called when a dbus method is exported. If the export of the
// method is successful, |success| will be true. It will be false
// otherwise.
void OnExported(const std::string& interface_name,
const std::string& method_name,
bool success);
base::WeakPtrFactory<ConsoleServiceProvider> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ConsoleServiceProvider);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_DBUS_CONSOLE_SERVICE_PROVIDER_H_
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/sys_info.h" #include "base/sys_info.h"
#include "base/threading/platform_thread.h" #include "base/threading/platform_thread.h"
#include "chrome/browser/chromeos/dbus/console_service_provider.h"
#include "chrome/browser/chromeos/dbus/display_power_service_provider.h" #include "chrome/browser/chromeos/dbus/display_power_service_provider.h"
#include "chrome/browser/chromeos/dbus/liveness_service_provider.h" #include "chrome/browser/chromeos/dbus/liveness_service_provider.h"
#include "chrome/browser/chromeos/dbus/printer_service_provider.h" #include "chrome/browser/chromeos/dbus/printer_service_provider.h"
...@@ -130,6 +131,7 @@ void CrosDBusService::Initialize() { ...@@ -130,6 +131,7 @@ void CrosDBusService::Initialize() {
#endif #endif
service->RegisterServiceProvider(new LivenessServiceProvider); service->RegisterServiceProvider(new LivenessServiceProvider);
service->RegisterServiceProvider(new ScreenLockServiceProvider); service->RegisterServiceProvider(new ScreenLockServiceProvider);
service->RegisterServiceProvider(new ConsoleServiceProvider);
g_cros_dbus_service = service; g_cros_dbus_service = service;
service->Start(); service->Start();
} else { } else {
......
...@@ -77,6 +77,8 @@ ...@@ -77,6 +77,8 @@
'browser/chromeos/display/display_preferences.h', 'browser/chromeos/display/display_preferences.h',
'browser/chromeos/display/overscan_calibrator.cc', 'browser/chromeos/display/overscan_calibrator.cc',
'browser/chromeos/display/overscan_calibrator.h', 'browser/chromeos/display/overscan_calibrator.h',
'browser/chromeos/dbus/console_service_provider.cc',
'browser/chromeos/dbus/console_service_provider.h',
'browser/chromeos/dbus/cros_dbus_service.cc', 'browser/chromeos/dbus/cros_dbus_service.cc',
'browser/chromeos/dbus/cros_dbus_service.h', 'browser/chromeos/dbus/cros_dbus_service.h',
'browser/chromeos/dbus/display_power_service_provider.cc', 'browser/chromeos/dbus/display_power_service_provider.cc',
......
...@@ -201,6 +201,14 @@ void DisplayConfigurator::Init(bool is_panel_fitting_enabled) { ...@@ -201,6 +201,14 @@ void DisplayConfigurator::Init(bool is_panel_fitting_enabled) {
} }
} }
void DisplayConfigurator::TakeControl() {
NOTIMPLEMENTED();
}
void DisplayConfigurator::RelinquishControl() {
NOTIMPLEMENTED();
}
void DisplayConfigurator::ForceInitialConfigure( void DisplayConfigurator::ForceInitialConfigure(
uint32_t background_color_argb) { uint32_t background_color_argb) {
if (!configure_display_) if (!configure_display_)
......
...@@ -145,6 +145,14 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { ...@@ -145,6 +145,14 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver {
return cached_displays_; return cached_displays_;
} }
// Called when an external process no longer needs to control the display
// and Chrome can take control.
void TakeControl();
// Called when an external process needs to control the display and thus
// Chrome should relinquish it.
void RelinquishControl();
void set_state_controller(StateController* controller) { void set_state_controller(StateController* controller) {
state_controller_ = controller; state_controller_ = controller;
} }
......
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