| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/accelerators/exit_warning_handler.h" | 5 #include "ash/accelerators/exit_warning_handler.h" |
| 6 | 6 |
| 7 #include "ash/metrics/user_metrics_recorder.h" | 7 #include "ash/metrics/user_metrics_recorder.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_delegate.h" | 9 #include "ash/shell_delegate.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 const int64 kTimeOutMilliseconds = 2000; | 31 const int64 kTimeOutMilliseconds = 2000; |
| 32 // Color of the text of the warning message. | 32 // Color of the text of the warning message. |
| 33 const SkColor kTextColor = SK_ColorWHITE; | 33 const SkColor kTextColor = SK_ColorWHITE; |
| 34 // Color of the window background. | 34 // Color of the window background. |
| 35 const SkColor kWindowBackgroundColor = SkColorSetARGB(0xC0, 0x0, 0x0, 0x0); | 35 const SkColor kWindowBackgroundColor = SkColorSetARGB(0xC0, 0x0, 0x0, 0x0); |
| 36 // Radius of the rounded corners of the window. | 36 // Radius of the rounded corners of the window. |
| 37 const int kWindowCornerRadius = 2; | 37 const int kWindowCornerRadius = 2; |
| 38 const int kHorizontalMarginAroundText = 100; | 38 const int kHorizontalMarginAroundText = 100; |
| 39 const int kVerticalMarginAroundText = 100; | 39 const int kVerticalMarginAroundText = 100; |
| 40 | 40 |
| 41 class ExitWarningLabel : public views::Label { | |
| 42 public: | |
| 43 ExitWarningLabel() {} | |
| 44 | |
| 45 virtual ~ExitWarningLabel() {} | |
| 46 | |
| 47 private: | |
| 48 virtual void PaintText(gfx::Canvas* canvas, | |
| 49 const base::string16& text, | |
| 50 const gfx::Rect& text_bounds, | |
| 51 int flags) OVERRIDE { | |
| 52 // Turn off subpixel rendering. | |
| 53 views::Label::PaintText(canvas, | |
| 54 text, | |
| 55 text_bounds, | |
| 56 flags | gfx::Canvas::NO_SUBPIXEL_RENDERING); | |
| 57 } | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(ExitWarningLabel); | |
| 60 }; | |
| 61 | |
| 62 class ExitWarningWidgetDelegateView : public views::WidgetDelegateView { | 41 class ExitWarningWidgetDelegateView : public views::WidgetDelegateView { |
| 63 public: | 42 public: |
| 64 ExitWarningWidgetDelegateView() : text_width_(0), width_(0), height_(0) { | 43 ExitWarningWidgetDelegateView() : text_width_(0), width_(0), height_(0) { |
| 65 #ifdef OS_CHROMEOS | 44 #ifdef OS_CHROMEOS |
| 66 text_ = l10n_util::GetStringUTF16(IDS_ASH_SIGN_OUT_WARNING_POPUP_TEXT); | 45 text_ = l10n_util::GetStringUTF16(IDS_ASH_SIGN_OUT_WARNING_POPUP_TEXT); |
| 67 accessible_name_ = l10n_util::GetStringUTF16( | 46 accessible_name_ = l10n_util::GetStringUTF16( |
| 68 IDS_ASH_SIGN_OUT_WARNING_POPUP_TEXT_ACCESSIBLE); | 47 IDS_ASH_SIGN_OUT_WARNING_POPUP_TEXT_ACCESSIBLE); |
| 69 #else | 48 #else |
| 70 text_ = l10n_util::GetStringUTF16(IDS_ASH_EXIT_WARNING_POPUP_TEXT); | 49 text_ = l10n_util::GetStringUTF16(IDS_ASH_EXIT_WARNING_POPUP_TEXT); |
| 71 accessible_name_ = | 50 accessible_name_ = |
| 72 l10n_util::GetStringUTF16(IDS_ASH_EXIT_WARNING_POPUP_TEXT_ACCESSIBLE); | 51 l10n_util::GetStringUTF16(IDS_ASH_EXIT_WARNING_POPUP_TEXT_ACCESSIBLE); |
| 73 #endif | 52 #endif |
| 74 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 53 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 75 const gfx::FontList& font_list = | 54 const gfx::FontList& font_list = |
| 76 rb.GetFontList(ui::ResourceBundle::LargeFont); | 55 rb.GetFontList(ui::ResourceBundle::LargeFont); |
| 77 text_width_ = gfx::GetStringWidth(text_, font_list); | 56 text_width_ = gfx::GetStringWidth(text_, font_list); |
| 78 width_ = text_width_ + kHorizontalMarginAroundText; | 57 width_ = text_width_ + kHorizontalMarginAroundText; |
| 79 height_ = font_list.GetHeight() + kVerticalMarginAroundText; | 58 height_ = font_list.GetHeight() + kVerticalMarginAroundText; |
| 80 views::Label* label = new ExitWarningLabel; | 59 views::Label* label = new views::Label(); |
| 81 label->SetText(text_); | 60 label->SetText(text_); |
| 82 label->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 61 label->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 83 label->SetFontList(font_list); | 62 label->SetFontList(font_list); |
| 84 label->SetEnabledColor(kTextColor); | 63 label->SetEnabledColor(kTextColor); |
| 85 label->SetDisabledColor(kTextColor); | 64 label->SetDisabledColor(kTextColor); |
| 86 label->SetAutoColorReadabilityEnabled(false); | 65 label->SetAutoColorReadabilityEnabled(false); |
| 66 label->set_subpixel_rendering_enabled(false); |
| 87 AddChildView(label); | 67 AddChildView(label); |
| 88 SetLayoutManager(new views::FillLayout); | 68 SetLayoutManager(new views::FillLayout); |
| 89 } | 69 } |
| 90 | 70 |
| 91 virtual gfx::Size GetPreferredSize() const OVERRIDE { | 71 virtual gfx::Size GetPreferredSize() const OVERRIDE { |
| 92 return gfx::Size(width_, height_); | 72 return gfx::Size(width_, height_); |
| 93 } | 73 } |
| 94 | 74 |
| 95 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { | 75 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { |
| 96 SkPaint paint; | 76 SkPaint paint; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 widget_->Show(); | 180 widget_->Show(); |
| 201 | 181 |
| 202 delegate->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); | 182 delegate->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); |
| 203 } | 183 } |
| 204 | 184 |
| 205 void ExitWarningHandler::Hide() { | 185 void ExitWarningHandler::Hide() { |
| 206 widget_.reset(); | 186 widget_.reset(); |
| 207 } | 187 } |
| 208 | 188 |
| 209 } // namespace ash | 189 } // namespace ash |
| OLD | NEW |