This source file includes following definitions.
- CalculateScreenBounds
- GetCurrentUserImageSize
- GetCurrentNetworkName
- IsConnected
- IsConnecting
#include "chrome/browser/chromeos/login/helper.h"
#include "ash/shell.h"
#include "base/strings/utf_string_conversions.h"
#include "chromeos/network/network_handler.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/shill_property_util.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/screen.h"
namespace chromeos {
gfx::Rect CalculateScreenBounds(const gfx::Size& size) {
gfx::Rect bounds(ash::Shell::GetScreen()->GetPrimaryDisplay().bounds());
if (!size.IsEmpty()) {
int horizontal_diff = bounds.width() - size.width();
int vertical_diff = bounds.height() - size.height();
bounds.Inset(horizontal_diff / 2, vertical_diff / 2);
}
return bounds;
}
int GetCurrentUserImageSize() {
static const int kBaseUserImageSize = 220;
float scale_factor = gfx::Display::GetForcedDeviceScaleFactor();
if (scale_factor > 1.0f)
return static_cast<int>(scale_factor * kBaseUserImageSize);
return kBaseUserImageSize * gfx::ImageSkia::GetMaxSupportedScale();
}
namespace login {
NetworkStateHelper::NetworkStateHelper() {}
NetworkStateHelper::~NetworkStateHelper() {}
base::string16 NetworkStateHelper::GetCurrentNetworkName() const {
NetworkStateHandler* nsh = NetworkHandler::Get()->network_state_handler();
const NetworkState* network =
nsh->ConnectedNetworkByType(NetworkTypePattern::NonVirtual());
if (network) {
if (network->Matches(NetworkTypePattern::Ethernet()))
return l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET);
return base::UTF8ToUTF16(network->name());
}
network = nsh->ConnectingNetworkByType(NetworkTypePattern::NonVirtual());
if (network) {
if (network->Matches(NetworkTypePattern::Ethernet()))
return l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET);
return base::UTF8ToUTF16(network->name());
}
return base::string16();
}
bool NetworkStateHelper::IsConnected() const {
chromeos::NetworkStateHandler* nsh =
chromeos::NetworkHandler::Get()->network_state_handler();
return nsh->ConnectedNetworkByType(chromeos::NetworkTypePattern::Default()) !=
NULL;
}
bool NetworkStateHelper::IsConnecting() const {
chromeos::NetworkStateHandler* nsh =
chromeos::NetworkHandler::Get()->network_state_handler();
return nsh->ConnectingNetworkByType(
chromeos::NetworkTypePattern::Default()) != NULL;
}
}
}