Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: ash/shell/window_type_launcher.cc

Issue 679283002: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/shell/window_type_launcher.h" 5 #include "ash/shell/window_type_launcher.h"
6 6
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/screensaver/screensaver_view.h" 8 #include "ash/screensaver/screensaver_view.h"
9 #include "ash/session/session_state_delegate.h" 9 #include "ash/session/session_state_delegate.h"
10 #include "ash/shelf/shelf_widget.h" 10 #include "ash/shelf/shelf_widget.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 public: 54 public:
55 explicit ModalWindow(ui::ModalType modal_type) 55 explicit ModalWindow(ui::ModalType modal_type)
56 : modal_type_(modal_type), 56 : modal_type_(modal_type),
57 color_(g_colors[g_color_index]), 57 color_(g_colors[g_color_index]),
58 open_button_(new views::LabelButton(this, 58 open_button_(new views::LabelButton(this,
59 base::ASCIIToUTF16("Moar!"))) { 59 base::ASCIIToUTF16("Moar!"))) {
60 ++g_color_index %= arraysize(g_colors); 60 ++g_color_index %= arraysize(g_colors);
61 open_button_->SetStyle(views::Button::STYLE_BUTTON); 61 open_button_->SetStyle(views::Button::STYLE_BUTTON);
62 AddChildView(open_button_); 62 AddChildView(open_button_);
63 } 63 }
64 virtual ~ModalWindow() { 64 ~ModalWindow() override {}
65 }
66 65
67 static void OpenModalWindow(aura::Window* parent, ui::ModalType modal_type) { 66 static void OpenModalWindow(aura::Window* parent, ui::ModalType modal_type) {
68 views::Widget* widget = 67 views::Widget* widget =
69 views::Widget::CreateWindowWithParent(new ModalWindow(modal_type), 68 views::Widget::CreateWindowWithParent(new ModalWindow(modal_type),
70 parent); 69 parent);
71 widget->GetNativeView()->SetName("ModalWindow"); 70 widget->GetNativeView()->SetName("ModalWindow");
72 widget->Show(); 71 widget->Show();
73 } 72 }
74 73
75 // Overridden from views::View: 74 // Overridden from views::View:
76 virtual void OnPaint(gfx::Canvas* canvas) override { 75 void OnPaint(gfx::Canvas* canvas) override {
77 canvas->FillRect(GetLocalBounds(), color_); 76 canvas->FillRect(GetLocalBounds(), color_);
78 } 77 }
79 virtual gfx::Size GetPreferredSize() const override { 78 gfx::Size GetPreferredSize() const override { return gfx::Size(200, 200); }
80 return gfx::Size(200, 200); 79 void Layout() override {
81 }
82 virtual void Layout() override {
83 gfx::Size open_ps = open_button_->GetPreferredSize(); 80 gfx::Size open_ps = open_button_->GetPreferredSize();
84 gfx::Rect local_bounds = GetLocalBounds(); 81 gfx::Rect local_bounds = GetLocalBounds();
85 open_button_->SetBounds( 82 open_button_->SetBounds(
86 5, local_bounds.bottom() - open_ps.height() - 5, 83 5, local_bounds.bottom() - open_ps.height() - 5,
87 open_ps.width(), open_ps.height()); 84 open_ps.width(), open_ps.height());
88 } 85 }
89 86
90 // Overridden from views::WidgetDelegate: 87 // Overridden from views::WidgetDelegate:
91 virtual views::View* GetContentsView() override { 88 views::View* GetContentsView() override { return this; }
92 return this; 89 bool CanResize() const override { return true; }
93 } 90 base::string16 GetWindowTitle() const override {
94 virtual bool CanResize() const override {
95 return true;
96 }
97 virtual base::string16 GetWindowTitle() const override {
98 return base::ASCIIToUTF16("Modal Window"); 91 return base::ASCIIToUTF16("Modal Window");
99 } 92 }
100 virtual ui::ModalType GetModalType() const override { 93 ui::ModalType GetModalType() const override { return modal_type_; }
101 return modal_type_;
102 }
103 94
104 // Overridden from views::ButtonListener: 95 // Overridden from views::ButtonListener:
105 virtual void ButtonPressed(views::Button* sender, 96 void ButtonPressed(views::Button* sender, const ui::Event& event) override {
106 const ui::Event& event) override {
107 DCHECK(sender == open_button_); 97 DCHECK(sender == open_button_);
108 OpenModalWindow(GetWidget()->GetNativeView(), modal_type_); 98 OpenModalWindow(GetWidget()->GetNativeView(), modal_type_);
109 } 99 }
110 100
111 private: 101 private:
112 ui::ModalType modal_type_; 102 ui::ModalType modal_type_;
113 SkColor color_; 103 SkColor color_;
114 views::LabelButton* open_button_; 104 views::LabelButton* open_button_;
115 105
116 DISALLOW_COPY_AND_ASSIGN(ModalWindow); 106 DISALLOW_COPY_AND_ASSIGN(ModalWindow);
117 }; 107 };
118 108
119 class NonModalTransient : public views::WidgetDelegateView { 109 class NonModalTransient : public views::WidgetDelegateView {
120 public: 110 public:
121 NonModalTransient() 111 NonModalTransient()
122 : color_(g_colors[g_color_index]) { 112 : color_(g_colors[g_color_index]) {
123 ++g_color_index %= arraysize(g_colors); 113 ++g_color_index %= arraysize(g_colors);
124 } 114 }
125 virtual ~NonModalTransient() { 115 ~NonModalTransient() override {}
126 }
127 116
128 static void OpenNonModalTransient(aura::Window* parent) { 117 static void OpenNonModalTransient(aura::Window* parent) {
129 views::Widget* widget = 118 views::Widget* widget =
130 views::Widget::CreateWindowWithParent(new NonModalTransient, parent); 119 views::Widget::CreateWindowWithParent(new NonModalTransient, parent);
131 widget->GetNativeView()->SetName("NonModalTransient"); 120 widget->GetNativeView()->SetName("NonModalTransient");
132 widget->Show(); 121 widget->Show();
133 } 122 }
134 123
135 static void ToggleNonModalTransient(aura::Window* parent) { 124 static void ToggleNonModalTransient(aura::Window* parent) {
136 if (!non_modal_transient_) { 125 if (!non_modal_transient_) {
137 non_modal_transient_ = 126 non_modal_transient_ =
138 views::Widget::CreateWindowWithParent(new NonModalTransient, parent); 127 views::Widget::CreateWindowWithParent(new NonModalTransient, parent);
139 non_modal_transient_->GetNativeView()->SetName("NonModalTransient"); 128 non_modal_transient_->GetNativeView()->SetName("NonModalTransient");
140 } 129 }
141 if (non_modal_transient_->IsVisible()) 130 if (non_modal_transient_->IsVisible())
142 non_modal_transient_->Hide(); 131 non_modal_transient_->Hide();
143 else 132 else
144 non_modal_transient_->Show(); 133 non_modal_transient_->Show();
145 } 134 }
146 135
147 // Overridden from views::View: 136 // Overridden from views::View:
148 virtual void OnPaint(gfx::Canvas* canvas) override { 137 void OnPaint(gfx::Canvas* canvas) override {
149 canvas->FillRect(GetLocalBounds(), color_); 138 canvas->FillRect(GetLocalBounds(), color_);
150 } 139 }
151 virtual gfx::Size GetPreferredSize() const override { 140 gfx::Size GetPreferredSize() const override { return gfx::Size(250, 250); }
152 return gfx::Size(250, 250);
153 }
154 141
155 // Overridden from views::WidgetDelegate: 142 // Overridden from views::WidgetDelegate:
156 virtual views::View* GetContentsView() override { 143 views::View* GetContentsView() override { return this; }
157 return this; 144 bool CanResize() const override { return true; }
158 } 145 base::string16 GetWindowTitle() const override {
159 virtual bool CanResize() const override {
160 return true;
161 }
162 virtual base::string16 GetWindowTitle() const override {
163 return base::ASCIIToUTF16("Non-Modal Transient"); 146 return base::ASCIIToUTF16("Non-Modal Transient");
164 } 147 }
165 virtual void DeleteDelegate() override { 148 void DeleteDelegate() override {
166 if (GetWidget() == non_modal_transient_) 149 if (GetWidget() == non_modal_transient_)
167 non_modal_transient_ = NULL; 150 non_modal_transient_ = NULL;
168 151
169 delete this; 152 delete this;
170 } 153 }
171 154
172 private: 155 private:
173 SkColor color_; 156 SkColor color_;
174 157
175 static views::Widget* non_modal_transient_; 158 static views::Widget* non_modal_transient_;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 NULL, 379 NULL,
397 gfx::Rect(point, gfx::Size()), 380 gfx::Rect(point, gfx::Size()),
398 views::MENU_ANCHOR_TOPLEFT, 381 views::MENU_ANCHOR_TOPLEFT,
399 source_type) == MenuRunner::MENU_DELETED) { 382 source_type) == MenuRunner::MENU_DELETED) {
400 return; 383 return;
401 } 384 }
402 } 385 }
403 386
404 } // namespace shell 387 } // namespace shell
405 } // namespace ash 388 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698