helper.cc revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
1// Copyright (c) 2012 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 "chrome/browser/chromeos/login/helper.h" 6 7#include "ash/shell.h" 8#include "base/utf_string_conversions.h" 9#include "chrome/browser/chromeos/net/connectivity_state_helper.h" 10#include "grit/generated_resources.h" 11#include "grit/theme_resources.h" 12#include "third_party/cros_system_api/dbus/service_constants.h" 13#include "ui/base/l10n/l10n_util.h" 14#include "ui/base/resource/resource_bundle.h" 15#include "ui/gfx/screen.h" 16 17namespace chromeos { 18 19gfx::Rect CalculateScreenBounds(const gfx::Size& size) { 20 gfx::Rect bounds(ash::Shell::GetScreen()->GetPrimaryDisplay().bounds()); 21 if (!size.IsEmpty()) { 22 int horizontal_diff = bounds.width() - size.width(); 23 int vertical_diff = bounds.height() - size.height(); 24 bounds.Inset(horizontal_diff / 2, vertical_diff / 2); 25 } 26 return bounds; 27} 28 29string16 GetCurrentNetworkName() { 30 ConnectivityStateHelper* csh = 31 ConnectivityStateHelper::Get(); 32 33 if (csh->IsConnectedType(flimflam::kTypeEthernet)) { 34 return l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET); 35 } else if (csh->IsConnectedType(flimflam::kTypeWifi)) { 36 return UTF8ToUTF16(csh->NetworkNameForType(flimflam::kTypeWifi)); 37 } else if (csh->IsConnectedType(flimflam::kTypeCellular)) { 38 return UTF8ToUTF16(csh->NetworkNameForType(flimflam::kTypeCellular)); 39 } else if (csh->IsConnectedType(flimflam::kTypeWimax)) { 40 return UTF8ToUTF16(csh->NetworkNameForType(flimflam::kTypeWimax)); 41 } else if (csh->IsConnectingType(flimflam::kTypeEthernet)) { 42 return l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET); 43 } else if (csh->IsConnectingType(flimflam::kTypeWifi)) { 44 return UTF8ToUTF16(csh->NetworkNameForType(flimflam::kTypeWifi)); 45 } else if (csh->IsConnectingType(flimflam::kTypeCellular)) { 46 return UTF8ToUTF16(csh->NetworkNameForType(flimflam::kTypeCellular)); 47 } else if (csh->IsConnectingType(flimflam::kTypeWimax)) { 48 return UTF8ToUTF16(csh->NetworkNameForType(flimflam::kTypeWimax)); 49 } else { 50 return string16(); 51 } 52} 53 54int GetCurrentUserImageSize() { 55 // The biggest size that the profile picture is displayed at is currently 56 // 220px, used for the big preview on OOBE and Change Picture options page. 57 static const int kBaseUserImageSize = 220; 58 float scale_factor = gfx::Display::GetForcedDeviceScaleFactor(); 59 if (scale_factor > 1.0f) 60 return static_cast<int>(scale_factor * kBaseUserImageSize); 61 return kBaseUserImageSize * 62 ui::GetScaleFactorScale(ui::GetMaxScaleFactor()); 63} 64 65} // namespace chromeos 66