| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/chromeos/ui/kiosk_external_update_notification.h" | 5 #include "chrome/browser/chromeos/ui/kiosk_external_update_notification.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
| 9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 class KioskExternalUpdateNotificationView : public views::WidgetDelegateView { | 32 class KioskExternalUpdateNotificationView : public views::WidgetDelegateView { |
| 33 public: | 33 public: |
| 34 explicit KioskExternalUpdateNotificationView( | 34 explicit KioskExternalUpdateNotificationView( |
| 35 KioskExternalUpdateNotification* owner) | 35 KioskExternalUpdateNotification* owner) |
| 36 : owner_(owner), widget_closed_(false) { | 36 : owner_(owner), widget_closed_(false) { |
| 37 AddLabel(); | 37 AddLabel(); |
| 38 SetLayoutManager(new views::FillLayout); | 38 SetLayoutManager(new views::FillLayout); |
| 39 } | 39 } |
| 40 | 40 |
| 41 virtual ~KioskExternalUpdateNotificationView() { | 41 ~KioskExternalUpdateNotificationView() override { |
| 42 widget_closed_ = true; | 42 widget_closed_ = true; |
| 43 InformOwnerForDismiss(); | 43 InformOwnerForDismiss(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 // Closes the widget immediately from |owner_|. | 46 // Closes the widget immediately from |owner_|. |
| 47 void CloseByOwner() { | 47 void CloseByOwner() { |
| 48 owner_ = NULL; | 48 owner_ = NULL; |
| 49 if (!widget_closed_) { | 49 if (!widget_closed_) { |
| 50 widget_closed_ = true; | 50 widget_closed_ = true; |
| 51 GetWidget()->Close(); | 51 GetWidget()->Close(); |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 void SetMessage(const base::string16& message) { label_->SetText(message); } | 55 void SetMessage(const base::string16& message) { label_->SetText(message); } |
| 56 | 56 |
| 57 // views::WidgetDelegateView overrides: | 57 // views::WidgetDelegateView overrides: |
| 58 virtual void OnPaint(gfx::Canvas* canvas) override { | 58 void OnPaint(gfx::Canvas* canvas) override { |
| 59 SkPaint paint; | 59 SkPaint paint; |
| 60 paint.setStyle(SkPaint::kFill_Style); | 60 paint.setStyle(SkPaint::kFill_Style); |
| 61 paint.setColor(kWindowBackgroundColor); | 61 paint.setColor(kWindowBackgroundColor); |
| 62 canvas->DrawRoundRect(GetLocalBounds(), kWindowCornerRadius, paint); | 62 canvas->DrawRoundRect(GetLocalBounds(), kWindowCornerRadius, paint); |
| 63 views::WidgetDelegateView::OnPaint(canvas); | 63 views::WidgetDelegateView::OnPaint(canvas); |
| 64 } | 64 } |
| 65 | 65 |
| 66 virtual gfx::Size GetPreferredSize() const override { | 66 gfx::Size GetPreferredSize() const override { |
| 67 return gfx::Size(kPreferredWidth, kPreferredHeight); | 67 return gfx::Size(kPreferredWidth, kPreferredHeight); |
| 68 } | 68 } |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 void AddLabel() { | 71 void AddLabel() { |
| 72 label_ = new views::Label; | 72 label_ = new views::Label; |
| 73 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 73 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 74 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 74 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 75 label_->SetFontList(rb.GetFontList(ui::ResourceBundle::BoldFont)); | 75 label_->SetFontList(rb.GetFontList(ui::ResourceBundle::BoldFont)); |
| 76 label_->SetEnabledColor(kTextColor); | 76 label_->SetEnabledColor(kTextColor); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 148 |
| 149 void KioskExternalUpdateNotification::Dismiss() { | 149 void KioskExternalUpdateNotification::Dismiss() { |
| 150 if (view_) { | 150 if (view_) { |
| 151 KioskExternalUpdateNotificationView* view = view_; | 151 KioskExternalUpdateNotificationView* view = view_; |
| 152 view_ = NULL; | 152 view_ = NULL; |
| 153 view->CloseByOwner(); | 153 view->CloseByOwner(); |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 | 156 |
| 157 } // namespace chromeos | 157 } // namespace chromeos |
| OLD | NEW |