| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/dbus/kiosk_info_service_provider.h" | 5 #include "chrome/browser/chromeos/dbus/kiosk_info_service_provider.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 12 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
| 13 #include "dbus/message.h" | 13 #include "dbus/message.h" |
| 14 #include "third_party/cros_system_api/dbus/service_constants.h" | 14 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 15 | 15 |
| 16 namespace chromeos { | 16 namespace chromeos { |
| 17 | 17 |
| 18 KioskInfoService::KioskInfoService() : weak_ptr_factory_(this) {} | 18 KioskInfoService::KioskInfoService(const std::string& service_interface, |
| 19 const std::string& method_name) |
| 20 : service_interface_(service_interface), |
| 21 method_name_(method_name), |
| 22 weak_ptr_factory_(this) {} |
| 19 | 23 |
| 20 KioskInfoService::~KioskInfoService() {} | 24 KioskInfoService::~KioskInfoService() {} |
| 21 | 25 |
| 22 void KioskInfoService::Start( | 26 void KioskInfoService::Start( |
| 23 scoped_refptr<dbus::ExportedObject> exported_object) { | 27 scoped_refptr<dbus::ExportedObject> exported_object) { |
| 24 exported_object->ExportMethod( | 28 exported_object->ExportMethod( |
| 25 kLibCrosServiceInterface, kGetKioskAppRequiredPlatforVersion, | 29 service_interface_, method_name_, |
| 26 base::Bind(&KioskInfoService::GetKioskAppRequiredPlatformVersion, | 30 base::Bind(&KioskInfoService::GetKioskAppRequiredPlatformVersion, |
| 27 weak_ptr_factory_.GetWeakPtr()), | 31 weak_ptr_factory_.GetWeakPtr()), |
| 28 base::Bind(&KioskInfoService::OnExported, | 32 base::Bind(&KioskInfoService::OnExported, |
| 29 weak_ptr_factory_.GetWeakPtr())); | 33 weak_ptr_factory_.GetWeakPtr())); |
| 30 } | 34 } |
| 31 | 35 |
| 32 void KioskInfoService::OnExported(const std::string& interface_name, | 36 void KioskInfoService::OnExported(const std::string& interface_name, |
| 33 const std::string& method_name, | 37 const std::string& method_name, |
| 34 bool success) { | 38 bool success) { |
| 35 if (!success) | 39 if (!success) |
| 36 LOG(ERROR) << "Failed to export " << interface_name << "." << method_name; | 40 LOG(ERROR) << "Failed to export " << interface_name << "." << method_name; |
| 37 } | 41 } |
| 38 | 42 |
| 39 void KioskInfoService::GetKioskAppRequiredPlatformVersion( | 43 void KioskInfoService::GetKioskAppRequiredPlatformVersion( |
| 40 dbus::MethodCall* method_call, | 44 dbus::MethodCall* method_call, |
| 41 dbus::ExportedObject::ResponseSender response_sender) { | 45 dbus::ExportedObject::ResponseSender response_sender) { |
| 42 std::unique_ptr<dbus::Response> response = | 46 std::unique_ptr<dbus::Response> response = |
| 43 dbus::Response::FromMethodCall(method_call); | 47 dbus::Response::FromMethodCall(method_call); |
| 44 dbus::MessageWriter writer(response.get()); | 48 dbus::MessageWriter writer(response.get()); |
| 45 writer.AppendString( | 49 writer.AppendString( |
| 46 KioskAppManager::Get()->GetAutoLaunchAppRequiredPlatformVersion()); | 50 KioskAppManager::Get()->GetAutoLaunchAppRequiredPlatformVersion()); |
| 47 response_sender.Run(std::move(response)); | 51 response_sender.Run(std::move(response)); |
| 48 } | 52 } |
| 49 | 53 |
| 50 } // namespace chromeos | 54 } // namespace chromeos |
| OLD | NEW |