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

Unified Diff: ash/display/resolution_notification_controller.cc

Issue 2799963003: Fix errors in display resolution change notifications (Closed)
Patch Set: Fix compile errors on non-cros systems Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: ash/display/resolution_notification_controller.cc
diff --git a/ash/display/resolution_notification_controller.cc b/ash/display/resolution_notification_controller.cc
index f4fcece9738c56ee89891ed8781304d1760548b0..d4bc6ef67def514710b7586d22fa2ecbcedbab90 100644
--- a/ash/display/resolution_notification_controller.cc
+++ b/ash/display/resolution_notification_controller.cc
@@ -162,7 +162,7 @@ ResolutionNotificationController::~ResolutionNotificationController() {
display::Screen::GetScreen()->RemoveObserver(this);
}
-void ResolutionNotificationController::PrepareNotification(
+bool ResolutionNotificationController::PrepareNotificationAndSetDisplayMode(
int64_t display_id,
const scoped_refptr<display::ManagedDisplayMode>& old_resolution,
const scoped_refptr<display::ManagedDisplayMode>& new_resolution,
@@ -170,7 +170,14 @@ void ResolutionNotificationController::PrepareNotification(
DCHECK(old_resolution);
DCHECK(new_resolution);
- DCHECK(!display::Display::IsInternalDisplayId(display_id));
+ display::DisplayManager* const display_manager =
+ Shell::Get()->display_manager();
+ if (display::Display::IsInternalDisplayId(display_id)) {
+ // We don't show notifications to confirm/revert the resolution change in
+ // the case of an internal display.
+ return display_manager->SetDisplayMode(display_id, new_resolution);
+ }
+
// If multiple resolution changes are invoked for the same display,
// the original resolution for the first resolution change has to be used
// instead of the specified |old_resolution|.
@@ -184,6 +191,15 @@ void ResolutionNotificationController::PrepareNotification(
new_resolution, accept_callback));
if (original_resolution && !original_resolution->size().IsEmpty())
change_info_->old_resolution = original_resolution;
+
+ if (!display_manager->SetDisplayMode(display_id, new_resolution)) {
+ // Discard the prepared notification data since we failed to set the new
+ // resolution.
+ change_info_.reset();
+ return false;
+ }
+
+ return true;
}
bool ResolutionNotificationController::DoesNotificationTimeout() {
@@ -288,8 +304,10 @@ void ResolutionNotificationController::OnDisplayAdded(
void ResolutionNotificationController::OnDisplayRemoved(
const display::Display& old_display) {
- if (change_info_ && change_info_->display_id == old_display.id())
- RevertResolutionChange();
+ if (change_info_ && change_info_->display_id == old_display.id()) {
+ message_center::MessageCenter::Get()->RemoveNotification(
+ kNotificationId, false /* by_user */);
+ }
}
void ResolutionNotificationController::OnDisplayMetricsChanged(

Powered by Google App Engine
This is Rietveld 408576698