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

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: Update commit message 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 if (!display_manager->SetDisplayMode(display_id, mode)) { 494
495 if (mode->IsEquivalent(current_mode)) {
496 LOG(ERROR) << "New display mode matches current mode.";
497 return;
498 }
499
500 if (!ash::Shell::Get()
501 ->resolution_notification_controller()
502 ->PrepareNotificationAndSetDisplayMode(
503 display_id, current_mode, mode,
504 base::Bind(&chromeos::StoreDisplayPrefs))) {
495 LOG(ERROR) << "Unable to set display mode for: " << display_id 505 LOG(ERROR) << "Unable to set display mode for: " << display_id
496 << " Mode: " << *mode_data; 506 << " Mode: " << *mode_data;
497 return;
498 } 507 }
499 if (display::Display::IsInternalDisplayId(display_id))
500 return;
501 // For external displays, show a notification confirming the resolution
502 // change.
503 ash::Shell::Get()->resolution_notification_controller()->PrepareNotification(
504 display_id, current_mode, mode, base::Bind(&chromeos::StoreDisplayPrefs));
505 } 508 }
506 509
507 void DisplayOptionsHandler::HandleSetRotation(const base::ListValue* args) { 510 void DisplayOptionsHandler::HandleSetRotation(const base::ListValue* args) {
508 DCHECK(!args->empty()); 511 DCHECK(!args->empty());
509 512
510 int64_t display_id = GetDisplayIdFromArgs(args); 513 int64_t display_id = GetDisplayIdFromArgs(args);
511 if (display_id == display::kInvalidDisplayId) 514 if (display_id == display::kInvalidDisplayId)
512 return; 515 return;
513 516
514 int rotation_value = 0; 517 int rotation_value = 0;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 if (!args->GetBoolean(0, &enable)) 572 if (!args->GetBoolean(0, &enable))
570 NOTREACHED(); 573 NOTREACHED();
571 574
572 GetDisplayManager()->SetDefaultMultiDisplayModeForCurrentDisplays( 575 GetDisplayManager()->SetDefaultMultiDisplayModeForCurrentDisplays(
573 enable ? display::DisplayManager::UNIFIED 576 enable ? display::DisplayManager::UNIFIED
574 : display::DisplayManager::EXTENDED); 577 : display::DisplayManager::EXTENDED);
575 } 578 }
576 579
577 } // namespace options 580 } // namespace options
578 } // namespace chromeos 581 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/extensions/display_info_provider_chromeos.cc ('k') | ui/display/manager/display_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698