background_view.h revision 72a454cd3513ac24fbdd0e0cb9ad70b86a99b801
1// Copyright (c) 2010 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#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_BACKGROUND_VIEW_H_ 6#define CHROME_BROWSER_CHROMEOS_LOGIN_BACKGROUND_VIEW_H_ 7#pragma once 8 9#include "chrome/browser/chromeos/boot_times_loader.h" 10#include "chrome/browser/chromeos/cros/cros_library.h" 11#include "chrome/browser/chromeos/login/login_html_dialog.h" 12#include "chrome/browser/chromeos/status/status_area_host.h" 13#include "chrome/browser/chromeos/version_loader.h" 14#include "views/view.h" 15 16namespace views { 17class Label; 18class TextButton; 19class Widget; 20class WindowDelegate; 21} 22 23class DOMView; 24class GURL; 25class Profile; 26 27namespace chromeos { 28 29class OobeProgressBar; 30class ShutdownButton; 31class StatusAreaView; 32 33// View used to render the background during login. BackgroundView contains 34// StatusAreaView. 35class BackgroundView : public views::View, 36 public StatusAreaHost, 37 public chromeos::LoginHtmlDialog::Delegate { 38 public: 39 enum LoginStep { 40 SELECT_NETWORK, 41 EULA, 42 SIGNIN, 43 REGISTRATION, 44 PICTURE, 45 46 // Steps count, must be the last in the enum. 47 STEPS_COUNT 48 }; 49 50 BackgroundView(); 51 52 // Initializes the background view. It backgroun_url is given (non empty), 53 // it creates a DOMView background area that renders a webpage. 54 void Init(const GURL& background_url); 55 56 // Enable/disable shutdown button. 57 void EnableShutdownButton(bool enable); 58 59 // Creates a window containing an instance of WizardContentsView as the root 60 // view. The caller is responsible for showing (and closing) the returned 61 // widget. The BackgroundView is set in |view|. If background_url is non 62 // empty, the content page of the url is displayed as a background. 63 static views::Widget* CreateWindowContainingView( 64 const gfx::Rect& bounds, 65 const GURL& background_url, 66 BackgroundView** view); 67 68 // Create a modal popup view. 69 void CreateModalPopup(views::WindowDelegate* view); 70 71 // Overridden from StatusAreaHost: 72 virtual gfx::NativeWindow GetNativeWindow() const; 73 74 // Toggles status area visibility. 75 void SetStatusAreaVisible(bool visible); 76 77 // Toggles whether status area is enabled. 78 void SetStatusAreaEnabled(bool enable); 79 80 // Toggles OOBE progress bar visibility, the bar is hidden by default. 81 void SetOobeProgressBarVisible(bool visible); 82 83 // Gets progress bar visibility. 84 bool IsOobeProgressBarVisible(); 85 86 // Sets current step on OOBE progress bar. 87 void SetOobeProgress(LoginStep step); 88 89 // Shows screen saver. 90 void ShowScreenSaver(); 91 92 // Hides screen saver. 93 void HideScreenSaver(); 94 95 // Tells if screen saver is visible. 96 bool IsScreenSaverVisible(); 97 98 // Tells if screen saver is enabled. 99 bool ScreenSaverEnabled(); 100 101 protected: 102 // Overridden from views::View: 103 virtual void Paint(gfx::Canvas* canvas); 104 virtual void Layout(); 105 virtual void ChildPreferredSizeChanged(View* child); 106 virtual void OnLocaleChanged(); 107 108 // Overridden from StatusAreaHost: 109 virtual Profile* GetProfile() const { return NULL; } 110 virtual void ExecuteBrowserCommand(int id) const {} 111 virtual bool ShouldOpenButtonOptions( 112 const views::View* button_view) const; 113 virtual void OpenButtonOptions(const views::View* button_view); 114 virtual ScreenMode GetScreenMode() const; 115 116 // Overridden from LoginHtmlDialog::Delegate: 117 virtual void OnDialogClosed() {} 118 119 private: 120 // Creates and adds the status_area. 121 void InitStatusArea(); 122 // Creates and adds the labels for version and boot time. 123 void InitInfoLabels(); 124 // Creates and add OOBE progress bar. 125 void InitProgressBar(); 126 127 // Invokes SetWindowType for the window. This is invoked during startup and 128 // after we've painted. 129 void UpdateWindowType(); 130 131 // Callback from chromeos::VersionLoader giving the version. 132 void OnVersion(VersionLoader::Handle handle, std::string version); 133 // Callback from chromeos::InfoLoader giving the boot times. 134 void OnBootTimes( 135 BootTimesLoader::Handle handle, BootTimesLoader::BootTimes boot_times); 136 137 // All of these variables could be NULL. 138 StatusAreaView* status_area_; 139 views::Label* os_version_label_; 140 views::Label* boot_times_label_; 141 OobeProgressBar* progress_bar_; 142 ShutdownButton* shutdown_button_; 143 144 // Handles asynchronously loading the version. 145 VersionLoader version_loader_; 146 // Used to request the version. 147 CancelableRequestConsumer version_consumer_; 148 149 // Handles asynchronously loading the boot times. 150 BootTimesLoader boot_times_loader_; 151 // Used to request the boot times. 152 CancelableRequestConsumer boot_times_consumer_; 153 154 // Has Paint been invoked once? The value of this is passed to the window 155 // manager. 156 // TODO(sky): nuke this when the wm knows when chrome has painted. 157 bool did_paint_; 158 159 // True if running official BUILD. 160 bool is_official_build_; 161 162 // DOMView for rendering a webpage as a background. 163 DOMView* background_area_; 164 165 // Proxy settings dialog that can be invoked from network menu. 166 scoped_ptr<LoginHtmlDialog> proxy_settings_dialog_; 167 168 DISALLOW_COPY_AND_ASSIGN(BackgroundView); 169}; 170 171} // namespace chromeos 172 173#endif // CHROME_BROWSER_CHROMEOS_LOGIN_BACKGROUND_VIEW_H_ 174