shell_runtime_api_delegate.cc revision 5f1c94371a64b3196d4be9466099bb892df9b88e
1// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "extensions/shell/browser/shell_runtime_api_delegate.h"
6
7#include "extensions/common/api/runtime.h"
8
9#if defined(OS_CHROMEOS)
10#include "chromeos/dbus/dbus_thread_manager.h"
11#include "chromeos/dbus/power_manager_client.h"
12#endif
13
14using extensions::core_api::runtime::PlatformInfo;
15
16namespace extensions {
17
18ShellRuntimeAPIDelegate::ShellRuntimeAPIDelegate() {
19}
20
21ShellRuntimeAPIDelegate::~ShellRuntimeAPIDelegate() {
22}
23
24void ShellRuntimeAPIDelegate::AddUpdateObserver(UpdateObserver* observer) {
25}
26
27void ShellRuntimeAPIDelegate::RemoveUpdateObserver(UpdateObserver* observer) {
28}
29
30base::Version ShellRuntimeAPIDelegate::GetPreviousExtensionVersion(
31    const Extension* extension) {
32  return base::Version();
33}
34
35void ShellRuntimeAPIDelegate::ReloadExtension(const std::string& extension_id) {
36}
37
38bool ShellRuntimeAPIDelegate::CheckForUpdates(
39    const std::string& extension_id,
40    const UpdateCheckCallback& callback) {
41  return false;
42}
43
44void ShellRuntimeAPIDelegate::OpenURL(const GURL& uninstall_url) {
45}
46
47bool ShellRuntimeAPIDelegate::GetPlatformInfo(PlatformInfo* info) {
48#if defined(OS_CHROMEOS)
49  info->os = PlatformInfo::OS_CROS_;
50#elif defined(OS_LINUX)
51  info->os = PlatformInfo::OS_LINUX_;
52#endif
53  return true;
54}
55
56bool ShellRuntimeAPIDelegate::RestartDevice(std::string* error_message) {
57// We allow chrome.runtime.restart() to request a device restart on ChromeOS.
58#if defined(OS_CHROMEOS)
59  chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart();
60  return true;
61#endif
62  *error_message = "Restart is only supported on ChromeOS.";
63  return false;
64}
65
66}  // namespace extensions
67