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

Side by Side Diff: ash/system/chromeos/screen_layout_observer.cc

Issue 2400553002: ash: Remove broken display notification suppression when settings is open (Closed)
Patch Set: fix tests Created 4 years, 2 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 (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/system/chromeos/screen_layout_observer.h" 5 #include "ash/system/chromeos/screen_layout_observer.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 19 matching lines...) Expand all
30 #include "ui/display/display.h" 30 #include "ui/display/display.h"
31 #include "ui/message_center/message_center.h" 31 #include "ui/message_center/message_center.h"
32 #include "ui/message_center/notification.h" 32 #include "ui/message_center/notification.h"
33 #include "ui/message_center/notification_delegate.h" 33 #include "ui/message_center/notification_delegate.h"
34 34
35 using message_center::Notification; 35 using message_center::Notification;
36 36
37 namespace ash { 37 namespace ash {
38 namespace { 38 namespace {
39 39
40 bool g_suppress_notifications_for_testing = false;
41
40 DisplayManager* GetDisplayManager() { 42 DisplayManager* GetDisplayManager() {
41 return Shell::GetInstance()->display_manager(); 43 return Shell::GetInstance()->display_manager();
42 } 44 }
43 45
44 base::string16 GetDisplayName(int64_t display_id) { 46 base::string16 GetDisplayName(int64_t display_id) {
45 return base::UTF8ToUTF16( 47 return base::UTF8ToUTF16(
46 GetDisplayManager()->GetDisplayNameForId(display_id)); 48 GetDisplayManager()->GetDisplayNameForId(display_id));
47 } 49 }
48 50
49 base::string16 GetDisplaySize(int64_t display_id) { 51 base::string16 GetDisplaySize(int64_t display_id) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 184
183 ScreenLayoutObserver::ScreenLayoutObserver() { 185 ScreenLayoutObserver::ScreenLayoutObserver() {
184 WmShell::Get()->AddDisplayObserver(this); 186 WmShell::Get()->AddDisplayObserver(this);
185 UpdateDisplayInfo(NULL); 187 UpdateDisplayInfo(NULL);
186 } 188 }
187 189
188 ScreenLayoutObserver::~ScreenLayoutObserver() { 190 ScreenLayoutObserver::~ScreenLayoutObserver() {
189 WmShell::Get()->RemoveDisplayObserver(this); 191 WmShell::Get()->RemoveDisplayObserver(this);
190 } 192 }
191 193
194 void ScreenLayoutObserver::SuppressNotificationsForTesting(bool suppress) {
195 g_suppress_notifications_for_testing = suppress;
196 }
197
192 void ScreenLayoutObserver::UpdateDisplayInfo( 198 void ScreenLayoutObserver::UpdateDisplayInfo(
193 ScreenLayoutObserver::DisplayInfoMap* old_info) { 199 ScreenLayoutObserver::DisplayInfoMap* old_info) {
194 if (old_info) 200 if (old_info)
195 old_info->swap(display_info_); 201 old_info->swap(display_info_);
196 display_info_.clear(); 202 display_info_.clear();
197 203
198 DisplayManager* display_manager = GetDisplayManager(); 204 DisplayManager* display_manager = GetDisplayManager();
199 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { 205 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) {
200 int64_t id = display_manager->GetDisplayAt(i).id(); 206 int64_t id = display_manager->GetDisplayAt(i).id();
201 display_info_[id] = display_manager->GetDisplayInfo(id); 207 display_info_[id] = display_manager->GetDisplayInfo(id);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 WmShell::Get()->RecordUserMetricsAction( 299 WmShell::Get()->RecordUserMetricsAction(
294 UMA_STATUS_AREA_DISPLAY_NOTIFICATION_CREATED); 300 UMA_STATUS_AREA_DISPLAY_NOTIFICATION_CREATED);
295 message_center::MessageCenter::Get()->AddNotification( 301 message_center::MessageCenter::Get()->AddNotification(
296 std::move(notification)); 302 std::move(notification));
297 } 303 }
298 304
299 void ScreenLayoutObserver::OnDisplayConfigurationChanged() { 305 void ScreenLayoutObserver::OnDisplayConfigurationChanged() {
300 DisplayInfoMap old_info; 306 DisplayInfoMap old_info;
301 UpdateDisplayInfo(&old_info); 307 UpdateDisplayInfo(&old_info);
302 308
303 if (!WmShell::Get() 309 if (g_suppress_notifications_for_testing)
304 ->system_tray_delegate()
305 ->ShouldShowDisplayNotification()) {
306 return; 310 return;
307 }
308 311
309 base::string16 message; 312 base::string16 message;
310 base::string16 additional_message; 313 base::string16 additional_message;
311 if (GetDisplayMessageForNotification(old_info, &message, &additional_message)) 314 if (GetDisplayMessageForNotification(old_info, &message, &additional_message))
312 CreateOrUpdateNotification(message, additional_message); 315 CreateOrUpdateNotification(message, additional_message);
313 } 316 }
314 317
315 } // namespace ash 318 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698