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

Side by Side Diff: ash/system/web_notification/ash_popup_alignment_delegate.cc

Issue 2029323002: mash: Convert AshPopupAlignmentDelegate to wm common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 6 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
OLDNEW
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 "ash/system/web_notification/ash_popup_alignment_delegate.h" 5 #include "ash/system/web_notification/ash_popup_alignment_delegate.h"
6 6
7 #include "ash/common/shelf/shelf_constants.h" 7 #include "ash/common/shelf/shelf_constants.h"
8 #include "ash/common/shelf/shelf_types.h" 8 #include "ash/common/shelf/shelf_types.h"
9 #include "ash/common/wm_lookup.h" 9 #include "ash/common/shelf/wm_shelf.h"
10 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
11 #include "ash/common/wm_window.h" 11 #include "ash/common/wm_window.h"
12 #include "ash/display/window_tree_host_manager.h"
13 #include "ash/shelf/shelf_layout_manager.h"
14 #include "ash/shelf/shelf_widget.h"
15 #include "base/i18n/rtl.h" 12 #include "base/i18n/rtl.h"
16 #include "ui/display/display.h" 13 #include "ui/display/display.h"
17 #include "ui/display/screen.h" 14 #include "ui/display/screen.h"
18 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
19 #include "ui/message_center/message_center_style.h" 16 #include "ui/message_center/message_center_style.h"
20 #include "ui/message_center/views/message_popup_collection.h" 17 #include "ui/message_center/views/message_popup_collection.h"
21 18
22 namespace ash { 19 namespace ash {
23 20
24 namespace { 21 namespace {
25 22
26 const int kToastMarginX = 3; 23 const int kToastMarginX = 3;
27 24
28 // If there should be no margin for the first item, this value needs to be 25 // If there should be no margin for the first item, this value needs to be
29 // substracted to flush the message to the shelf (the width of the border + 26 // substracted to flush the message to the shelf (the width of the border +
30 // shadow). 27 // shadow).
31 const int kNoToastMarginBorderAndShadowOffset = 2; 28 const int kNoToastMarginBorderAndShadowOffset = 2;
32 29
33 } 30 } // namespace
34 31
35 AshPopupAlignmentDelegate::AshPopupAlignmentDelegate(ShelfLayoutManager* shelf) 32 AshPopupAlignmentDelegate::AshPopupAlignmentDelegate(WmShelf* shelf)
36 : screen_(NULL), shelf_(shelf), system_tray_height_(0) { 33 : screen_(NULL), shelf_(shelf), system_tray_height_(0) {
37 shelf_->AddObserver(this); 34 shelf_->AddObserver(this);
38 } 35 }
39 36
40 AshPopupAlignmentDelegate::~AshPopupAlignmentDelegate() { 37 AshPopupAlignmentDelegate::~AshPopupAlignmentDelegate() {
41 if (screen_) 38 if (screen_)
42 screen_->RemoveObserver(this); 39 screen_->RemoveObserver(this);
43 WmShell::Get()->RemoveShellObserver(this); 40 WmShell::Get()->RemoveShellObserver(this);
44 shelf_->RemoveObserver(this); 41 shelf_->RemoveObserver(this);
45 } 42 }
46 43
47 void AshPopupAlignmentDelegate::StartObserving( 44 void AshPopupAlignmentDelegate::StartObserving(
48 display::Screen* screen, 45 display::Screen* screen,
49 const display::Display& display) { 46 const display::Display& display) {
50 screen_ = screen; 47 screen_ = screen;
51 work_area_ = display.work_area(); 48 work_area_ = display.work_area();
52 screen->AddObserver(this); 49 screen->AddObserver(this);
53 WmShell::Get()->AddShellObserver(this); 50 WmShell::Get()->AddShellObserver(this);
54 if (system_tray_height_ > 0) 51 if (system_tray_height_ > 0)
55 UpdateWorkArea(); 52 UpdateWorkArea();
56 } 53 }
57 54
58 void AshPopupAlignmentDelegate::SetSystemTrayHeight(int height) { 55 void AshPopupAlignmentDelegate::SetSystemTrayHeight(int height) {
59 system_tray_height_ = height; 56 system_tray_height_ = height;
60 57
61 // If the shelf is shown during auto-hide state, the distance from the edge 58 // If the shelf is shown during auto-hide state, the distance from the edge
62 // should be reduced by the height of shelf's shown height. 59 // should be reduced by the height of shelf's shown height.
63 if (shelf_->visibility_state() == SHELF_AUTO_HIDE && 60 if (shelf_->GetVisibilityState() == SHELF_AUTO_HIDE &&
64 shelf_->auto_hide_state() == SHELF_AUTO_HIDE_SHOWN) { 61 shelf_->GetAutoHideState() == SHELF_AUTO_HIDE_SHOWN) {
65 system_tray_height_ -= GetShelfConstant(SHELF_SIZE) - kShelfAutoHideSize; 62 system_tray_height_ -= GetShelfConstant(SHELF_SIZE) - kShelfAutoHideSize;
66 } 63 }
67 64
68 if (system_tray_height_ > 0) 65 if (system_tray_height_ > 0)
69 system_tray_height_ += message_center::kMarginBetweenItems; 66 system_tray_height_ += message_center::kMarginBetweenItems;
70 else 67 else
71 system_tray_height_ = 0; 68 system_tray_height_ = 0;
72 69
73 DoUpdateIfPossible(); 70 DoUpdateIfPossible();
74 } 71 }
(...skipping 30 matching lines...) Expand all
105 void AshPopupAlignmentDelegate::RecomputeAlignment( 102 void AshPopupAlignmentDelegate::RecomputeAlignment(
106 const display::Display& display) { 103 const display::Display& display) {
107 // Nothing needs to be done. 104 // Nothing needs to be done.
108 } 105 }
109 106
110 ShelfAlignment AshPopupAlignmentDelegate::GetAlignment() const { 107 ShelfAlignment AshPopupAlignmentDelegate::GetAlignment() const {
111 return shelf_->GetAlignment(); 108 return shelf_->GetAlignment();
112 } 109 }
113 110
114 display::Display AshPopupAlignmentDelegate::GetCurrentDisplay() const { 111 display::Display AshPopupAlignmentDelegate::GetCurrentDisplay() const {
115 return WmLookup::Get() 112 return shelf_->GetWindow()->GetDisplayNearestWindow();
116 ->GetWindowForWidget(shelf_->shelf_widget())
117 ->GetDisplayNearestWindow();
118 } 113 }
119 114
120 void AshPopupAlignmentDelegate::UpdateWorkArea() { 115 void AshPopupAlignmentDelegate::UpdateWorkArea() {
121 work_area_ = shelf_->user_work_area_bounds(); 116 work_area_ = shelf_->GetUserWorkAreaBounds();
122 DoUpdateIfPossible(); 117 DoUpdateIfPossible();
123 } 118 }
124 119
120 ///////////////////////////////////////////////////////////////////////////////
121 // ShellObserver:
122
125 void AshPopupAlignmentDelegate::OnDisplayWorkAreaInsetsChanged() { 123 void AshPopupAlignmentDelegate::OnDisplayWorkAreaInsetsChanged() {
126 UpdateWorkArea(); 124 UpdateWorkArea();
127 } 125 }
128 126
127 ///////////////////////////////////////////////////////////////////////////////
128 // WmShelfObserver:
129
129 void AshPopupAlignmentDelegate::WillChangeVisibilityState( 130 void AshPopupAlignmentDelegate::WillChangeVisibilityState(
130 ShelfVisibilityState new_state) { 131 ShelfVisibilityState new_state) {
131 UpdateWorkArea(); 132 UpdateWorkArea();
132 } 133 }
133 134
134 void AshPopupAlignmentDelegate::OnAutoHideStateChanged( 135 void AshPopupAlignmentDelegate::OnAutoHideStateChanged(
135 ShelfAutoHideState new_state) { 136 ShelfAutoHideState new_state) {
136 UpdateWorkArea(); 137 UpdateWorkArea();
137 } 138 }
138 139
140 ///////////////////////////////////////////////////////////////////////////////
141 // display::DisplayObserver:
142
139 void AshPopupAlignmentDelegate::OnDisplayAdded( 143 void AshPopupAlignmentDelegate::OnDisplayAdded(
140 const display::Display& new_display) {} 144 const display::Display& new_display) {}
141 145
142 void AshPopupAlignmentDelegate::OnDisplayRemoved( 146 void AshPopupAlignmentDelegate::OnDisplayRemoved(
143 const display::Display& old_display) {} 147 const display::Display& old_display) {}
144 148
145 void AshPopupAlignmentDelegate::OnDisplayMetricsChanged( 149 void AshPopupAlignmentDelegate::OnDisplayMetricsChanged(
146 const display::Display& display, 150 const display::Display& display,
147 uint32_t metrics) { 151 uint32_t metrics) {
148 if (GetCurrentDisplay().id() == display.id()) 152 if (GetCurrentDisplay().id() == display.id())
149 UpdateWorkArea(); 153 UpdateWorkArea();
150 } 154 }
151 155
152 } // namespace ash 156 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698