Elim cr-checkbox
[chromium-blink-merge.git] / chrome / browser / chromeos / login / helper.h
blobc02cd58908047dc554562f02f5c9bdc9377989ab
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.
7 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_HELPER_H_
8 #define CHROME_BROWSER_CHROMEOS_LOGIN_HELPER_H_
10 #include <string>
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"
17 class GURL;
19 namespace gfx {
20 class Rect;
21 class Size;
22 } // namespace gfx
24 namespace content {
25 class StoragePartition;
28 namespace net {
29 class URLRequestContextGetter;
32 namespace chromeos {
34 // Returns bounds of the screen to use for login wizard.
35 // The rect is centered within the default monitor and sized accordingly if
36 // |size| is not empty. Otherwise the whole monitor is occupied.
37 gfx::Rect CalculateScreenBounds(const gfx::Size& size);
39 // Returns the size of user image required for proper display under current DPI.
40 int GetCurrentUserImageSize();
42 // Define the constants in |login| namespace to avoid potential
43 // conflict with other chromeos components.
44 namespace login {
46 // Maximum size of user image, in which it should be saved to be properly
47 // displayed under all possible DPI values.
48 const int kMaxUserImageSize = 512;
50 // Returns true if lock/login should scroll user pods into view itself when
51 // virtual keyboard is shown and disable vk overscroll.
52 bool LoginScrollIntoViewEnabled();
54 // A helper class for easily mocking out Network*Handler calls for tests.
55 class NetworkStateHelper {
56 public:
57 NetworkStateHelper();
58 virtual ~NetworkStateHelper();
60 // Returns name of the currently connected network.
61 // If there are no connected networks, returns name of the network
62 // that is in the "connecting" state. Otherwise empty string is returned.
63 // If there are multiple connected networks, network priority:
64 // Ethernet > WiFi > Cellular. Same for connecting network.
65 virtual base::string16 GetCurrentNetworkName() const;
67 // Add a network configuration.
68 virtual void CreateNetworkFromOnc(const std::string& onc_spec) const;
70 // Returns true if the default network is in connected state.
71 virtual bool IsConnected() const;
73 // Returns true if the default network is in connecting state.
74 virtual bool IsConnecting() const;
76 private:
77 void OnCreateConfiguration(const std::string& service_path) const;
78 void OnCreateConfigurationFailed(
79 const std::string& error_name,
80 scoped_ptr<base::DictionaryValue> error_data) const;
82 DISALLOW_COPY_AND_ASSIGN(NetworkStateHelper);
86 // Webview based login helpers.
89 // Returns the storage partition for the sign-in webview. Note the function gets
90 // the partition via the sign-in WebContents thus returns nullptr if the sign-in
91 // webui is torn down.
92 content::StoragePartition* GetSigninPartition();
94 // Returns the request context that contains sign-in cookies. For old iframe
95 // based flow, the context of the sign-in profile is returned. For webview based
96 // flow, the context of the sign-in webview storage partition is returned.
97 net::URLRequestContextGetter* GetSigninContext();
99 } // namespace login
101 } // namespace chromeos
103 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_HELPER_H_