Index: chrome/browser/ui/webui/options/chromeos/display_options_handler.cc |
diff --git a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc |
index 8714639ed058db0e3835ef992cb008ebbac1e389..d02c3b3b31032cdb174297b7aa27f98d68620f25 100644 |
--- a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc |
+++ b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc |
@@ -9,6 +9,7 @@ |
#include "ash/display/display_controller.h" |
#include "ash/display/display_manager.h" |
#include "ash/display/output_configurator_animation.h" |
+#include "ash/display/resolution_notification_controller.h" |
#include "ash/screen_ash.h" |
#include "ash/shell.h" |
#include "base/bind.h" |
@@ -344,9 +345,34 @@ void DisplayOptionsHandler::HandleSetResolution(const base::ListValue* args) { |
return; |
} |
- // TODO(mukai): creates a confirmation dialog. |
- GetDisplayManager()->SetDisplayResolution( |
- display_id, gfx::ToFlooredSize(gfx::SizeF(width, height))); |
+ const ash::internal::DisplayInfo& display_info = |
+ GetDisplayManager()->GetDisplayInfo(display_id); |
+ gfx::Size new_resolution = gfx::ToFlooredSize(gfx::SizeF(width, height)); |
+ gfx::Size old_resolution = display_info.size_in_pixel(); |
+ bool has_new_resolution = false; |
+ bool has_old_resolution = false; |
+ for (size_t i = 0; i < display_info.resolutions().size(); ++i) { |
+ ash::internal::Resolution resolution = display_info.resolutions()[i]; |
+ if (resolution.size == new_resolution) |
+ has_new_resolution = true; |
+ if (resolution.size == old_resolution) |
+ has_old_resolution = true; |
+ } |
+ if (!has_new_resolution) { |
+ LOG(ERROR) << "No new resolution " << new_resolution.ToString() |
+ << " is found in the display info " << display_info.ToString(); |
+ return; |
+ } |
+ if (!has_old_resolution) { |
+ LOG(ERROR) << "No old resolution " << old_resolution.ToString() |
+ << " is found in the display info " << display_info.ToString(); |
+ return; |
+ } |
+ |
+ ash::Shell::GetInstance()->resolution_notification_controller()-> |
+ SetDisplayResolutionAndNotify( |
+ display_id, old_resolution, new_resolution, |
+ base::Bind(&StoreDisplayPrefs)); |
} |
void DisplayOptionsHandler::HandleSetOrientation(const base::ListValue* args) { |