summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-10 23:10:43 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-10 23:10:43 +0000
commit6af2295501973c7578664223c795e31fdfc3641e (patch)
tree2c244aa33f6826c411c3ca5a580e665a59b95fff /chrome
parentc5d7f32f2fdae32e4ebf5c67b02026eefecc17b2 (diff)
downloadchromium_src-6af2295501973c7578664223c795e31fdfc3641e.zip
chromium_src-6af2295501973c7578664223c795e31fdfc3641e.tar.gz
chromium_src-6af2295501973c7578664223c795e31fdfc3641e.tar.bz2
Refactors the login manager code to have two windows:
. background window containing the status and visual background. . WizardController creates it's own window for showing the various wizard dialogs. I needed to separate these two out as if you have logged in once I still want the background, and may end up showing the wizardcontrollers later. BUG=none TEST=none Review URL: http://codereview.chromium.org/832002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41219 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/chromeos/login/authentication_notification_details.h14
-rw-r--r--chrome/browser/chromeos/login/background_view.cc112
-rw-r--r--chrome/browser/chromeos/login/background_view.h55
-rw-r--r--chrome/browser/chromeos/login/login_manager_view.cc37
-rw-r--r--chrome/browser/chromeos/login/utils.cc55
-rw-r--r--chrome/browser/chromeos/login/utils.h26
-rw-r--r--chrome/browser/chromeos/login/wizard_controller.cc258
-rw-r--r--chrome/browser/chromeos/login/wizard_controller.h62
-rw-r--r--chrome/browser/chromeos/login/wizard_screen.h4
-rw-r--r--chrome/browser/chromeos/login/wizard_window.cc119
-rwxr-xr-xchrome/chrome_browser.gypi5
-rw-r--r--chrome/common/notification_type.h3
12 files changed, 441 insertions, 309 deletions
diff --git a/chrome/browser/chromeos/login/authentication_notification_details.h b/chrome/browser/chromeos/login/authentication_notification_details.h
index e415375..4ad9f0d 100644
--- a/chrome/browser/chromeos/login/authentication_notification_details.h
+++ b/chrome/browser/chromeos/login/authentication_notification_details.h
@@ -1,16 +1,16 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-//
-// A class to hold the parameters we get back from an authentication attempt
-// through the login manager
-#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_AUTHENTICATION_NOTIFICATION_DETAILS_H__
-#define CHROME_BROWSER_CHROMEOS_LOGIN_AUTHENTICATION_NOTIFICATION_DETAILS_H__
+#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_AUTHENTICATION_NOTIFICATION_DETAILS_H_
+#define CHROME_BROWSER_CHROMEOS_LOGIN_AUTHENTICATION_NOTIFICATION_DETAILS_H_
+// A class to hold the parameters we get back from an authentication attempt
+// through the login manager
class AuthenticationNotificationDetails {
public:
- AuthenticationNotificationDetails(bool success) : success_(success) { }
+ explicit AuthenticationNotificationDetails(bool success) : success_(success) {
+ }
bool success() const { return success_; }
@@ -20,4 +20,4 @@ class AuthenticationNotificationDetails {
DISALLOW_COPY_AND_ASSIGN(AuthenticationNotificationDetails);
};
-#endif // CHROME_BROWSER_CHROMEOS_LOGIN_AUTHENTICATION_NOTIFICATION_DETAILS_H__
+#endif // CHROME_BROWSER_CHROMEOS_LOGIN_AUTHENTICATION_NOTIFICATION_DETAILS_H_
diff --git a/chrome/browser/chromeos/login/background_view.cc b/chrome/browser/chromeos/login/background_view.cc
new file mode 100644
index 0000000..35bfeb2
--- /dev/null
+++ b/chrome/browser/chromeos/login/background_view.cc
@@ -0,0 +1,112 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/login/background_view.h"
+
+#include "chrome/browser/chromeos/login/rounded_rect_painter.h"
+#include "chrome/browser/chromeos/status/clock_menu_button.h"
+#include "chrome/browser/chromeos/status/network_menu_button.h"
+#include "chrome/browser/chromeos/status/status_area_view.h"
+#include "chrome/common/x11_util.h"
+#include "views/screen.h"
+#include "views/widget/widget_gtk.h"
+
+// X Windows headers have "#define Status int". That interferes with
+// NetworkLibrary header which defines enum "Status".
+#include <X11/cursorfont.h>
+#include <X11/Xcursor/Xcursor.h>
+
+namespace chromeos {
+
+BackgroundView::BackgroundView() : status_area_(NULL) {
+ views::Painter* painter = chromeos::CreateWizardPainter(
+ &chromeos::BorderDefinition::kWizardBorder);
+ set_background(views::Background::CreateBackgroundPainter(true, painter));
+ InitStatusArea();
+}
+
+static gfx::Rect CalculateWindowBounds(const gfx::Rect& bounds) {
+ if (!bounds.IsEmpty())
+ return bounds;
+
+ return views::Screen::GetMonitorWorkAreaNearestWindow(NULL);
+}
+
+static void ResetXCursor() {
+ // TOOD(sky): nuke this once new window manager is in place.
+ // This gets rid of the ugly X default cursor.
+ Display* display = x11_util::GetXDisplay();
+ Cursor cursor = XCreateFontCursor(display, XC_left_ptr);
+ XID root_window = x11_util::GetX11RootWindow();
+ XSetWindowAttributes attr;
+ attr.cursor = cursor;
+ XChangeWindowAttributes(display, root_window, CWCursor, &attr);
+}
+
+// static
+views::Widget* BackgroundView::CreateWindowContainingView(
+ const gfx::Rect& bounds,
+ BackgroundView** view) {
+ ResetXCursor();
+
+ views::WidgetGtk* window =
+ new views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW);
+ window->Init(NULL, CalculateWindowBounds(bounds));
+ *view = new BackgroundView();
+ window->SetContentsView(*view);
+
+ // This keeps the window from flashing at startup.
+ GdkWindow* gdk_window = window->GetNativeView()->window;
+ gdk_window_set_back_pixmap(gdk_window, NULL, false);
+
+ return window;
+}
+
+void BackgroundView::RecreateStatusArea() {
+ RemoveAllChildViews(true);
+ status_area_ = NULL;
+ InitStatusArea();
+}
+
+void BackgroundView::Layout() {
+ int right_top_padding =
+ chromeos::BorderDefinition::kWizardBorder.padding +
+ chromeos::BorderDefinition::kWizardBorder.corner_radius / 2;
+ gfx::Size status_area_size = status_area_->GetPreferredSize();
+ status_area_->SetBounds(
+ width() - status_area_size.width() - right_top_padding,
+ right_top_padding,
+ status_area_size.width(),
+ status_area_size.height());
+}
+
+gfx::NativeWindow BackgroundView::GetNativeWindow() const {
+ return
+ GTK_WINDOW(static_cast<views::WidgetGtk*>(GetWidget())->GetNativeView());
+}
+
+bool BackgroundView::ShouldOpenButtonOptions(
+ const views::View* button_view) const {
+ if (button_view == status_area_->clock_view() ||
+ button_view == status_area_->network_view()) {
+ return false;
+ }
+ return true;
+}
+
+void BackgroundView::OpenButtonOptions(const views::View* button_view) const {
+ // TODO(avayvod): Add some dialog for options or remove them completely.
+}
+
+bool BackgroundView::IsButtonVisible(const views::View* button_view) const {
+ return true;
+}
+
+void BackgroundView::InitStatusArea() {
+ status_area_ = new StatusAreaView(this);
+ status_area_->Init();
+ AddChildView(status_area_);
+}
+
+} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/background_view.h b/chrome/browser/chromeos/login/background_view.h
new file mode 100644
index 0000000..b95391e
--- /dev/null
+++ b/chrome/browser/chromeos/login/background_view.h
@@ -0,0 +1,55 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_BACKGROUND_VIEW_H_
+#define CHROME_BROWSER_CHROMEOS_LOGIN_BACKGROUND_VIEW_H_
+
+#include "chrome/browser/chromeos/status/status_area_host.h"
+#include "views/view.h"
+
+namespace views {
+class Widget;
+}
+
+namespace chromeos {
+
+class StatusAreaView;
+
+// View used to render the background during login. BackgroundView contains
+// StatusAreaView.
+class BackgroundView : public views::View, public StatusAreaHost {
+ public:
+ BackgroundView();
+
+ // Creates a window containing an instance of WizardContentsView as the root
+ // view. The caller is responsible for showing (and closing) the returned
+ // widget. The BackgroundView is set in |view|.
+ static views::Widget* CreateWindowContainingView(const gfx::Rect& bounds,
+ BackgroundView** view);
+
+ // Deletes the current status area and adds a new one.
+ void RecreateStatusArea();
+
+ // Overridden from views::View:
+ virtual void Layout();
+
+ // Overridden from StatusAreaHost:
+ virtual gfx::NativeWindow GetNativeWindow() const;
+ virtual bool ShouldOpenButtonOptions(
+ const views::View* button_view) const;
+ virtual void OpenButtonOptions(const views::View* button_view) const;
+ virtual bool IsButtonVisible(const views::View* button_view) const;
+
+ private:
+ // Creates and adds the status_area.
+ void InitStatusArea();
+
+ StatusAreaView* status_area_;
+
+ DISALLOW_COPY_AND_ASSIGN(BackgroundView);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_LOGIN_BACKGROUND_VIEW_H_
diff --git a/chrome/browser/chromeos/login/login_manager_view.cc b/chrome/browser/chromeos/login/login_manager_view.cc
index 2b41847..d47a45b 100644
--- a/chrome/browser/chromeos/login/login_manager_view.cc
+++ b/chrome/browser/chromeos/login/login_manager_view.cc
@@ -12,26 +12,21 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/callback.h"
-#include "base/file_path.h"
+#include "base/command_line.h"
#include "base/keyboard_codes.h"
#include "base/logging.h"
-#include "base/path_service.h"
#include "base/process_util.h"
#include "base/string_util.h"
-#include "chrome/browser/browser_init.h"
-#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/login_library.h"
#include "chrome/browser/chromeos/cros/network_library.h"
-#include "chrome/browser/chromeos/external_cookie_handler.h"
#include "chrome/browser/chromeos/login/authentication_notification_details.h"
#include "chrome/browser/chromeos/login/google_authenticator.h"
#include "chrome/browser/chromeos/login/pam_google_authenticator.h"
#include "chrome/browser/chromeos/login/rounded_rect_painter.h"
#include "chrome/browser/chromeos/login/screen_observer.h"
#include "chrome/browser/chromeos/login/user_manager.h"
-#include "chrome/browser/profile_manager.h"
-#include "chrome/common/chrome_paths.h"
+#include "chrome/browser/chromeos/login/utils.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_service.h"
#include "grit/generated_resources.h"
@@ -330,35 +325,11 @@ void LoginManagerView::OnLoginFailure() {
}
void LoginManagerView::OnLoginSuccess(const std::string& username) {
- LOG(INFO) << "LoginManagerView: OnLoginSuccess()";
// TODO(cmasone): something sensible if errors occur.
- SetupSession(username);
- UserManager::Get()->UserLoggedIn(username);
- // Send notification of success
- AuthenticationNotificationDetails details(true);
- NotificationService::current()->Notify(
- NotificationType::LOGIN_AUTHENTICATION, Source<LoginManagerView>(this),
- Details<AuthenticationNotificationDetails>(&details));
+ SetupSession(username);
- // Now launch the initial browser window.
- BrowserInit browser_init;
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- FilePath user_data_dir;
- PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
- ProfileManager* profile_manager = g_browser_process->profile_manager();
- // The default profile will have been changed because the ProfileManager
- // will process the notification that the UserManager sends out.
- Profile* profile = profile_manager->GetDefaultProfile(user_data_dir);
- int return_code;
-
- ExternalCookieHandler::GetCookies(command_line, profile);
- LOG(INFO) << "OnLoginSuccess: Preparing to launch browser";
- browser_init.LaunchBrowser(command_line,
- profile,
- std::wstring(),
- true,
- &return_code);
+ login_utils::CompleteLogin(username);
}
void LoginManagerView::SetupSession(const std::string& username) {
diff --git a/chrome/browser/chromeos/login/utils.cc b/chrome/browser/chromeos/login/utils.cc
new file mode 100644
index 0000000..54f7ee1
--- /dev/null
+++ b/chrome/browser/chromeos/login/utils.cc
@@ -0,0 +1,55 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/login/utils.h"
+
+#include "base/command_line.h"
+#include "base/file_path.h"
+#include "base/path_service.h"
+#include "chrome/browser/browser_init.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chromeos/external_cookie_handler.h"
+#include "chrome/browser/chromeos/login/authentication_notification_details.h"
+#include "chrome/browser/chromeos/login/user_manager.h"
+#include "chrome/browser/profile.h"
+#include "chrome/browser/profile_manager.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/common/notification_service.h"
+#include "views/widget/widget_gtk.h"
+
+namespace chromeos {
+
+namespace login_utils {
+
+void CompleteLogin(const std::string& username) {
+ LOG(INFO) << "LoginManagerView: OnLoginSuccess()";
+
+ UserManager::Get()->UserLoggedIn(username);
+
+ // Send notification of success
+ AuthenticationNotificationDetails details(true);
+ NotificationService::current()->Notify(
+ NotificationType::LOGIN_AUTHENTICATION,
+ NotificationService::AllSources(),
+ Details<AuthenticationNotificationDetails>(&details));
+
+ // Now launch the initial browser window.
+ BrowserInit browser_init;
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ FilePath user_data_dir;
+ PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
+ ProfileManager* profile_manager = g_browser_process->profile_manager();
+ // The default profile will have been changed because the ProfileManager
+ // will process the notification that the UserManager sends out.
+ Profile* profile = profile_manager->GetDefaultProfile(user_data_dir);
+ int return_code;
+
+ ExternalCookieHandler::GetCookies(command_line, profile);
+ browser_init.LaunchBrowser(command_line, profile, std::wstring(), true,
+ &return_code);
+}
+
+} // namespace login_utils
+
+} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/utils.h b/chrome/browser/chromeos/login/utils.h
new file mode 100644
index 0000000..652c6dc
--- /dev/null
+++ b/chrome/browser/chromeos/login/utils.h
@@ -0,0 +1,26 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_UTILS_H_
+#define CHROME_BROWSER_CHROMEOS_LOGIN_UTILS_H_
+
+#include <string>
+
+namespace views {
+class Widget;
+}
+
+namespace chromeos {
+
+namespace login_utils {
+
+// Invoked after the user has successfully logged in. This launches a browser
+// and does other bookkeeping after logging in.
+void CompleteLogin(const std::string& username);
+
+} // namespace login_utils
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_LOGIN_UTILS_H_
diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc
index e744a82..59d3c5a 100644
--- a/chrome/browser/chromeos/login/wizard_controller.cc
+++ b/chrome/browser/chromeos/login/wizard_controller.cc
@@ -4,22 +4,25 @@
#include "chrome/browser/chromeos/login/wizard_controller.h"
+#include <gdk/gdk.h>
+#include <signal.h>
+#include <sys/types.h>
+
#include <string>
-#include <vector>
-#include "app/gfx/canvas.h"
#include "app/resource_bundle.h"
#include "base/logging.h" // For NOTREACHED.
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chromeos/cros/cros_library.h"
+#include "chrome/browser/chromeos/cros/login_library.h"
#include "chrome/browser/chromeos/login/account_screen.h"
-#include "chrome/browser/chromeos/login/rounded_rect_painter.h"
+#include "chrome/browser/chromeos/login/background_view.h"
#include "chrome/browser/chromeos/login/user_manager.h"
-#include "chrome/browser/chromeos/status/clock_menu_button.h"
-#include "chrome/browser/chromeos/status/network_menu_button.h"
-#include "chrome/browser/chromeos/status/status_area_view.h"
#include "unicode/locid.h"
+#include "views/painter.h"
+#include "views/screen.h"
#include "views/view.h"
-#include "views/window/window.h"
+#include "views/widget/widget_gtk.h"
namespace {
@@ -31,100 +34,117 @@ const char kLoginScreenName[] = "login";
const char kAccountScreenName[] = "account";
const char kUpdateScreenName[] = "update";
-} // namespace
-
-// Initialize default controller.
-WizardController* WizardController::default_controller_ = NULL;
-
-// Contents view for wizard's window. Parents screen views and status area
-// view.
-class WizardContentsView : public views::View {
+// RootView of the Widget WizardController creates. Contains the contents of the
+// WizardController.
+class ContentView : public views::View {
public:
- WizardContentsView()
- : status_area_(NULL) {
+ ContentView(int window_x, int window_y, int screen_w, int screen_h)
+ : window_x_(window_x),
+ window_y_(window_y),
+ screen_w_(screen_w),
+ screen_h_(screen_h) {
+ painter_.reset(chromeos::CreateWizardPainter(
+ &chromeos::BorderDefinition::kWizardBorder));
}
- ~WizardContentsView() {}
- void Init(chromeos::StatusAreaHost* host) {
- views::Painter* painter = chromeos::CreateWizardPainter(
- &chromeos::BorderDefinition::kWizardBorder);
- set_background(views::Background::CreateBackgroundPainter(true, painter));
- InitStatusArea(host);
- }
-
- // Called to re-create status area view that have been deleted by the call
- // RemoveAllChildViews(true). Needed for locale switch.
- void InitStatusArea(chromeos::StatusAreaHost* host) {
- status_area_ = new chromeos::StatusAreaView(host);
- status_area_->Init();
- AddChildView(status_area_);
- }
-
- // Overridden from views::View:
- virtual gfx::Size GetPreferredSize() {
- return size();
+ void PaintBackground(gfx::Canvas* canvas) {
+ // TODO(sky): nuke this once new login manager is in place. This needs to
+ // exist because with no window manager transparency isn't really supported.
+ canvas->TranslateInt(-window_x_, -window_y_);
+ painter_->Paint(screen_w_, screen_h_, canvas);
}
virtual void Layout() {
- int right_top_padding =
- chromeos::BorderDefinition::kWizardBorder.padding +
- chromeos::BorderDefinition::kWizardBorder.corner_radius / 2;
- gfx::Size status_area_size = status_area_->GetPreferredSize();
- status_area_->SetBounds(
- width() - status_area_size.width() - right_top_padding,
- right_top_padding,
- status_area_size.width(),
- status_area_size.height());
-
- // Layout screen view. It should be the only visible child that's not a
- // status area view.
for (int i = 0; i < GetChildViewCount(); ++i) {
views::View* cur = GetChildViewAt(i);
- if (cur != status_area_ && cur->IsVisible()) {
- int x = (width() - kWizardScreenWidth) / 2;
- int y = (height() - kWizardScreenHeight) / 2;
- cur->SetBounds(x, y, kWizardScreenWidth, kWizardScreenHeight);
- }
+ if (cur->IsVisible())
+ cur->SetBounds(0, 0, width(), height());
}
}
- chromeos::StatusAreaView* status_area() const { return status_area_; }
-
private:
- chromeos::StatusAreaView* status_area_;
+ scoped_ptr<views::Painter> painter_;
- DISALLOW_COPY_AND_ASSIGN(WizardContentsView);
+ const int window_x_;
+ const int window_y_;
+ const int screen_w_;
+ const int screen_h_;
+
+ DISALLOW_COPY_AND_ASSIGN(ContentView);
};
+} // namespace
+
+// Initialize default controller.
+// static
+WizardController* WizardController::default_controller_ = NULL;
+
///////////////////////////////////////////////////////////////////////////////
// WizardController, public:
WizardController::WizardController()
- : contents_(NULL),
+ : widget_(NULL),
+ background_widget_(NULL),
+ background_view_(NULL),
+ contents_(NULL),
current_screen_(NULL) {
DCHECK(default_controller_ == NULL);
default_controller_ = this;
}
WizardController::~WizardController() {
+ // Close ends up deleting the widget.
+ if (background_widget_)
+ background_widget_->Close();
+
+ if (widget_)
+ widget_->Close();
+
default_controller_ = NULL;
}
-void WizardController::ShowFirstScreen(const std::string& first_screen_name) {
- if (first_screen_name == kNetworkScreenName) {
- SetCurrentScreen(GetNetworkScreen());
- } else if (first_screen_name == kLoginScreenName) {
- SetCurrentScreen(GetLoginScreen());
- } else if (first_screen_name == kAccountScreenName) {
- SetCurrentScreen(GetAccountScreen());
- } else if (first_screen_name == kUpdateScreenName) {
- SetCurrentScreen(GetUpdateScreen());
- } else {
- if (chromeos::UserManager::Get()->GetUsers().empty()) {
- SetCurrentScreen(GetNetworkScreen());
- } else {
- SetCurrentScreen(GetLoginScreen());
- }
- }
+void WizardController::Init(const std::string& first_screen_name) {
+ DCHECK(!contents_);
+
+ gfx::Rect screen_bounds =
+ views::Screen::GetMonitorWorkAreaNearestWindow(NULL);
+ int window_x = (screen_bounds.width() - kWizardScreenWidth) / 2;
+ int window_y = (screen_bounds.height() - kWizardScreenHeight) / 2;
+
+ contents_ = new ContentView(window_x, window_y, screen_bounds.width(),
+ screen_bounds.height());
+
+ views::WidgetGtk* window =
+ new views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW);
+ widget_ = window;
+ window->Init(NULL, gfx::Rect(window_x, window_y, kWizardScreenWidth,
+ kWizardScreenHeight));
+ window->SetContentsView(contents_);
+
+ ShowFirstScreen(first_screen_name);
+
+ // This keeps the window from flashing at startup.
+ GdkWindow* gdk_window = window->GetNativeView()->window;
+ gdk_window_set_back_pixmap(gdk_window, NULL, false);
+}
+
+void WizardController::Show() {
+ DCHECK(widget_);
+ widget_->Show();
+}
+
+void WizardController::ShowBackground(const gfx::Size& size) {
+ DCHECK(!background_widget_);
+ background_widget_ = chromeos::BackgroundView::CreateWindowContainingView(
+ gfx::Rect(0, 0, size.width(), size.height()), &background_view_);
+ background_widget_->Show();
+}
+
+void WizardController::OwnBackground(
+ views::Widget* background_widget,
+ chromeos::BackgroundView* background_view) {
+ DCHECK(!background_widget_);
+ background_widget_ = background_widget;
+ background_view_ = background_view;
}
NetworkScreen* WizardController::GetNetworkScreen() {
@@ -154,7 +174,17 @@ UpdateScreen* WizardController::GetUpdateScreen() {
///////////////////////////////////////////////////////////////////////////////
// WizardController, ExitHandlers:
void WizardController::OnLoginSignInSelected() {
- window()->Close();
+ // Close the windows now (which will delete them).
+ if (background_widget_) {
+ background_widget_->Close();
+ background_widget_ = NULL;
+ }
+
+ widget_->Close();
+ widget_ = NULL;
+
+ // We're on the stack, so don't try and delete us now.
+ MessageLoop::current()->DeleteSoon(FROM_HERE, this);
}
void WizardController::OnLoginCreateAccount() {
@@ -175,11 +205,6 @@ void WizardController::OnLanguageChanged() {
///////////////////////////////////////////////////////////////////////////////
// WizardController, private:
-void WizardController::InitContents() {
- contents_ = new WizardContentsView();
- contents_->Init(this);
-}
-
void WizardController::OnSwitchLanguage(std::string lang) {
// Delete all views that may may reference locale-specific data.
SetCurrentScreen(NULL);
@@ -201,7 +226,8 @@ void WizardController::OnSwitchLanguage(std::string lang) {
g_browser_process->SetApplicationLocale(lang);
// Recreate view hierarchy and return to the wizard screen.
- contents_->InitStatusArea(this);
+ if (background_view_)
+ background_view_->RecreateStatusArea();
OnExit(chromeos::ScreenObserver::LANGUAGE_CHANGED);
}
@@ -212,7 +238,25 @@ void WizardController::SetCurrentScreen(WizardScreen* new_current) {
if (current_screen_) {
current_screen_->Show();
contents_->Layout();
- contents_->SchedulePaint();
+ }
+ contents_->SchedulePaint();
+}
+
+void WizardController::ShowFirstScreen(const std::string& first_screen_name) {
+ if (first_screen_name == kNetworkScreenName) {
+ SetCurrentScreen(GetNetworkScreen());
+ } else if (first_screen_name == kLoginScreenName) {
+ SetCurrentScreen(GetLoginScreen());
+ } else if (first_screen_name == kAccountScreenName) {
+ SetCurrentScreen(GetAccountScreen());
+ } else if (first_screen_name == kUpdateScreenName) {
+ SetCurrentScreen(GetUpdateScreen());
+ } else {
+ if (chromeos::UserManager::Get()->GetUsers().empty()) {
+ SetCurrentScreen(GetNetworkScreen());
+ } else {
+ SetCurrentScreen(GetLoginScreen());
+ }
}
}
@@ -241,46 +285,26 @@ void WizardController::OnExit(ExitCodes exit_code) {
}
///////////////////////////////////////////////////////////////////////////////
-// WizardController, views::WindowDelegate overrides:
-views::View* WizardController::GetContentsView() {
- if (!contents_)
- InitContents();
- return contents_;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// WizardController, StatusAreaHost overrides:
-gfx::NativeWindow WizardController::GetNativeWindow() const {
- return window()->GetNativeWindow();
-}
-
-bool WizardController::ShouldOpenButtonOptions(
- const views::View* button_view) const {
- if (button_view == contents_->status_area()->clock_view())
- return false;
- if (button_view == contents_->status_area()->network_view())
- return false;
- return true;
-}
-
-void WizardController::OpenButtonOptions(const views::View* button_view) const {
- // TODO(avayvod): Add some dialog for options or remove them completely.
-}
-
-bool WizardController::IsButtonVisible(const views::View* button_view) const {
- return true;
-}
-
-///////////////////////////////////////////////////////////////////////////////
// WizardController, WizardScreen overrides:
views::View* WizardController::GetWizardView() {
return contents_;
}
-views::Window* WizardController::GetWizardWindow() {
- return window();
-}
-
chromeos::ScreenObserver* WizardController::GetObserver(WizardScreen* screen) {
return this;
}
+
+namespace browser {
+
+// Declared in browser_dialogs.h so that others don't need to depend on our .h.
+void ShowLoginWizard(const std::string& first_screen_name,
+ const gfx::Size& size) {
+ WizardController* controller = new WizardController();
+ controller->ShowBackground(size);
+ controller->Init(first_screen_name);
+ controller->Show();
+ if (chromeos::CrosLibrary::EnsureLoaded())
+ chromeos::LoginLibrary::Get()->EmitLoginPromptReady();
+}
+
+} // namespace browser
diff --git a/chrome/browser/chromeos/login/wizard_controller.h b/chrome/browser/chromeos/login/wizard_controller.h
index aec0093..2975726 100644
--- a/chrome/browser/chromeos/login/wizard_controller.h
+++ b/chrome/browser/chromeos/login/wizard_controller.h
@@ -11,22 +11,23 @@
#include "chrome/browser/chromeos/login/screen_observer.h"
#include "chrome/browser/chromeos/login/view_screen.h"
#include "chrome/browser/chromeos/login/wizard_screen.h"
-#include "chrome/browser/chromeos/status/status_area_host.h"
-#include "views/window/window_delegate.h"
class AccountScreen;
class WizardContentsView;
class WizardScreen;
+
namespace chromeos {
-class StatusAreaView;
-} // namespace chromeos
-
-// Class that manages control flow between wizard screens, top level window,
-// status area and background view. Wizard controller interacts with screen
-// controllers to move the user between screens.
-class WizardController : public views::WindowDelegate,
- public chromeos::StatusAreaHost,
- public chromeos::ScreenObserver,
+class BackgroundView;
+}
+
+namespace views {
+class Views;
+class Widget;
+}
+
+// Class that manages control flow between wizard screens. Wizard controller
+// interacts with screen controllers to move the user between screens.
+class WizardController : public chromeos::ScreenObserver,
public WizardScreenDelegate {
public:
WizardController();
@@ -39,7 +40,20 @@ class WizardController : public views::WindowDelegate,
// Shows the first screen defined by |first_screen_name| or by default
// if the parameter is empty.
- void ShowFirstScreen(const std::string& first_screen_name);
+ void Init(const std::string& first_screen_name);
+
+ // Returns the view that contains all the other views.
+ views::View* contents() { return contents_; }
+
+ // Shows the wizard controller in a window.
+ void Show();
+
+ // Creates and shows a background window.
+ void ShowBackground(const gfx::Size& size);
+
+ // Takes ownership of the specified background widget and view.
+ void OwnBackground(views::Widget* background_widget,
+ chromeos::BackgroundView* background_view);
// Lazy initializers and getters for screens.
NetworkScreen* GetNetworkScreen();
@@ -59,28 +73,24 @@ class WizardController : public views::WindowDelegate,
virtual void OnExit(ExitCodes exit_code);
virtual void OnSwitchLanguage(std::string lang);
- // Overridden from views::WindowDelegate:
- virtual views::View* GetContentsView();
-
- // Overridden from StatusAreaHost:
- virtual gfx::NativeWindow GetNativeWindow() const;
- virtual bool ShouldOpenButtonOptions(const views::View* button_view) const;
- virtual void OpenButtonOptions(const views::View* button_view) const;
- virtual bool IsButtonVisible(const views::View* button_view) const;
-
// Overridden from WizardScreenDelegate:
virtual views::View* GetWizardView();
- virtual views::Window* GetWizardWindow();
virtual chromeos::ScreenObserver* GetObserver(WizardScreen* screen);
- // Initializes contents view and status area.
- void InitContents();
-
// Switches from one screen to another.
void SetCurrentScreen(WizardScreen* screen);
+ void ShowFirstScreen(const std::string& first_screen_name);
+
+ // Widget we're showing in.
+ views::Widget* widget_;
+
+ // Used to render the background.
+ views::Widget* background_widget_;
+ chromeos::BackgroundView* background_view_;
+
// Contents view.
- WizardContentsView* contents_;
+ views::View* contents_;
// Screens.
scoped_ptr<NetworkScreen> network_screen_;
diff --git a/chrome/browser/chromeos/login/wizard_screen.h b/chrome/browser/chromeos/login/wizard_screen.h
index 317c30b..c2804af 100644
--- a/chrome/browser/chromeos/login/wizard_screen.h
+++ b/chrome/browser/chromeos/login/wizard_screen.h
@@ -13,7 +13,6 @@ class ScreenObserver;
} // namespace chromeos
namespace views {
class View;
-class Window;
} // namespace views
// Interface that login wizard exposes to its screens.
@@ -22,9 +21,6 @@ class WizardScreenDelegate {
// Returns top level view of the wizard.
virtual views::View* GetWizardView() = 0;
- // Returns top level window of the wizard.
- virtual views::Window* GetWizardWindow() = 0;
-
// Returns observer screen should notify.
virtual chromeos::ScreenObserver* GetObserver(WizardScreen* screen) = 0;
diff --git a/chrome/browser/chromeos/login/wizard_window.cc b/chrome/browser/chromeos/login/wizard_window.cc
deleted file mode 100644
index eaa184a..0000000
--- a/chrome/browser/chromeos/login/wizard_window.cc
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <gdk/gdk.h>
-#include <signal.h>
-#include <sys/types.h>
-
-#include <string>
-
-#include "base/process_util.h"
-#include "chrome/browser/chromeos/cros/cros_library.h"
-#include "chrome/browser/chromeos/cros/login_library.h"
-#include "chrome/browser/chromeos/login/wizard_controller.h"
-#include "chrome/browser/views/browser_dialogs.h"
-#include "chrome/common/x11_util.h"
-#include "views/screen.h"
-#include "views/window/hit_test.h"
-#include "views/window/non_client_view.h"
-#include "views/window/window.h"
-#include "views/window/window_gtk.h"
-
-// X Windows headers have "#define Status int". That interferes with
-// NetworkLibrary header which defines enum "Status".
-#include <X11/cursorfont.h>
-#include <X11/Xcursor/Xcursor.h>
-
-namespace {
-
-// Acts as a frame view with no UI.
-class WizardNonClientFrameView : public views::NonClientFrameView {
- public:
- WizardNonClientFrameView() : views::NonClientFrameView() {}
-
- // Returns just the bounds of the window.
- virtual gfx::Rect GetBoundsForClientView() const { return bounds(); }
-
- // Doesn't add any size to the client bounds.
- virtual gfx::Rect GetWindowBoundsForClientBounds(
- const gfx::Rect& client_bounds) const {
- return client_bounds;
- }
-
- // There is no non client area.
- virtual int NonClientHitTest(const gfx::Point& point) {
- return bounds().Contains(point) ? HTCLIENT : HTNOWHERE;
- }
-
- // There is no non client area.
- virtual void GetWindowMask(const gfx::Size& size,
- gfx::Path* window_mask) {}
- virtual void EnableClose(bool enable) {}
- virtual void ResetWindowControls() {}
-
- DISALLOW_COPY_AND_ASSIGN(WizardNonClientFrameView);
-};
-
-// Subclass of WindowGtk, for use as the top level window.
-class WizardWindow : public views::WindowGtk {
- public:
- static WizardWindow* Create(const std::string& first_screen_name,
- const gfx::Size& size) {
- WizardController* controller = new WizardController();
- WizardWindow* wizard_window = new WizardWindow(controller);
- wizard_window->GetNonClientView()->SetFrameView(
- new WizardNonClientFrameView());
-
- gfx::Rect wizard_window_rect(0, 0, size.width(), size.height());
- if (size.width() <= 0 || size.height() <= 0) {
- // TODO(dpolukhin): add support for multiple monitors.
- gfx::Rect monitor_bounds =
- views::Screen::GetMonitorWorkAreaNearestWindow(NULL);
- wizard_window_rect.SetRect(monitor_bounds.x(),
- monitor_bounds.y(),
- monitor_bounds.width(),
- monitor_bounds.height());
- }
- wizard_window->Init(NULL, wizard_window_rect);
- controller->ShowFirstScreen(first_screen_name);
-
- // This keeps the window from flashing at startup.
- GdkWindow* gdk_window = GTK_WIDGET(
- wizard_window->GetNativeWindow())->window;
- gdk_window_set_back_pixmap(gdk_window, NULL, false);
-
- // This gets rid of the ugly X default cursor.
- Display* display = x11_util::GetXDisplay();
- Cursor cursor = XCreateFontCursor(display, XC_left_ptr);
- XID root_window = x11_util::GetX11RootWindow();
- XSetWindowAttributes attr;
- attr.cursor = cursor;
- XChangeWindowAttributes(display, root_window, CWCursor, &attr);
- return wizard_window;
- }
-
- private:
- explicit WizardWindow(WizardController* controller)
- : views::WindowGtk(controller) {
- }
-
- DISALLOW_COPY_AND_ASSIGN(WizardWindow);
-};
-
-} // namespace
-
-namespace browser {
-
-// Declared in browser_dialogs.h so that others don't need to depend on our .h.
-void ShowLoginWizard(const std::string& first_screen_name,
- const gfx::Size& size) {
- views::WindowGtk* window = WizardWindow::Create(first_screen_name, size);
- window->Show();
- if (chromeos::CrosLibrary::EnsureLoaded()) {
- chromeos::LoginLibrary::Get()->EmitLoginPromptReady();
- }
-}
-
-} // namespace browser
-
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 026eebb..1a98773 100755
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -351,6 +351,8 @@
'browser/chromeos/login/account_screen.cc',
'browser/chromeos/login/account_screen.h',
'browser/chromeos/login/authenticator.h',
+ 'browser/chromeos/login/background_view.cc',
+ 'browser/chromeos/login/background_view.h',
'browser/chromeos/login/google_authenticator.cc',
'browser/chromeos/login/google_authenticator.h',
'browser/chromeos/login/pam_google_authenticator.cc',
@@ -367,11 +369,12 @@
'browser/chromeos/login/update_view.h',
'browser/chromeos/login/user_manager.cc',
'browser/chromeos/login/user_manager.h',
+ 'browser/chromeos/login/utils.cc',
+ 'browser/chromeos/login/utils.h',
'browser/chromeos/login/view_screen.h',
'browser/chromeos/login/wizard_controller.cc',
'browser/chromeos/login/wizard_controller.h',
'browser/chromeos/login/wizard_screen.h',
- 'browser/chromeos/login/wizard_window.cc',
'browser/chromeos/network_list.cc',
'browser/chromeos/network_list.h',
'browser/chromeos/options/internet_page_view.cc',
diff --git a/chrome/common/notification_type.h b/chrome/common/notification_type.h
index 326e2d9..4b242da 100644
--- a/chrome/common/notification_type.h
+++ b/chrome/common/notification_type.h
@@ -869,8 +869,7 @@ class NotificationType {
LOGIN_USER_CHANGED,
// Sent when a chromium os user attempts to log in. The source is
- // GoogleAuthenticator and the details are in
- // AuthenticationNotificationDetails.
+ // all and the details are AuthenticationNotificationDetails.
LOGIN_AUTHENTICATION,
#endif