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 // This file contains helper functions used by Chromium OS login. 6 7 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_HELPER_H_ 8 #define CHROME_BROWSER_CHROMEOS_LOGIN_HELPER_H_ 9 10 #include <string> 11 12 #include "base/compiler_specific.h" 13 #include "base/strings/string16.h" 14 #include "third_party/skia/include/core/SkColor.h" 15 #include "ui/views/view.h" 16 17 class GURL; 18 19 namespace gfx { 20 class Rect; 21 class Size; 22 } // namespace gfx 23 24 namespace chromeos { 25 26 // Returns bounds of the screen to use for login wizard. 27 // The rect is centered within the default monitor and sized accordingly if 28 // |size| is not empty. Otherwise the whole monitor is occupied. 29 gfx::Rect CalculateScreenBounds(const gfx::Size& size); 30 31 // Returns the size of user image required for proper display under current DPI. 32 int GetCurrentUserImageSize(); 33 34 // Define the constants in |login| namespace to avoid potential 35 // conflict with other chromeos components. 36 namespace login { 37 38 // Maximum size of user image, in which it should be saved to be properly 39 // displayed under all possible DPI values. 40 const int kMaxUserImageSize = 512; 41 42 // Canonicalizes a GAIA user ID, accounting for the legacy guest mode user ID 43 // which does trips up gaia::CanonicalizeEmail() because it does not contain an 44 // @ symbol. 45 std::string CanonicalizeUserID(const std::string& user_id); 46 47 // Returns true if lock/login should scroll user pods into view itself when 48 // virtual keyboard is shown and disable vk overscroll. 49 bool LoginScrollIntoViewEnabled(); 50 51 // A helper class for easily mocking out Network*Handler calls for tests. 52 class NetworkStateHelper { 53 public: 54 NetworkStateHelper(); 55 virtual ~NetworkStateHelper(); 56 57 // Returns name of the currently connected network. 58 // If there are no connected networks, returns name of the network 59 // that is in the "connecting" state. Otherwise empty string is returned. 60 // If there are multiple connected networks, network priority: 61 // Ethernet > WiFi > Cellular. Same for connecting network. 62 virtual base::string16 GetCurrentNetworkName() const; 63 64 // Returns true if the default network is in connected state. 65 virtual bool IsConnected() const; 66 67 // Returns true if the default network is in connecting state. 68 virtual bool IsConnecting() const; 69 70 private: 71 DISALLOW_COPY_AND_ASSIGN(NetworkStateHelper); 72 }; 73 74 } // namespace login 75 76 } // namespace chromeos 77 78 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_HELPER_H_ 79