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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/display_options_handler.cc

Issue 2799963003: Fix errors in display resolution change notifications (Closed)
Patch Set: 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 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 "chrome/browser/ui/webui/options/chromeos/display_options_handler.h" 5 #include "chrome/browser/ui/webui/options/chromeos/display_options_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 484
485 scoped_refptr<display::ManagedDisplayMode> mode = 485 scoped_refptr<display::ManagedDisplayMode> mode =
486 ConvertValueToManagedDisplayMode(mode_data); 486 ConvertValueToManagedDisplayMode(mode_data);
487 if (!mode) 487 if (!mode)
488 return; 488 return;
489 489
490 base::RecordAction(base::UserMetricsAction("Options_DisplaySetResolution")); 490 base::RecordAction(base::UserMetricsAction("Options_DisplaySetResolution"));
491 display::DisplayManager* display_manager = GetDisplayManager(); 491 display::DisplayManager* display_manager = GetDisplayManager();
492 scoped_refptr<display::ManagedDisplayMode> current_mode = 492 scoped_refptr<display::ManagedDisplayMode> current_mode =
493 display_manager->GetActiveModeForDisplayId(display_id); 493 display_manager->GetActiveModeForDisplayId(display_id);
494
495 if (mode->IsEquivalent(current_mode)) {
496 LOG(ERROR) << "New display mode matches current mode.";
497 return;
498 }
499
500 // We must prepare the notification before we set the mode, since setting
501 // the mode actually shows the notification, so it should be ready by then.
502 // crbug.com/701389.
503 if (display::Display::IsInternalDisplayId(display_id)) {
504 // For external displays, show a notification confirming the resolution
505 // change.
506 ash::Shell::GetInstance()
507 ->resolution_notification_controller()
508 ->PrepareNotification(display_id, current_mode, mode,
509 base::Bind(&chromeos::StoreDisplayPrefs));
510 }
511
494 if (!display_manager->SetDisplayMode(display_id, mode)) { 512 if (!display_manager->SetDisplayMode(display_id, mode)) {
495 LOG(ERROR) << "Unable to set display mode for: " << display_id 513 LOG(ERROR) << "Unable to set display mode for: " << display_id
496 << " Mode: " << *mode_data; 514 << " Mode: " << *mode_data;
497 return;
498 } 515 }
499 if (display::Display::IsInternalDisplayId(display_id))
500 return;
501 // For external displays, show a notification confirming the resolution
502 // change.
503 ash::Shell::GetInstance()
504 ->resolution_notification_controller()
505 ->PrepareNotification(display_id, current_mode, mode,
506 base::Bind(&chromeos::StoreDisplayPrefs));
507 } 516 }
508 517
509 void DisplayOptionsHandler::HandleSetRotation(const base::ListValue* args) { 518 void DisplayOptionsHandler::HandleSetRotation(const base::ListValue* args) {
510 DCHECK(!args->empty()); 519 DCHECK(!args->empty());
511 520
512 int64_t display_id = GetDisplayIdFromArgs(args); 521 int64_t display_id = GetDisplayIdFromArgs(args);
513 if (display_id == display::kInvalidDisplayId) 522 if (display_id == display::kInvalidDisplayId)
514 return; 523 return;
515 524
516 int rotation_value = 0; 525 int rotation_value = 0;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 if (!args->GetBoolean(0, &enable)) 580 if (!args->GetBoolean(0, &enable))
572 NOTREACHED(); 581 NOTREACHED();
573 582
574 GetDisplayManager()->SetDefaultMultiDisplayModeForCurrentDisplays( 583 GetDisplayManager()->SetDefaultMultiDisplayModeForCurrentDisplays(
575 enable ? display::DisplayManager::UNIFIED 584 enable ? display::DisplayManager::UNIFIED
576 : display::DisplayManager::EXTENDED); 585 : display::DisplayManager::EXTENDED);
577 } 586 }
578 587
579 } // namespace options 588 } // namespace options
580 } // namespace chromeos 589 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698