Chromium Code Reviews| Index: ash/display/resolution_notification_controller.cc |
| diff --git a/ash/display/resolution_notification_controller.cc b/ash/display/resolution_notification_controller.cc |
| index 315dd5ab5b65cb512ba195cf4f9c1d231443ac29..4ad8c62bd9920c4062ee3735291ec274c27b0c56 100644 |
| --- a/ash/display/resolution_notification_controller.cc |
| +++ b/ash/display/resolution_notification_controller.cc |
| @@ -5,6 +5,7 @@ |
| #include "ash/display/resolution_notification_controller.h" |
| #include "ash/display/display_controller.h" |
| +#include "ash/display/display_info.h" |
| #include "ash/display/display_manager.h" |
| #include "ash/shell.h" |
| #include "ash/system/system_notifier.h" |
| @@ -102,8 +103,8 @@ const char ResolutionNotificationController::kNotificationId[] = |
| struct ResolutionNotificationController::ResolutionChangeInfo { |
| ResolutionChangeInfo(int64 display_id, |
| - const gfx::Size& old_resolution, |
| - const gfx::Size& new_resolution, |
| + const ash::DisplayMode& old_resolution, |
| + const ash::DisplayMode& new_resolution, |
| const base::Closure& accept_callback); |
| ~ResolutionChangeInfo(); |
| @@ -111,14 +112,14 @@ struct ResolutionNotificationController::ResolutionChangeInfo { |
| int64 display_id; |
| // The resolution before the change. |
| - gfx::Size old_resolution; |
| + ash::DisplayMode old_resolution; |
|
oshima
2014/07/30 02:09:45
remove ash::
Jun Mukai
2014/07/30 02:18:31
Done.
|
| // The requested resolution. Note that this may be different from |
| // |current_resolution| which is the actual resolution set. |
| - gfx::Size new_resolution; |
| + ash::DisplayMode new_resolution; |
| // The actual resolution after the change. |
| - gfx::Size current_resolution; |
| + ash::DisplayMode current_resolution; |
| // The callback when accept is chosen. |
| base::Closure accept_callback; |
| @@ -137,8 +138,8 @@ struct ResolutionNotificationController::ResolutionChangeInfo { |
| ResolutionNotificationController::ResolutionChangeInfo::ResolutionChangeInfo( |
| int64 display_id, |
| - const gfx::Size& old_resolution, |
| - const gfx::Size& new_resolution, |
| + const ash::DisplayMode& old_resolution, |
| + const ash::DisplayMode& new_resolution, |
| const base::Closure& accept_callback) |
| : display_id(display_id), |
| old_resolution(old_resolution), |
| @@ -168,26 +169,26 @@ ResolutionNotificationController::~ResolutionNotificationController() { |
| void ResolutionNotificationController::SetDisplayResolutionAndNotify( |
| int64 display_id, |
| - const gfx::Size& old_resolution, |
| - const gfx::Size& new_resolution, |
| + const ash::DisplayMode& old_resolution, |
| + const ash::DisplayMode& new_resolution, |
| const base::Closure& accept_callback) { |
| // 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|. |
| - gfx::Size original_resolution; |
| + ash::DisplayMode original_resolution; |
| if (change_info_ && change_info_->display_id == display_id) { |
| - DCHECK(change_info_->new_resolution == old_resolution); |
| + DCHECK(change_info_->new_resolution.size == old_resolution.size); |
| original_resolution = change_info_->old_resolution; |
| } |
| change_info_.reset(new ResolutionChangeInfo( |
| display_id, old_resolution, new_resolution, accept_callback)); |
| - if (!original_resolution.IsEmpty()) |
| + if (!original_resolution.size.IsEmpty()) |
| change_info_->old_resolution = original_resolution; |
| - // SetDisplayResolution() causes OnConfigurationChanged() and the notification |
| + // SetDisplayMode() causes OnConfigurationChanged() and the notification |
| // will be shown at that point. |
| - Shell::GetInstance()->display_manager()->SetDisplayResolution( |
| + Shell::GetInstance()->display_manager()->SetDisplayMode( |
| display_id, new_resolution); |
| } |
| @@ -224,16 +225,17 @@ void ResolutionNotificationController::CreateOrUpdateNotification( |
| Shell::GetInstance()->display_manager()->GetDisplayNameForId( |
| change_info_->display_id)); |
| const base::string16 message = |
| - (change_info_->new_resolution == change_info_->current_resolution) ? |
| + (change_info_->new_resolution.size == |
| + change_info_->current_resolution.size) ? |
| l10n_util::GetStringFUTF16( |
| IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED, |
| display_name, |
| - base::UTF8ToUTF16(change_info_->new_resolution.ToString())) : |
| + base::UTF8ToUTF16(change_info_->new_resolution.size.ToString())) : |
| l10n_util::GetStringFUTF16( |
| IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED_TO_UNSUPPORTED, |
| display_name, |
| - base::UTF8ToUTF16(change_info_->new_resolution.ToString()), |
| - base::UTF8ToUTF16(change_info_->current_resolution.ToString())); |
| + base::UTF8ToUTF16(change_info_->new_resolution.size.ToString()), |
| + base::UTF8ToUTF16(change_info_->current_resolution.size.ToString())); |
| ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| scoped_ptr<Notification> notification(new Notification( |
| @@ -279,9 +281,9 @@ void ResolutionNotificationController::RevertResolutionChange() { |
| message_center::MessageCenter::Get()->RemoveNotification( |
| kNotificationId, false /* by_user */); |
| int64 display_id = change_info_->display_id; |
| - gfx::Size old_resolution = change_info_->old_resolution; |
| + ash::DisplayMode old_resolution = change_info_->old_resolution; |
| change_info_.reset(); |
| - Shell::GetInstance()->display_manager()->SetDisplayResolution( |
| + Shell::GetInstance()->display_manager()->SetDisplayMode( |
| display_id, old_resolution); |
| } |
| @@ -303,9 +305,13 @@ void ResolutionNotificationController::OnDisplayConfigurationChanged() { |
| if (!change_info_) |
| return; |
| - const DisplayInfo& info = Shell::GetInstance()->display_manager()-> |
| - GetDisplayInfo(change_info_->display_id); |
| - change_info_->current_resolution = info.bounds_in_native().size(); |
| + DisplayMode mode; |
| + if (!Shell::GetInstance()->display_manager()->GetSelectedModeForDisplayId( |
| + change_info_->display_id, &mode)) { |
| + return; |
| + } |
| + |
| + change_info_->current_resolution = mode; |
| CreateOrUpdateNotification(true); |
| if (g_use_timer && change_info_->timeout_count > 0) { |
| change_info_->timer.Start(FROM_HERE, |