Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Commit

Permalink
Move IsRunningOnChromeOS to base/chromeos so that ui/, /chromeos and …
Browse files Browse the repository at this point in the history
…other components can use it.

plus, a couple of cleanups including
 - removed unnecessary includes
 - removed unnecessary ifdef chromeos in chromeos only code.

BUG=115967
TEST=none

Review URL: http://codereview.chromium.org/9546013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127283 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
oshima@chromium.org committed Mar 16, 2012
1 parent 3e00090 commit c1dd7bf
Show file tree
Hide file tree
Showing 48 changed files with 117 additions and 142 deletions.
7 changes: 7 additions & 0 deletions base/base.gypi
Expand Up @@ -62,6 +62,8 @@
'callback_internal.cc',
'callback_internal.h',
'cancelable_callback.h',
'chromeos/chromeos_version.cc',
'chromeos/chromeos_version.h',
'command_line.cc',
'command_line.h',
'compiler_specific.h',
Expand Down Expand Up @@ -549,6 +551,11 @@
['exclude', '^sys_info_linux\\.cc$'],
],
}],
[ 'chromeos != 1', {
'sources/': [
['exclude', '^chromeos/'],
],
}],
],
}],
],
Expand Down
@@ -1,17 +1,16 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 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/system/runtime_environment.h"
#include "base/chromeos/chromeos_version.h"

#include <stdlib.h>
#include <string.h>

#include "base/logging.h"

namespace base {
namespace chromeos {
namespace system {
namespace runtime_environment {

bool IsRunningOnChromeOS() {
// Check if the user name is chronos. Note that we don't go with
Expand All @@ -21,6 +20,5 @@ bool IsRunningOnChromeOS() {
return user && strcmp(user, "chronos") == 0;
}

} // namespace runtime_environment
} // namespace system
} // namespace chromeos
} // namespace base
21 changes: 21 additions & 0 deletions base/chromeos/chromeos_version.h
@@ -0,0 +1,21 @@
// Copyright (c) 2012 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 BASE_CHROMEOS_CHROMEOS_VERSION_H_
#define BASE_CHROMEOS_CHROMEOS_VERSION_H_
#pragma once

#include "base/base_export.h"

namespace base {
namespace chromeos {

// Returns true if the browser is running on Chrome OS.
// Useful for implementing stubs for Linux desktop.
BASE_EXPORT bool IsRunningOnChromeOS();

} // namespace chromeos
} // namespace base

#endif // BASE_CHROMEOS_CHROMEOS_VERSION_H_
4 changes: 2 additions & 2 deletions chrome/browser/chrome_browser_main_extra_parts_ash.cc
Expand Up @@ -20,12 +20,12 @@
#include "ui/gfx/compositor/compositor_setup.h"

#if defined(OS_CHROMEOS)
#include "base/chromeos/chromeos_version.h"
#include "chrome/browser/ui/views/ash/brightness_controller_chromeos.h"
#include "chrome/browser/ui/views/ash/ime_controller_chromeos.h"
#include "chrome/browser/ui/views/ash/volume_controller_chromeos.h"
#include "chrome/browser/chromeos/input_method/input_method_manager.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/system/runtime_environment.h"
#endif

ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh()
Expand All @@ -34,7 +34,7 @@ ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh()

void ChromeBrowserMainExtraPartsAsh::PreProfileInit() {
#if defined(OS_CHROMEOS)
if (chromeos::system::runtime_environment::IsRunningOnChromeOS() ||
if (base::chromeos::IsRunningOnChromeOS() ||
CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAuraHostWindowUseFullscreen)) {
aura::RootWindow::set_use_fullscreen_host_window(true);
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/audio/audio_mixer_alsa.cc
Expand Up @@ -13,11 +13,11 @@

#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/chromeos/chromeos_version.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "chrome/browser/extensions/extension_tts_api_chromeos.h"
#include "content/public/browser/browser_thread.h"

Expand Down Expand Up @@ -151,7 +151,7 @@ void AudioMixerAlsa::Connect() {
return;

// Do not attempt to connect if we're not on the device.
if (!system::runtime_environment::IsRunningOnChromeOS())
if (!base::chromeos::IsRunningOnChromeOS())
return;

if (!ConnectInternal()) {
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/chromeos/chrome_browser_main_chromeos.cc
Expand Up @@ -6,6 +6,7 @@

#include "base/bind.h"
#include "base/callback.h"
#include "base/chromeos/chromeos_version.h"
#include "base/command_line.h"
#include "base/lazy_instance.h"
#include "base/message_loop.h"
Expand Down Expand Up @@ -38,7 +39,6 @@
#include "chrome/browser/chromeos/power/resume_observer.h"
#include "chrome/browser/chromeos/power/screen_lock_observer.h"
#include "chrome/browser/chromeos/status/status_area_view_chromeos.h"
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "chrome/browser/chromeos/system/statistics_provider.h"
#include "chrome/browser/chromeos/system_key_event_listener.h"
#include "chrome/browser/chromeos/upgrade_detector_chromeos.h"
Expand Down Expand Up @@ -306,7 +306,7 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() {
// detector starts to monitor changes from the update engine.
UpgradeDetectorChromeos::GetInstance()->Init();

if (chromeos::system::runtime_environment::IsRunningOnChromeOS()) {
if (base::chromeos::IsRunningOnChromeOS()) {
// Enable Num Lock on X start up for http://crosbug.com/p/5795 and
// http://crosbug.com/p/6245. We don't do this for Chromium OS since many
// netbooks do not work as intended when Num Lock is on (e.g. On a netbook
Expand Down Expand Up @@ -336,7 +336,7 @@ void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() {
// volume on the login screen, if Chrome is running on Chrome OS
// (i.e. not Linux desktop), and in non-test mode.
// Note: SystemKeyEventListener depends on the DBus thread.
if (chromeos::system::runtime_environment::IsRunningOnChromeOS() &&
if (base::chromeos::IsRunningOnChromeOS() &&
!parameters().ui_task) { // ui_task is non-NULL when running tests.
chromeos::SystemKeyEventListener::Initialize();
}
Expand Down
Expand Up @@ -21,7 +21,6 @@
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "chrome/browser/net/pref_proxy_config_tracker_impl.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/testing_browser_process.h"
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/dbus/bluetooth_adapter_client.cc
Expand Up @@ -7,12 +7,12 @@
#include <map>

#include "base/bind.h"
#include "base/chromeos/chromeos_version.h"
#include "base/logging.h"
#include "base/stl_util.h"
#include "chrome/browser/chromeos/dbus/bluetooth_device_client.h"
#include "chrome/browser/chromeos/dbus/bluetooth_manager_client.h"
#include "chrome/browser/chromeos/dbus/bluetooth_property.h"
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
Expand Down Expand Up @@ -800,7 +800,7 @@ BluetoothAdapterClient::~BluetoothAdapterClient() {
BluetoothAdapterClient* BluetoothAdapterClient::Create(
dbus::Bus* bus,
BluetoothManagerClient* manager_client) {
if (system::runtime_environment::IsRunningOnChromeOS()) {
if (base::chromeos::IsRunningOnChromeOS()) {
return new BluetoothAdapterClientImpl(bus, manager_client);
} else {
return new BluetoothAdapterClientStubImpl();
Expand Down
Expand Up @@ -7,10 +7,10 @@
#include <string>

#include "base/bind.h"
#include "base/chromeos/chromeos_version.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/threading/platform_thread.h"
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "dbus/bus.h"
#include "dbus/exported_object.h"
#include "dbus/message.h"
Expand Down Expand Up @@ -558,7 +558,7 @@ BluetoothAgentServiceProvider* BluetoothAgentServiceProvider::Create(
dbus::Bus* bus,
const dbus::ObjectPath& object_path,
Delegate* delegate) {
if (system::runtime_environment::IsRunningOnChromeOS()) {
if (base::chromeos::IsRunningOnChromeOS()) {
return new BluetoothAgentServiceProviderImpl(bus, object_path, delegate);
} else {
return new BluetoothAgentServiceProviderStubImpl(delegate);
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/dbus/bluetooth_device_client.cc
Expand Up @@ -7,11 +7,11 @@
#include <map>

#include "base/bind.h"
#include "base/chromeos/chromeos_version.h"
#include "base/logging.h"
#include "base/stl_util.h"
#include "chrome/browser/chromeos/dbus/bluetooth_adapter_client.h"
#include "chrome/browser/chromeos/dbus/bluetooth_property.h"
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
Expand Down Expand Up @@ -530,7 +530,7 @@ BluetoothDeviceClient::~BluetoothDeviceClient() {
BluetoothDeviceClient* BluetoothDeviceClient::Create(
dbus::Bus* bus,
BluetoothAdapterClient* adapter_client) {
if (system::runtime_environment::IsRunningOnChromeOS()) {
if (base::chromeos::IsRunningOnChromeOS()) {
return new BluetoothDeviceClientImpl(bus, adapter_client);
} else {
return new BluetoothDeviceClientStubImpl();
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/dbus/bluetooth_input_client.cc
Expand Up @@ -7,11 +7,11 @@
#include <map>

#include "base/bind.h"
#include "base/chromeos/chromeos_version.h"
#include "base/logging.h"
#include "base/stl_util.h"
#include "chrome/browser/chromeos/dbus/bluetooth_adapter_client.h"
#include "chrome/browser/chromeos/dbus/bluetooth_property.h"
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
Expand Down Expand Up @@ -255,7 +255,7 @@ BluetoothInputClient::~BluetoothInputClient() {
BluetoothInputClient* BluetoothInputClient::Create(
dbus::Bus* bus,
BluetoothAdapterClient* adapter_client) {
if (system::runtime_environment::IsRunningOnChromeOS()) {
if (base::chromeos::IsRunningOnChromeOS()) {
return new BluetoothInputClientImpl(bus, adapter_client);
} else {
return new BluetoothInputClientStubImpl();
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/dbus/bluetooth_manager_client.cc
Expand Up @@ -5,9 +5,9 @@
#include "chrome/browser/chromeos/dbus/bluetooth_manager_client.h"

#include "base/bind.h"
#include "base/chromeos/chromeos_version.h"
#include "base/logging.h"
#include "chrome/browser/chromeos/dbus/bluetooth_property.h"
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
Expand Down Expand Up @@ -306,7 +306,7 @@ BluetoothManagerClient::~BluetoothManagerClient() {
}

BluetoothManagerClient* BluetoothManagerClient::Create(dbus::Bus* bus) {
if (system::runtime_environment::IsRunningOnChromeOS()) {
if (base::chromeos::IsRunningOnChromeOS()) {
return new BluetoothManagerClientImpl(bus);
} else {
return new BluetoothManagerClientStubImpl();
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/dbus/bluetooth_node_client.cc
Expand Up @@ -7,11 +7,11 @@
#include <map>

#include "base/bind.h"
#include "base/chromeos/chromeos_version.h"
#include "base/logging.h"
#include "base/stl_util.h"
#include "chrome/browser/chromeos/dbus/bluetooth_device_client.h"
#include "chrome/browser/chromeos/dbus/bluetooth_property.h"
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
Expand Down Expand Up @@ -192,7 +192,7 @@ BluetoothNodeClient::~BluetoothNodeClient() {
BluetoothNodeClient* BluetoothNodeClient::Create(
dbus::Bus* bus,
BluetoothDeviceClient* adapter_client) {
if (system::runtime_environment::IsRunningOnChromeOS()) {
if (base::chromeos::IsRunningOnChromeOS()) {
return new BluetoothNodeClientImpl(bus, adapter_client);
} else {
return new BluetoothNodeClientStubImpl();
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/dbus/cros_dbus_service.cc
Expand Up @@ -5,10 +5,10 @@
#include "chrome/browser/chromeos/dbus/cros_dbus_service.h"

#include "base/bind.h"
#include "base/chromeos/chromeos_version.h"
#include "base/stl_util.h"
#include "base/threading/platform_thread.h"
#include "chrome/browser/chromeos/dbus/proxy_resolution_service_provider.h"
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "content/public/browser/browser_thread.h"
#include "dbus/bus.h"
#include "dbus/exported_object.h"
Expand Down Expand Up @@ -99,7 +99,7 @@ class CrosDBusServiceStubImpl : public CrosDBusService {

// static
CrosDBusService* CrosDBusService::Create(dbus::Bus* bus) {
if (system::runtime_environment::IsRunningOnChromeOS()) {
if (base::chromeos::IsRunningOnChromeOS()) {
CrosDBusServiceImpl* service = new CrosDBusServiceImpl(bus);
service->RegisterServiceProvider(ProxyResolutionServiceProvider::Create());
return service;
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/dbus/cros_disks_client.cc
Expand Up @@ -5,8 +5,8 @@
#include "chrome/browser/chromeos/dbus/cros_disks_client.h"

#include "base/bind.h"
#include "base/chromeos/chromeos_version.h"
#include "base/stl_util.h"
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
Expand Down Expand Up @@ -557,7 +557,7 @@ CrosDisksClient::~CrosDisksClient() {}

// static
CrosDisksClient* CrosDisksClient::Create(dbus::Bus* bus) {
if (system::runtime_environment::IsRunningOnChromeOS())
if (base::chromeos::IsRunningOnChromeOS())
return new CrosDisksClientImpl(bus);
else
return new CrosDisksClientStubImpl();
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/dbus/cryptohome_client.cc
Expand Up @@ -5,8 +5,8 @@
#include "chrome/browser/chromeos/dbus/cryptohome_client.h"

#include "base/bind.h"
#include "base/chromeos/chromeos_version.h"
#include "base/synchronization/waitable_event.h"
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "content/public/browser/browser_thread.h"
#include "dbus/bus.h"
#include "dbus/message.h"
Expand Down Expand Up @@ -657,7 +657,7 @@ CryptohomeClient::~CryptohomeClient() {}

// static
CryptohomeClient* CryptohomeClient::Create(dbus::Bus* bus) {
if (system::runtime_environment::IsRunningOnChromeOS())
if (base::chromeos::IsRunningOnChromeOS())
return new CryptohomeClientImpl(bus);
else
return new CryptohomeClientStubImpl();
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/dbus/image_burner_client.cc
Expand Up @@ -5,8 +5,8 @@
#include "chrome/browser/chromeos/dbus/image_burner_client.h"

#include "base/bind.h"
#include "base/chromeos/chromeos_version.h"
#include "base/compiler_specific.h"
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
Expand Down Expand Up @@ -157,7 +157,7 @@ ImageBurnerClient::~ImageBurnerClient() {

// static
ImageBurnerClient* ImageBurnerClient::Create(dbus::Bus* bus) {
if (system::runtime_environment::IsRunningOnChromeOS()) {
if (base::chromeos::IsRunningOnChromeOS()) {
return new ImageBurnerClientImpl(bus);
} else {
return new ImageBurnerClientStubImpl();
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/dbus/introspectable_client.cc
Expand Up @@ -9,7 +9,7 @@

#include "base/bind.h"
#include "base/logging.h"
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "base/chromeos/chromeos_version.h"
#include "chrome/common/libxml_utils.h"
#include "dbus/bus.h"
#include "dbus/message.h"
Expand Down Expand Up @@ -144,7 +144,7 @@ std::vector<std::string> IntrospectableClient::GetInterfacesFromXmlData(

// static
IntrospectableClient* IntrospectableClient::Create(dbus::Bus* bus) {
if (system::runtime_environment::IsRunningOnChromeOS()) {
if (base::chromeos::IsRunningOnChromeOS()) {
return new IntrospectableClientImpl(bus);
} else {
return new IntrospectableClientStubImpl();
Expand Down

0 comments on commit c1dd7bf

Please sign in to comment.