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

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

Issue 441013003: Move the logic of getting root window to StartObserving() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/shelf/shelf_constants.h" 8 #include "ash/shelf/shelf_constants.h"
9 #include "ash/shelf/shelf_layout_manager.h" 9 #include "ash/shelf/shelf_layout_manager.h"
10 #include "ash/shelf/shelf_types.h" 10 #include "ash/shelf/shelf_types.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 screen_->RemoveObserver(this); 44 screen_->RemoveObserver(this);
45 Shell::GetInstance()->RemoveShellObserver(this); 45 Shell::GetInstance()->RemoveShellObserver(this);
46 if (shelf_) 46 if (shelf_)
47 shelf_->RemoveObserver(this); 47 shelf_->RemoveObserver(this);
48 } 48 }
49 49
50 void AshPopupAlignmentDelegate::StartObserving(gfx::Screen* screen, 50 void AshPopupAlignmentDelegate::StartObserving(gfx::Screen* screen,
51 const gfx::Display& display) { 51 const gfx::Display& display) {
52 screen_ = screen; 52 screen_ = screen;
53 display_id_ = display.id(); 53 display_id_ = display.id();
54 root_window_ = ash::Shell::GetInstance()->display_controller()->
55 GetRootWindowForDisplayId(display_id_);
54 UpdateShelf(); 56 UpdateShelf();
55 screen->AddObserver(this); 57 screen->AddObserver(this);
56 Shell::GetInstance()->AddShellObserver(this); 58 Shell::GetInstance()->AddShellObserver(this);
57 if (system_tray_height_ > 0) 59 if (system_tray_height_ > 0)
58 OnAutoHideStateChanged(shelf_->auto_hide_state()); 60 OnAutoHideStateChanged(shelf_->auto_hide_state());
59 } 61 }
60 62
61 void AshPopupAlignmentDelegate::SetSystemTrayHeight(int height) { 63 void AshPopupAlignmentDelegate::SetSystemTrayHeight(int height) {
62 system_tray_height_ = height; 64 system_tray_height_ = height;
63 65
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 } 119 }
118 120
119 ShelfAlignment AshPopupAlignmentDelegate::GetAlignment() const { 121 ShelfAlignment AshPopupAlignmentDelegate::GetAlignment() const {
120 return shelf_ ? shelf_->GetAlignment() : SHELF_ALIGNMENT_BOTTOM; 122 return shelf_ ? shelf_->GetAlignment() : SHELF_ALIGNMENT_BOTTOM;
121 } 123 }
122 124
123 void AshPopupAlignmentDelegate::UpdateShelf() { 125 void AshPopupAlignmentDelegate::UpdateShelf() {
124 if (shelf_) 126 if (shelf_)
125 return; 127 return;
126 128
127 aura::Window* root_window = ash::Shell::GetInstance()->display_controller()-> 129 shelf_ = ShelfLayoutManager::ForShelf(root_window_);
128 GetRootWindowForDisplayId(display_id_);
129 shelf_ = ShelfLayoutManager::ForShelf(root_window);
130 if (shelf_) 130 if (shelf_)
131 shelf_->AddObserver(this); 131 shelf_->AddObserver(this);
132 } 132 }
133 133
134 void AshPopupAlignmentDelegate::OnDisplayWorkAreaInsetsChanged() { 134 void AshPopupAlignmentDelegate::OnDisplayWorkAreaInsetsChanged() {
135 UpdateShelf(); 135 UpdateShelf();
136 136
137 work_area_ = Shell::GetScreen()->GetDisplayNearestWindow( 137 work_area_ = Shell::GetScreen()->GetDisplayNearestWindow(
138 shelf_->shelf_widget()->GetNativeView()).work_area(); 138 shelf_->shelf_widget()->GetNativeView()).work_area();
139 } 139 }
(...skipping 27 matching lines...) Expand all
167 } 167 }
168 168
169 void AshPopupAlignmentDelegate::OnDisplayMetricsChanged( 169 void AshPopupAlignmentDelegate::OnDisplayMetricsChanged(
170 const gfx::Display& display, 170 const gfx::Display& display,
171 uint32_t metrics) { 171 uint32_t metrics) {
172 if (display.id() == display_id_ && shelf_) 172 if (display.id() == display_id_ && shelf_)
173 OnAutoHideStateChanged(shelf_->auto_hide_state()); 173 OnAutoHideStateChanged(shelf_->auto_hide_state());
174 } 174 }
175 175
176 } // namespace ash 176 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698