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

Side by Side Diff: ash/frame/custom_frame_view_ash.cc

Issue 263083005: Remove "Alternate frame caption button style" command line flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months 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 | Annotate | Revision Log
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/frame/custom_frame_view_ash.h" 5 #include "ash/frame/custom_frame_view_ash.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" 8 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
9 #include "ash/frame/caption_buttons/frame_maximize_button.h"
10 #include "ash/frame/caption_buttons/frame_maximize_button_observer.h"
11 #include "ash/frame/default_header_painter.h" 9 #include "ash/frame/default_header_painter.h"
12 #include "ash/frame/frame_border_hit_test_controller.h" 10 #include "ash/frame/frame_border_hit_test_controller.h"
13 #include "ash/frame/frame_util.h" 11 #include "ash/frame/frame_util.h"
14 #include "ash/frame/header_painter.h" 12 #include "ash/frame/header_painter.h"
15 #include "ash/session/session_state_delegate.h" 13 #include "ash/session/session_state_delegate.h"
16 #include "ash/shell.h" 14 #include "ash/shell.h"
17 #include "ash/shell_observer.h" 15 #include "ash/shell_observer.h"
18 #include "ash/wm/immersive_fullscreen_controller.h" 16 #include "ash/wm/immersive_fullscreen_controller.h"
19 #include "ash/wm/window_state.h" 17 #include "ash/wm/window_state.h"
20 #include "ash/wm/window_state_delegate.h" 18 #include "ash/wm/window_state_delegate.h"
21 #include "ash/wm/window_state_observer.h" 19 #include "ash/wm/window_state_observer.h"
22 #include "base/command_line.h" 20 #include "base/command_line.h"
23 #include "ui/aura/client/aura_constants.h" 21 #include "ui/aura/client/aura_constants.h"
24 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
25 #include "ui/aura/window_observer.h" 23 #include "ui/aura/window_observer.h"
26 #include "ui/gfx/canvas.h" 24 #include "ui/gfx/canvas.h"
27 #include "ui/gfx/image/image.h" 25 #include "ui/gfx/image/image.h"
28 #include "ui/gfx/rect.h" 26 #include "ui/gfx/rect.h"
29 #include "ui/gfx/rect_conversions.h" 27 #include "ui/gfx/rect_conversions.h"
30 #include "ui/gfx/size.h" 28 #include "ui/gfx/size.h"
31 #include "ui/views/controls/image_view.h" 29 #include "ui/views/controls/image_view.h"
32 #include "ui/views/view.h" 30 #include "ui/views/view.h"
33 #include "ui/views/widget/widget.h" 31 #include "ui/views/widget/widget.h"
34 #include "ui/views/widget/widget_delegate.h" 32 #include "ui/views/widget/widget_delegate.h"
35 #include "ui/views/widget/widget_deletion_observer.h"
36 33
37 namespace { 34 namespace {
38 35
39 /////////////////////////////////////////////////////////////////////////////// 36 ///////////////////////////////////////////////////////////////////////////////
40 // CustomFrameViewAshWindowStateDelegate 37 // CustomFrameViewAshWindowStateDelegate
41 38
42 // Handles a user's fullscreen request (Shift+F4/F4). Puts the window into 39 // Handles a user's fullscreen request (Shift+F4/F4). Puts the window into
43 // immersive fullscreen if immersive fullscreen is enabled for non-browser 40 // immersive fullscreen if immersive fullscreen is enabled for non-browser
44 // windows. 41 // windows.
45 class CustomFrameViewAshWindowStateDelegate 42 class CustomFrameViewAshWindowStateDelegate
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 namespace ash { 117 namespace ash {
121 118
122 /////////////////////////////////////////////////////////////////////////////// 119 ///////////////////////////////////////////////////////////////////////////////
123 // CustomFrameViewAsh::HeaderView 120 // CustomFrameViewAsh::HeaderView
124 121
125 // View which paints the header. It slides off and on screen in immersive 122 // View which paints the header. It slides off and on screen in immersive
126 // fullscreen. 123 // fullscreen.
127 class CustomFrameViewAsh::HeaderView 124 class CustomFrameViewAsh::HeaderView
128 : public views::View, 125 : public views::View,
129 public ImmersiveFullscreenController::Delegate, 126 public ImmersiveFullscreenController::Delegate,
130 public FrameMaximizeButtonObserver,
131 public ShellObserver { 127 public ShellObserver {
132 public: 128 public:
133 // |frame| is the widget that the caption buttons act on. 129 // |frame| is the widget that the caption buttons act on.
134 explicit HeaderView(views::Widget* frame); 130 explicit HeaderView(views::Widget* frame);
135 virtual ~HeaderView(); 131 virtual ~HeaderView();
136 132
137 // Schedules a repaint for the entire title. 133 // Schedules a repaint for the entire title.
138 void SchedulePaintForTitle(); 134 void SchedulePaintForTitle();
139 135
140 // Tells the window controls to reset themselves to the normal state. 136 // Tells the window controls to reset themselves to the normal state.
(...skipping 27 matching lines...) Expand all
168 } 164 }
169 165
170 private: 166 private:
171 // ImmersiveFullscreenController::Delegate: 167 // ImmersiveFullscreenController::Delegate:
172 virtual void OnImmersiveRevealStarted() OVERRIDE; 168 virtual void OnImmersiveRevealStarted() OVERRIDE;
173 virtual void OnImmersiveRevealEnded() OVERRIDE; 169 virtual void OnImmersiveRevealEnded() OVERRIDE;
174 virtual void OnImmersiveFullscreenExited() OVERRIDE; 170 virtual void OnImmersiveFullscreenExited() OVERRIDE;
175 virtual void SetVisibleFraction(double visible_fraction) OVERRIDE; 171 virtual void SetVisibleFraction(double visible_fraction) OVERRIDE;
176 virtual std::vector<gfx::Rect> GetVisibleBoundsInScreen() const OVERRIDE; 172 virtual std::vector<gfx::Rect> GetVisibleBoundsInScreen() const OVERRIDE;
177 173
178 // FrameMaximizeButtonObserver:
179 virtual void OnMaximizeBubbleShown(views::Widget* bubble) OVERRIDE;
180
181 // The widget that the caption buttons act on. 174 // The widget that the caption buttons act on.
182 views::Widget* frame_; 175 views::Widget* frame_;
183 176
184 // Helper for painting the header. 177 // Helper for painting the header.
185 scoped_ptr<DefaultHeaderPainter> header_painter_; 178 scoped_ptr<DefaultHeaderPainter> header_painter_;
186 179
187 views::ImageView* avatar_icon_; 180 views::ImageView* avatar_icon_;
188 181
189 // View which contains the window caption buttons. 182 // View which contains the window caption buttons.
190 FrameCaptionButtonContainerView* caption_button_container_; 183 FrameCaptionButtonContainerView* caption_button_container_;
191 184
192 // The maximize bubble widget. |maximize_bubble_| may be non-NULL but have
193 // been already destroyed.
194 views::Widget* maximize_bubble_;
195
196 // Keeps track of whether |maximize_bubble_| is still alive.
197 scoped_ptr<views::WidgetDeletionObserver> maximize_bubble_lifetime_observer_;
198
199 // The fraction of the header's height which is visible while in fullscreen. 185 // The fraction of the header's height which is visible while in fullscreen.
200 // This value is meaningless when not in fullscreen. 186 // This value is meaningless when not in fullscreen.
201 double fullscreen_visible_fraction_; 187 double fullscreen_visible_fraction_;
202 188
203 DISALLOW_COPY_AND_ASSIGN(HeaderView); 189 DISALLOW_COPY_AND_ASSIGN(HeaderView);
204 }; 190 };
205 191
206 CustomFrameViewAsh::HeaderView::HeaderView(views::Widget* frame) 192 CustomFrameViewAsh::HeaderView::HeaderView(views::Widget* frame)
207 : frame_(frame), 193 : frame_(frame),
208 header_painter_(new ash::DefaultHeaderPainter), 194 header_painter_(new ash::DefaultHeaderPainter),
209 avatar_icon_(NULL), 195 avatar_icon_(NULL),
210 caption_button_container_(NULL), 196 caption_button_container_(NULL),
211 maximize_bubble_(NULL),
212 fullscreen_visible_fraction_(0) { 197 fullscreen_visible_fraction_(0) {
213 // Unfortunately, there is no views::WidgetDelegate::CanMinimize(). Assume 198 // Unfortunately, there is no views::WidgetDelegate::CanMinimize(). Assume
214 // that the window frame can be minimized if it can be maximized. 199 // that the window frame can be minimized if it can be maximized.
215 FrameCaptionButtonContainerView::MinimizeAllowed minimize_allowed = 200 FrameCaptionButtonContainerView::MinimizeAllowed minimize_allowed =
216 frame_->widget_delegate()->CanMaximize() ? 201 frame_->widget_delegate()->CanMaximize() ?
217 FrameCaptionButtonContainerView::MINIMIZE_ALLOWED : 202 FrameCaptionButtonContainerView::MINIMIZE_ALLOWED :
218 FrameCaptionButtonContainerView::MINIMIZE_DISALLOWED; 203 FrameCaptionButtonContainerView::MINIMIZE_DISALLOWED;
219 caption_button_container_ = new FrameCaptionButtonContainerView(frame_, 204 caption_button_container_ = new FrameCaptionButtonContainerView(frame_,
220 minimize_allowed); 205 minimize_allowed);
221 caption_button_container_->UpdateSizeButtonVisibility(Shell::GetInstance()-> 206 caption_button_container_->UpdateSizeButtonVisibility(Shell::GetInstance()->
222 IsMaximizeModeWindowManagerEnabled()); 207 IsMaximizeModeWindowManagerEnabled());
223 AddChildView(caption_button_container_); 208 AddChildView(caption_button_container_);
224 FrameMaximizeButton* frame_maximize_button =
225 caption_button_container_->GetOldStyleSizeButton();
226 if (frame_maximize_button)
227 frame_maximize_button->AddObserver(this);
228 209
229 header_painter_->Init(frame_, this, NULL, caption_button_container_); 210 header_painter_->Init(frame_, this, NULL, caption_button_container_);
230 UpdateAvatarIcon(); 211 UpdateAvatarIcon();
231 212
232 Shell::GetInstance()->AddShellObserver(this); 213 Shell::GetInstance()->AddShellObserver(this);
233 } 214 }
234 215
235 CustomFrameViewAsh::HeaderView::~HeaderView() { 216 CustomFrameViewAsh::HeaderView::~HeaderView() {
236 FrameMaximizeButton* frame_maximize_button =
237 caption_button_container_->GetOldStyleSizeButton();
238 if (frame_maximize_button)
239 frame_maximize_button->RemoveObserver(this);
240 Shell::GetInstance()->RemoveShellObserver(this); 217 Shell::GetInstance()->RemoveShellObserver(this);
241 } 218 }
242 219
243 void CustomFrameViewAsh::HeaderView::SchedulePaintForTitle() { 220 void CustomFrameViewAsh::HeaderView::SchedulePaintForTitle() {
244 header_painter_->SchedulePaintForTitle(); 221 header_painter_->SchedulePaintForTitle();
245 } 222 }
246 223
247 void CustomFrameViewAsh::HeaderView::ResetWindowControls() { 224 void CustomFrameViewAsh::HeaderView::ResetWindowControls() {
248 caption_button_container_->ResetWindowControls(); 225 caption_button_container_->ResetWindowControls();
249 } 226 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 331
355 std::vector<gfx::Rect> 332 std::vector<gfx::Rect>
356 CustomFrameViewAsh::HeaderView::GetVisibleBoundsInScreen() const { 333 CustomFrameViewAsh::HeaderView::GetVisibleBoundsInScreen() const {
357 // TODO(pkotwicz): Implement views::View::ConvertRectToScreen(). 334 // TODO(pkotwicz): Implement views::View::ConvertRectToScreen().
358 gfx::Rect visible_bounds(GetVisibleBounds()); 335 gfx::Rect visible_bounds(GetVisibleBounds());
359 gfx::Point visible_origin_in_screen(visible_bounds.origin()); 336 gfx::Point visible_origin_in_screen(visible_bounds.origin());
360 views::View::ConvertPointToScreen(this, &visible_origin_in_screen); 337 views::View::ConvertPointToScreen(this, &visible_origin_in_screen);
361 std::vector<gfx::Rect> bounds_in_screen; 338 std::vector<gfx::Rect> bounds_in_screen;
362 bounds_in_screen.push_back( 339 bounds_in_screen.push_back(
363 gfx::Rect(visible_origin_in_screen, visible_bounds.size())); 340 gfx::Rect(visible_origin_in_screen, visible_bounds.size()));
364 if (maximize_bubble_lifetime_observer_.get() &&
365 maximize_bubble_lifetime_observer_->IsWidgetAlive()) {
366 bounds_in_screen.push_back(maximize_bubble_->GetWindowBoundsInScreen());
367 }
368 return bounds_in_screen; 341 return bounds_in_screen;
369 } 342 }
370 343
371 /////////////////////////////////////////////////////////////////////////////// 344 ///////////////////////////////////////////////////////////////////////////////
372 // CustomFrameViewAsh::HeaderView, FrameMaximizeButtonObserver overrides:
373
374 void CustomFrameViewAsh::HeaderView::OnMaximizeBubbleShown(
375 views::Widget* bubble) {
376 maximize_bubble_ = bubble;
377 maximize_bubble_lifetime_observer_.reset(
378 new views::WidgetDeletionObserver(bubble));
379 }
380
381 ///////////////////////////////////////////////////////////////////////////////
382 // CustomFrameViewAsh::OverlayView 345 // CustomFrameViewAsh::OverlayView
383 346
384 // View which takes up the entire widget and contains the HeaderView. HeaderView 347 // View which takes up the entire widget and contains the HeaderView. HeaderView
385 // is a child of OverlayView to avoid creating a larger texture than necessary 348 // is a child of OverlayView to avoid creating a larger texture than necessary
386 // when painting the HeaderView to its own layer. 349 // when painting the HeaderView to its own layer.
387 class CustomFrameViewAsh::OverlayView : public views::View { 350 class CustomFrameViewAsh::OverlayView : public views::View {
388 public: 351 public:
389 explicit OverlayView(HeaderView* header_view); 352 explicit OverlayView(HeaderView* header_view);
390 virtual ~OverlayView(); 353 virtual ~OverlayView();
391 354
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 FrameCaptionButtonContainerView* CustomFrameViewAsh:: 537 FrameCaptionButtonContainerView* CustomFrameViewAsh::
575 GetFrameCaptionButtonContainerViewForTest() { 538 GetFrameCaptionButtonContainerViewForTest() {
576 return header_view_->caption_button_container(); 539 return header_view_->caption_button_container();
577 } 540 }
578 541
579 int CustomFrameViewAsh::NonClientTopBorderHeight() const { 542 int CustomFrameViewAsh::NonClientTopBorderHeight() const {
580 return frame_->IsFullscreen() ? 0 : header_view_->GetPreferredHeight(); 543 return frame_->IsFullscreen() ? 0 : header_view_->GetPreferredHeight();
581 } 544 }
582 545
583 } // namespace ash 546 } // namespace ash
OLDNEW
« no previous file with comments | « ash/frame/caption_buttons/maximize_bubble_controller_bubble.cc ('k') | ash/metrics/user_metrics_recorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698