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

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

Issue 2739763003: Moves maintaining ShellObservers back to Shell (Closed)
Patch Set: merge Created 3 years, 9 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/common/system/web_notification/ash_popup_alignment_delegate.h" 5 #include "ash/common/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/wm_shelf.h" 8 #include "ash/common/shelf/wm_shelf.h"
9 #include "ash/common/wm_shell.h"
10 #include "ash/common/wm_window.h" 9 #include "ash/common/wm_window.h"
11 #include "ash/public/cpp/shelf_types.h" 10 #include "ash/public/cpp/shelf_types.h"
12 #include "ash/public/cpp/shell_window_ids.h" 11 #include "ash/public/cpp/shell_window_ids.h"
13 #include "ash/root_window_controller.h" 12 #include "ash/root_window_controller.h"
13 #include "ash/shell.h"
14 #include "base/i18n/rtl.h" 14 #include "base/i18n/rtl.h"
15 #include "ui/display/display.h" 15 #include "ui/display/display.h"
16 #include "ui/display/screen.h" 16 #include "ui/display/screen.h"
17 #include "ui/gfx/geometry/rect.h" 17 #include "ui/gfx/geometry/rect.h"
18 #include "ui/message_center/message_center_style.h" 18 #include "ui/message_center/message_center_style.h"
19 #include "ui/message_center/views/message_popup_collection.h" 19 #include "ui/message_center/views/message_popup_collection.h"
20 #include "ui/wm/core/shadow_types.h" 20 #include "ui/wm/core/shadow_types.h"
21 21
22 namespace ash { 22 namespace ash {
23 23
24 namespace { 24 namespace {
25 25
26 const int kToastMarginX = 7; 26 const int kToastMarginX = 7;
27 27
28 // If there should be no margin for the first item, this value needs to be 28 // 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 + 29 // substracted to flush the message to the shelf (the width of the border +
30 // shadow). 30 // shadow).
31 const int kNoToastMarginBorderAndShadowOffset = 2; 31 const int kNoToastMarginBorderAndShadowOffset = 2;
32 32
33 } // namespace 33 } // namespace
34 34
35 AshPopupAlignmentDelegate::AshPopupAlignmentDelegate(WmShelf* shelf) 35 AshPopupAlignmentDelegate::AshPopupAlignmentDelegate(WmShelf* shelf)
36 : screen_(NULL), shelf_(shelf), tray_bubble_height_(0) { 36 : screen_(NULL), shelf_(shelf), tray_bubble_height_(0) {
37 shelf_->AddObserver(this); 37 shelf_->AddObserver(this);
38 } 38 }
39 39
40 AshPopupAlignmentDelegate::~AshPopupAlignmentDelegate() { 40 AshPopupAlignmentDelegate::~AshPopupAlignmentDelegate() {
41 if (screen_) 41 if (screen_)
42 screen_->RemoveObserver(this); 42 screen_->RemoveObserver(this);
43 WmShell::Get()->RemoveShellObserver(this); 43 Shell::GetInstance()->RemoveShellObserver(this);
44 shelf_->RemoveObserver(this); 44 shelf_->RemoveObserver(this);
45 } 45 }
46 46
47 void AshPopupAlignmentDelegate::StartObserving( 47 void AshPopupAlignmentDelegate::StartObserving(
48 display::Screen* screen, 48 display::Screen* screen,
49 const display::Display& display) { 49 const display::Display& display) {
50 screen_ = screen; 50 screen_ = screen;
51 work_area_ = display.work_area(); 51 work_area_ = display.work_area();
52 screen->AddObserver(this); 52 screen->AddObserver(this);
53 WmShell::Get()->AddShellObserver(this); 53 Shell::GetInstance()->AddShellObserver(this);
54 if (tray_bubble_height_ > 0) 54 if (tray_bubble_height_ > 0)
55 UpdateWorkArea(); 55 UpdateWorkArea();
56 } 56 }
57 57
58 void AshPopupAlignmentDelegate::SetTrayBubbleHeight(int height) { 58 void AshPopupAlignmentDelegate::SetTrayBubbleHeight(int height) {
59 tray_bubble_height_ = height; 59 tray_bubble_height_ = height;
60 60
61 // If the shelf is shown during auto-hide state, the distance from the edge 61 // 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. 62 // should be reduced by the height of shelf's shown height.
63 if (shelf_->GetVisibilityState() == SHELF_AUTO_HIDE && 63 if (shelf_->GetVisibilityState() == SHELF_AUTO_HIDE &&
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 const display::Display& old_display) {} 159 const display::Display& old_display) {}
160 160
161 void AshPopupAlignmentDelegate::OnDisplayMetricsChanged( 161 void AshPopupAlignmentDelegate::OnDisplayMetricsChanged(
162 const display::Display& display, 162 const display::Display& display,
163 uint32_t metrics) { 163 uint32_t metrics) {
164 if (GetCurrentDisplay().id() == display.id()) 164 if (GetCurrentDisplay().id() == display.id())
165 UpdateWorkArea(); 165 UpdateWorkArea();
166 } 166 }
167 167
168 } // namespace ash 168 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/overview/overview_button_tray.cc ('k') | ash/common/test/test_shelf_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698