diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-30 01:48:48 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-30 01:48:48 +0000 |
commit | f65210ccc1f4d4c6c4de3f7972bba9a4528d6926 (patch) | |
tree | 5a1889996fc7454ab71c198efa73129093a17866 | |
parent | 15d04ae1405ec06bd43ff1f82bd2ffbc706d1b81 (diff) | |
download | chromium_src-f65210ccc1f4d4c6c4de3f7972bba9a4528d6926.zip chromium_src-f65210ccc1f4d4c6c4de3f7972bba9a4528d6926.tar.gz chromium_src-f65210ccc1f4d4c6c4de3f7972bba9a4528d6926.tar.bz2 |
Add Shutdown button to login/locker screen.
* cleaned up code that are no longer in use.
BUG=chromium-os:5763
TEST=maual. pressing shutdown button on login/locker will shutdown the system.
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=64272
Review URL: http://codereview.chromium.org/4054001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64531 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/generated_resources.grd | 3 | ||||
-rw-r--r-- | chrome/app/theme/theme_resources.grd | 1 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/background_view.cc | 109 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/background_view.h | 40 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/existing_user_controller.cc | 7 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/existing_user_controller.h | 13 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/screen_locker.cc | 63 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/shutdown_button.cc | 124 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/shutdown_button.h | 40 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/wizard_controller.cc | 1 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 |
11 files changed, 247 insertions, 156 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 4c4741a..bee34da 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -8966,6 +8966,9 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_GO_INCOGNITO_BUTTON"> Go incognito </message> + <message name="IDS_SHUTDOWN_BUTTON" desc="Text shown on shutdown button on login/locker screen"> + Shutdown + </message> <message name="IDS_LOGIN_OOBE_HELP_DIALOG_TITLE" desc="Default title for help dialogs during OOBE/login"> Help </message> diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd index 036cd7c..6a8c38e 100644 --- a/chrome/app/theme/theme_resources.grd +++ b/chrome/app/theme/theme_resources.grd @@ -577,6 +577,7 @@ <include name="IDR_SCROLL_THUMB" file="chromeos_scroll_thumb.png" type="BINDATA" /> <include name="IDR_SCROLL_THUMB_H" file="chromeos_scroll_thumb_h.png" type="BINDATA" /> <include name="IDR_SCROLL_THUMB_P" file="chromeos_scroll_thumb_p.png" type="BINDATA" /> + <include name="IDR_SHUTDOWN_ICON" file="shutdown_icon.png" type="BINDATA" /> </if> </includes> </release> diff --git a/chrome/browser/chromeos/login/background_view.cc b/chrome/browser/chromeos/login/background_view.cc index 79d1a9c..fe5cb66 100644 --- a/chrome/browser/chromeos/login/background_view.cc +++ b/chrome/browser/chromeos/login/background_view.cc @@ -16,6 +16,7 @@ #include "chrome/browser/chromeos/login/helper.h" #include "chrome/browser/chromeos/login/oobe_progress_bar.h" #include "chrome/browser/chromeos/login/rounded_rect_painter.h" +#include "chrome/browser/chromeos/login/shutdown_button.h" #include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/chromeos/status/clock_menu_button.h" #include "chrome/browser/chromeos/status/feedback_menu_button.h" @@ -94,9 +95,8 @@ BackgroundView::BackgroundView() os_version_label_(NULL), boot_times_label_(NULL), progress_bar_(NULL), - go_incognito_button_(NULL), + shutdown_button_(NULL), did_paint_(false), - delegate_(NULL), #if defined(OFFICIAL_BUILD) is_official_build_(true), #else @@ -120,6 +120,13 @@ void BackgroundView::Init(const GURL& background_url) { } } +void BackgroundView::EnableShutdownButton() { + DCHECK(!shutdown_button_); + shutdown_button_ = new ShutdownButton(); + shutdown_button_->Init(); + AddChildView(shutdown_button_); +} + // static views::Widget* BackgroundView::CreateWindowContainingView( const gfx::Rect& bounds, @@ -168,21 +175,6 @@ void BackgroundView::SetOobeProgress(LoginStep step) { progress_bar_->SetProgress(step); } -// Toggles GoIncognito button visibility. -void BackgroundView::SetGoIncognitoButtonVisible(bool visible, - Delegate *delegate) { - // Set delegate to handle button pressing. - delegate_ = delegate; - bool currently_visible = - go_incognito_button_ && go_incognito_button_->IsVisible(); - if (currently_visible != visible) { - if (!go_incognito_button_) { - InitGoIncognitoButton(); - } - go_incognito_button_->SetVisible(visible); - } -} - void BackgroundView::ShowScreenSaver() { SetStatusAreaVisible(false); background_area_->SetVisible(true); @@ -203,17 +195,6 @@ bool BackgroundView::ScreenSaverEnabled() { return background_area_ != NULL; } -void BackgroundView::OnOwnerChanged() { - delegate_ = NULL; - if (go_incognito_button_) { - // BackgroundView is passed among multiple controllers, so they should - // explicitly enable "Go incognito" button if needed. - RemoveChildView(go_incognito_button_); - delete go_incognito_button_; - go_incognito_button_ = NULL; - } -} - /////////////////////////////////////////////////////////////////////////////// // BackgroundView protected: @@ -233,8 +214,6 @@ void BackgroundView::Layout() { const int kProgressBarBottomPadding = 20; const int kProgressBarWidth = 750; const int kProgressBarHeight = 70; - const int kGoIncognitoButtonBottomPadding = 12; - const int kGoIncognitoButtonRightPadding = 12; gfx::Size status_area_size = status_area_->GetPreferredSize(); status_area_->SetBounds( width() - status_area_size.width() - kCornerPadding, @@ -264,13 +243,8 @@ void BackgroundView::Layout() { kProgressBarWidth, kProgressBarHeight); } - if (go_incognito_button_) { - gfx::Size go_button_size = go_incognito_button_->GetPreferredSize(); - go_incognito_button_->SetBounds( - width() - go_button_size.width()- kGoIncognitoButtonRightPadding, - height() - go_button_size.height() - kGoIncognitoButtonBottomPadding, - go_button_size.width(), - go_button_size.height()); + if (shutdown_button_) { + shutdown_button_->LayoutIn(this); } if (background_area_) background_area_->SetBounds(this->bounds()); @@ -281,12 +255,6 @@ void BackgroundView::ChildPreferredSizeChanged(View* child) { SchedulePaint(); } -void BackgroundView::OnLocaleChanged() { - UpdateLocalizedStrings(); - Layout(); - SchedulePaint(); -} - gfx::NativeWindow BackgroundView::GetNativeWindow() const { return GTK_WINDOW(static_cast<WidgetGtk*>(GetWidget())->GetNativeView()); @@ -315,16 +283,6 @@ bool BackgroundView::IsScreenLockerMode() const { return false; } -void BackgroundView::ButtonPressed(views::Button* sender, - const views::Event& event) { - if (sender == go_incognito_button_) { - DCHECK(delegate_); - if (delegate_) { - delegate_->OnGoIncognitoButton(); - } - } -} - /////////////////////////////////////////////////////////////////////////////// // BackgroundView private: @@ -385,51 +343,6 @@ void BackgroundView::InitProgressBar() { AddChildView(progress_bar_); } -void BackgroundView::InitGoIncognitoButton() { - SkColor kButtonColor = 0xFF4F6985; - SkColor kStrokeColor = 0xFF657A91; - int kStrokeWidth = 1; - int kVerticalPadding = 8; - int kHorizontalPadding = 12; - int kCornerRadius = 4; - - go_incognito_button_ = - new TextButtonWithHandCursorOver(this, std::wstring()); - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - go_incognito_button_->SetIcon(*rb.GetBitmapNamed(IDR_INCOGNITO_GUY)); - go_incognito_button_->SetFocusable(true); - // Set label colors. - go_incognito_button_->SetEnabledColor(SK_ColorWHITE); - go_incognito_button_->SetDisabledColor(SK_ColorWHITE); - go_incognito_button_->SetHighlightColor(SK_ColorWHITE); - go_incognito_button_->SetHoverColor(SK_ColorWHITE); - // Disable throbbing and make border always visible. - go_incognito_button_->SetAnimationDuration(0); - go_incognito_button_->SetNormalHasBorder(true); - // Setup round shapes. - go_incognito_button_->set_background( - CreateRoundedBackground( - kCornerRadius, kStrokeWidth, kButtonColor, kStrokeColor)); - - go_incognito_button_->set_border( - views::Border::CreateEmptyBorder(kVerticalPadding, - kHorizontalPadding, - kVerticalPadding, - kHorizontalPadding)); - // Set button text. - UpdateLocalizedStrings(); - // Enable and add to the views hierarchy. - go_incognito_button_->SetEnabled(true); - AddChildView(go_incognito_button_); -} - -void BackgroundView::UpdateLocalizedStrings() { - if (go_incognito_button_) { - go_incognito_button_->SetText( - UTF8ToWide(l10n_util::GetStringUTF8(IDS_GO_INCOGNITO_BUTTON))); - } -} - void BackgroundView::UpdateWindowType() { std::vector<int> params; params.push_back(did_paint_ ? 1 : 0); diff --git a/chrome/browser/chromeos/login/background_view.h b/chrome/browser/chromeos/login/background_view.h index e64caf7..3b9a7d4 100644 --- a/chrome/browser/chromeos/login/background_view.h +++ b/chrome/browser/chromeos/login/background_view.h @@ -10,13 +10,12 @@ #include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/status/status_area_host.h" #include "chrome/browser/chromeos/version_loader.h" -#include "views/controls/button/button.h" #include "views/view.h" namespace views { -class Widget; class Label; class TextButton; +class Widget; } class DOMView; @@ -26,23 +25,14 @@ class Profile; namespace chromeos { class OobeProgressBar; +class ShutdownButton; class StatusAreaView; // View used to render the background during login. BackgroundView contains // StatusAreaView. class BackgroundView : public views::View, - public StatusAreaHost, - public views::ButtonListener { + public StatusAreaHost { public: - // Delegate class to handle notificatoin from the view. - class Delegate { - public: - virtual ~Delegate() {} - - // Initializes incognito login. - virtual void OnGoIncognitoButton() = 0; - }; - enum LoginStep { SELECT_NETWORK, #if defined(OFFICIAL_BUILD) @@ -61,6 +51,9 @@ class BackgroundView : public views::View, // it creates a DOMView background area that renders a webpage. void Init(const GURL& background_url); + // Enable shutdown button. + void EnableShutdownButton(); + // 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|. If background_url is non @@ -82,9 +75,6 @@ class BackgroundView : public views::View, // Sets current step on OOBE progress bar. void SetOobeProgress(LoginStep step); - // Toggles GoIncognito button visibility. - void SetGoIncognitoButtonVisible(bool visible, Delegate *delegate); - // Shows screen saver. void ShowScreenSaver(); @@ -97,15 +87,11 @@ class BackgroundView : public views::View, // Tells if screen saver is enabled. bool ScreenSaverEnabled(); - // Tells that owner has been changed. - void OnOwnerChanged(); - protected: // Overridden from views::View: virtual void Paint(gfx::Canvas* canvas); virtual void Layout(); virtual void ChildPreferredSizeChanged(View* child); - virtual void OnLocaleChanged(); // Overridden from StatusAreaHost: virtual Profile* GetProfile() const { return NULL; } @@ -117,9 +103,6 @@ class BackgroundView : public views::View, virtual bool IsBrowserMode() const; virtual bool IsScreenLockerMode() const; - // Overridden from views::ButtonListener. - virtual void ButtonPressed(views::Button* sender, const views::Event& event); - private: // Creates and adds the status_area. void InitStatusArea(); @@ -127,11 +110,6 @@ class BackgroundView : public views::View, void InitInfoLabels(); // Creates and add OOBE progress bar. void InitProgressBar(); - // Creates and add GoIncoginito button. - void InitGoIncognitoButton(); - - // Updates string from the resources. - void UpdateLocalizedStrings(); // Invokes SetWindowType for the window. This is invoked during startup and // after we've painted. @@ -148,7 +126,7 @@ class BackgroundView : public views::View, views::Label* os_version_label_; views::Label* boot_times_label_; OobeProgressBar* progress_bar_; - views::TextButton* go_incognito_button_; + ShutdownButton* shutdown_button_; // Handles asynchronously loading the version. VersionLoader version_loader_; @@ -165,10 +143,6 @@ class BackgroundView : public views::View, // TODO(sky): nuke this when the wm knows when chrome has painted. bool did_paint_; - // NOTE: |delegate_| is assigned to NULL when the owner is changed. See - // 'OnOwnerChanged()' for more info. - Delegate *delegate_; - // True if running official BUILD. bool is_official_build_; diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc index 35a9537..add663b 100644 --- a/chrome/browser/chromeos/login/existing_user_controller.cc +++ b/chrome/browser/chromeos/login/existing_user_controller.cc @@ -27,6 +27,7 @@ #include "chrome/browser/chromeos/login/login_utils.h" #include "chrome/browser/chromeos/login/message_bubble.h" #include "chrome/browser/chromeos/login/wizard_controller.h" +#include "chrome/browser/chromeos/view_ids.h" #include "chrome/browser/chromeos/wm_ipc.h" #include "chrome/browser/views/window.h" #include "chrome/common/chrome_switches.h" @@ -157,6 +158,7 @@ void ExistingUserController::Init() { background_bounds_, GURL(url_string), &background_view_); + background_view_->EnableShutdownButton(); if (!WizardController::IsDeviceRegistered()) { background_view_->SetOobeProgressBarVisible(true); @@ -188,7 +190,6 @@ void ExistingUserController::OwnBackground( DCHECK(!background_window_); background_window_ = background_widget; background_view_ = background_view; - background_view_->OnOwnerChanged(); } void ExistingUserController::LoginNewUser(const std::string& username, @@ -362,10 +363,6 @@ void ExistingUserController::SelectUser(int index) { } } -void ExistingUserController::OnGoIncognitoButton() { - LoginOffTheRecord(); -} - void ExistingUserController::OnLoginFailure(const LoginFailure& failure) { std::string error = failure.GetErrorString(); diff --git a/chrome/browser/chromeos/login/existing_user_controller.h b/chrome/browser/chromeos/login/existing_user_controller.h index 766250a..080ff9c 100644 --- a/chrome/browser/chromeos/login/existing_user_controller.h +++ b/chrome/browser/chromeos/login/existing_user_controller.h @@ -27,10 +27,11 @@ namespace chromeos { class HelpAppLauncher; class MessageBubble; -// ExistingUserController is used to handle login when someone has already -// logged into the machine. When Init is invoked a UserController is created for -// each of the Users's in the UserManager (including one for new user and -// one for BWSI login), and the window manager is then told to show the windows. +// ExistingUserController is used to handle login when someone has +// already logged into the machine. When Init is invoked, a +// UserController is created for each of the Users's in the +// UserManager (including one for new user and one for Guest login), +// and the window manager is then told to show the windows. // // To use ExistingUserController create an instance of it and invoke Init. // @@ -38,7 +39,6 @@ class MessageBubble; // the user logs in (or chooses to see other settings). class ExistingUserController : public WmMessageListener::Observer, public UserController::Delegate, - public BackgroundView::Delegate, public LoginPerformer::Delegate, public MessageBubbleDelegate, public CaptchaView::Delegate, @@ -85,9 +85,6 @@ class ExistingUserController : public WmMessageListener::Observer, virtual void AddStartUrl(const GURL& start_url) { start_url_ = start_url; } virtual void SelectUser(int index); - // BackgroundView::Delegate - virtual void OnGoIncognitoButton(); - // LoginPerformer::Delegate implementation: virtual void OnLoginFailure(const LoginFailure& error); virtual void OnLoginSuccess( diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc index a965dd9..19c2059 100644 --- a/chrome/browser/chromeos/login/screen_locker.cc +++ b/chrome/browser/chromeos/login/screen_locker.cc @@ -30,6 +30,7 @@ #include "chrome/browser/chromeos/login/login_utils.h" #include "chrome/browser/chromeos/login/message_bubble.h" #include "chrome/browser/chromeos/login/screen_lock_view.h" +#include "chrome/browser/chromeos/login/shutdown_button.h" #include "chrome/browser/chromeos/wm_ipc.h" #include "chrome/browser/metrics/user_metrics.h" #include "chrome/common/chrome_switches.h" @@ -224,6 +225,33 @@ class LockWindow : public views::WidgetGtk { DISALLOW_COPY_AND_ASSIGN(LockWindow); }; +// GrabWidget's root view to layout the ScreenLockView at the center +// and the Shutdown button at the right bottom. +class GrabWidgetRootView : public views::View { + public: + explicit GrabWidgetRootView(chromeos::ScreenLockView* screen_lock_view) + : screen_lock_view_(screen_lock_view), + shutdown_button_(new chromeos::ShutdownButton()) { + shutdown_button_->Init(); + AddChildView(screen_lock_view_); + AddChildView(shutdown_button_); + } + + // views::View implementation. + virtual void Layout() { + gfx::Size size = screen_lock_view_->GetPreferredSize(); + screen_lock_view_->SetBounds(0, 0, size.width(), size.height()); + shutdown_button_->LayoutIn(this); + } + + private: + views::View* screen_lock_view_; + + chromeos::ShutdownButton* shutdown_button_; + + DISALLOW_COPY_AND_ASSIGN(GrabWidgetRootView); +}; + // A child widget that grabs both keyboard and pointer input. class GrabWidget : public views::WidgetGtk { public: @@ -330,8 +358,10 @@ void GrabWidget::TryGrabAllInputs() { // addition to other background components. class ScreenLockerBackgroundView : public chromeos::BackgroundView { public: - explicit ScreenLockerBackgroundView(views::WidgetGtk* lock_widget) - : lock_widget_(lock_widget) { + ScreenLockerBackgroundView(views::WidgetGtk* lock_widget, + views::View* screen_lock_view) + : lock_widget_(lock_widget), + screen_lock_view_(screen_lock_view) { } virtual bool IsScreenLockerMode() const { @@ -341,17 +371,24 @@ class ScreenLockerBackgroundView : public chromeos::BackgroundView { virtual void Layout() { chromeos::BackgroundView::Layout(); gfx::Rect screen = bounds(); - gfx::Size size = lock_widget_->GetRootView()->GetPreferredSize(); - lock_widget_->SetBounds( - gfx::Rect((screen.width() - size.width()) / 2, - (screen.height() - size.height()) / 2, - size.width(), - size.height())); + if (screen_lock_view_) { + gfx::Size size = screen_lock_view_->GetPreferredSize(); + gfx::Point origin((screen.width() - size.width()) / 2, + (screen.height() - size.height()) / 2); + gfx::Size widget_size(screen.size()); + widget_size.Enlarge(-origin.x(), -origin.y()); + lock_widget_->SetBounds(gfx::Rect(origin, widget_size)); + } else { + // No password entry. Move the lock widget to off screen. + lock_widget_->SetBounds(gfx::Rect(-100, -100, 1, 1)); + } } private: views::WidgetGtk* lock_widget_; + views::View* screen_lock_view_; + DISALLOW_COPY_AND_ASSIGN(ScreenLockerBackgroundView); }; @@ -540,15 +577,19 @@ void ScreenLocker::Init() { lock_widget_ = new GrabWidget(this); lock_widget_->MakeTransparent(); lock_widget_->InitWithWidget(lock_window_, gfx::Rect()); - if (screen_lock_view_) - lock_widget_->SetContentsView(screen_lock_view_); + if (screen_lock_view_) { + lock_widget_->SetContentsView( + new GrabWidgetRootView(screen_lock_view_)); + } + lock_widget_->Show(); // Configuring the background url. std::string url_string = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( switches::kScreenSaverUrl); - background_view_ = new ScreenLockerBackgroundView(lock_widget_); + background_view_ = new ScreenLockerBackgroundView(lock_widget_, + screen_lock_view_); background_view_->Init(GURL(url_string)); if (background_view_->ScreenSaverEnabled()) StartScreenSaver(); diff --git a/chrome/browser/chromeos/login/shutdown_button.cc b/chrome/browser/chromeos/login/shutdown_button.cc new file mode 100644 index 0000000..b677915 --- /dev/null +++ b/chrome/browser/chromeos/login/shutdown_button.cc @@ -0,0 +1,124 @@ +// Copyright (c) 2011 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/shutdown_button.h" + +#include "app/l10n_util.h" +#include "app/resource_bundle.h" +#include "base/utf_string_conversions.h" +#include "chrome/browser/chromeos/cros/cros_library.h" +#include "chrome/browser/chromeos/cros/power_library.h" +#include "chrome/browser/chromeos/login/rounded_rect_painter.h" +#include "chrome/browser/chromeos/view_ids.h" +#include "grit/generated_resources.h" +#include "grit/theme_resources.h" +#include "views/background.h" + +namespace { + +// Bottom/Right Padding for Shutdown button. +const int kBottomPadding = 12; +const int kRightPadding = 12; + +class HoverBackground : public views::Background { + public: + HoverBackground(views::Background* normal, views::Background* hover) + : normal_(normal), hover_(hover) { + } + + // views::Background implementation. + virtual void Paint(gfx::Canvas* canvas, views::View* view) const { + views::TextButton* button = static_cast<views::TextButton*>(view); + if (button->state() == views::CustomButton::BS_HOT) { + hover_->Paint(canvas, view); + } else { + normal_->Paint(canvas, view); + } + } + + private: + views::Background* normal_; + views::Background* hover_; + + DISALLOW_COPY_AND_ASSIGN(HoverBackground); +}; + +} // namespace + +namespace chromeos { + +ShutdownButton::ShutdownButton() + : ALLOW_THIS_IN_INITIALIZER_LIST(TextButton(this, std::wstring())) { +} + +void ShutdownButton::Init() { + SkColor kButtonColor = 0xFF242A35; + SkColor kHoverColor = 0xFF353E4E; + int kVerticalPadding = 13; + int kIconTextPadding = 10; + int kHorizontalPadding = 13; + int kCornerRadius = 4; + + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + SetIcon(*rb.GetBitmapNamed(IDR_SHUTDOWN_ICON)); + set_icon_text_spacing(kIconTextPadding); + SetFocusable(true); + // Set label colors. + SetEnabledColor(SK_ColorWHITE); + SetDisabledColor(SK_ColorWHITE); + SetHighlightColor(SK_ColorWHITE); + SetHoverColor(SK_ColorWHITE); + // Disable throbbing and make border always visible. + SetAnimationDuration(0); + SetNormalHasBorder(true); + // Setup round shapes. + set_background( + new HoverBackground( + CreateRoundedBackground( + kCornerRadius, 0, kButtonColor, 0), + CreateRoundedBackground( + kCornerRadius, 0, kHoverColor, 0))); + set_border( + views::Border::CreateEmptyBorder(kVerticalPadding, + kHorizontalPadding, + kVerticalPadding, + kHorizontalPadding)); + OnLocaleChanged(); // set text +} + +void ShutdownButton::LayoutIn(views::View* parent) { + // No RTL for now. RTL will be handled in new + // domui based Login/Locker. + gfx::Size button_size = GetPreferredSize(); + SetBounds( + parent->width() - button_size.width()- kRightPadding, + parent->height() - button_size.height() - kBottomPadding, + button_size.width(), + button_size.height()); +} + +void ShutdownButton::OnLocaleChanged() { + SetText(UTF8ToWide(l10n_util::GetStringUTF8(IDS_SHUTDOWN_BUTTON))); + if (GetParent()) { + GetParent()->Layout(); + GetParent()->SchedulePaint(); + } +} + +gfx::NativeCursor ShutdownButton::GetCursorForPoint( + views::Event::EventType event_type, + const gfx::Point& p) { + if (!IsEnabled()) { + return NULL; + } + return gdk_cursor_new(GDK_HAND2); +} + +void ShutdownButton::ButtonPressed(views::Button* sender, + const views::Event& event) { + DCHECK(CrosLibrary::Get()->EnsureLoaded()); + CrosLibrary::Get()->GetPowerLibrary()->RequestShutdown(); +} + +} // namespace chromeos diff --git a/chrome/browser/chromeos/login/shutdown_button.h b/chrome/browser/chromeos/login/shutdown_button.h new file mode 100644 index 0000000..20b3894 --- /dev/null +++ b/chrome/browser/chromeos/login/shutdown_button.h @@ -0,0 +1,40 @@ +// Copyright (c) 2011 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_SHUTDOWN_BUTTON_H_ +#define CHROME_BROWSER_CHROMEOS_SHUTDOWN_BUTTON_H_ +#pragma once + +#include "views/controls/button/text_button.h" + +namespace chromeos { + +class ShutdownButton : public views::TextButton, + public views::ButtonListener { + public: + ShutdownButton(); + + // Initializes shutdown button. + void Init(); + + // Layout the shutdown button at the right bottom corner of + // |parent|. + void LayoutIn(views::View* parent); + + private: + // views::View overrides. + virtual void OnLocaleChanged(); + virtual gfx::NativeCursor GetCursorForPoint( + views::Event::EventType event_type, + const gfx::Point& p); + + // views::ButtonListener implementation. + virtual void ButtonPressed(views::Button* sender, const views::Event& event); + + DISALLOW_COPY_AND_ASSIGN(ShutdownButton); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_SHUTDOWN_BUTTON_H diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc index 4899525..1962a29 100644 --- a/chrome/browser/chromeos/login/wizard_controller.cc +++ b/chrome/browser/chromeos/login/wizard_controller.cc @@ -319,7 +319,6 @@ void WizardController::OwnBackground( DCHECK(!background_widget_); background_widget_ = background_widget; background_view_ = background_view; - background_view_->OnOwnerChanged(); } chromeos::NetworkScreen* WizardController::GetNetworkScreen() { diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 62f7fd2..eded665 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -619,6 +619,8 @@ 'browser/chromeos/login/screen_lock_view.cc', 'browser/chromeos/login/screen_lock_view.h', 'browser/chromeos/login/screen_observer.h', + 'browser/chromeos/login/shutdown_button.cc', + 'browser/chromeos/login/shutdown_button.h', 'browser/chromeos/login/signed_settings.cc', 'browser/chromeos/login/signed_settings.h', 'browser/chromeos/login/signed_settings_helper.cc', |