Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / webui / chromeos / login / gaia_screen_handler.h
blob520ac36801d6763c87526016e2a40b409e2af22b
1 // Copyright 2013 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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_GAIA_SCREEN_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_GAIA_SCREEN_HANDLER_H_
8 #include "base/basictypes.h"
9 #include "base/command_line.h"
10 #include "base/memory/ref_counted.h"
11 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
12 #include "net/base/net_errors.h"
14 namespace chromeos {
16 class SigninScreenHandler;
18 // A class that's used to specify the way how Gaia should be loaded.
19 struct GaiaContext {
20 GaiaContext();
22 // Forces Gaia to reload.
23 bool force_reload;
25 // Whether local verison of Gaia is used.
26 bool is_local;
28 // True if password was changed for the current user.
29 bool password_changed;
31 // True if user pods can be displyed.
32 bool show_users;
34 // Whether Gaia should be loaded in offline mode.
35 bool use_offline;
37 // True if user list is non-empty.
38 bool has_users;
40 // Email of current user.
41 std::string email;
44 // A class that handles WebUI hooks in Gaia screen.
45 class GaiaScreenHandler : public BaseScreenHandler {
46 public:
47 enum FrameState {
48 FRAME_STATE_UNKNOWN = 0,
49 FRAME_STATE_LOADING,
50 FRAME_STATE_LOADED,
51 FRAME_STATE_ERROR
54 explicit GaiaScreenHandler(
55 const scoped_refptr<NetworkStateInformer>& network_state_informer);
56 virtual ~GaiaScreenHandler();
58 void LoadGaia(const GaiaContext& context);
59 void UpdateGaia(const GaiaContext& context);
60 void ReloadGaia();
62 FrameState frame_state() const { return frame_state_; }
63 net::Error frame_error() const { return frame_error_; }
65 private:
66 // TODO (ygorshenin@): remove this dependency.
67 friend class SigninScreenHandler;
69 // BaseScreenHandler implementation:
70 virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) OVERRIDE;
71 virtual void Initialize() OVERRIDE;
73 // WebUIMessageHandler implementation:
74 virtual void RegisterMessages() OVERRIDE;
76 // WebUI message handlers.
77 void HandleFrameLoadingCompleted(int status);
79 // TODO (ygorshenin@): GaiaScreenHandler should implement
80 // NetworkStateInformer::Observer.
81 void UpdateState(ErrorScreenActor::ErrorReason reason);
83 // TODO (ygorshenin@): remove this dependency.
84 void SetSigninScreenHandler(SigninScreenHandler* handler);
86 // Current state of Gaia frame.
87 FrameState frame_state_;
89 // Latest Gaia frame error.
90 net::Error frame_error_;
92 // Network state informer used to keep signin screen up.
93 scoped_refptr<NetworkStateInformer> network_state_informer_;
95 // Non-owning ptr to SigninScreenHandler instance. Should not be used
96 // in dtor.
97 // TODO (ygorshenin@): GaiaScreenHandler shouldn't communicate with
98 // signin_screen_handler directly.
99 SigninScreenHandler* signin_screen_handler_;
101 DISALLOW_COPY_AND_ASSIGN(GaiaScreenHandler);
104 } // namespace chromeos
106 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_GAIA_SCREEN_HANDLER_H_