Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/accelerators/accelerator_commands_aura.h" | 5 #include "ash/accelerators/accelerator_commands_aura.h" |
| 6 | 6 |
| 7 #include "ash/common/display/display_info.h" | |
| 7 #include "ash/common/wm/window_state.h" | 8 #include "ash/common/wm/window_state.h" |
| 8 #include "ash/common/wm_window.h" | 9 #include "ash/common/wm_window.h" |
| 9 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| 10 #include "ash/display/display_util.h" | 11 #include "ash/display/display_util.h" |
| 11 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 12 #include "ash/wm/screen_pinning_controller.h" | 13 #include "ash/wm/screen_pinning_controller.h" |
| 13 #include "base/metrics/user_metrics.h" | 14 #include "base/metrics/user_metrics.h" |
| 14 | 15 |
| 15 namespace ash { | 16 namespace ash { |
| 16 namespace accelerators { | 17 namespace accelerators { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 32 base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Up")); | 33 base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Up")); |
| 33 else | 34 else |
| 34 base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Down")); | 35 base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Down")); |
| 35 | 36 |
| 36 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 37 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 37 | 38 |
| 38 int64_t display_id = display_manager->IsInUnifiedMode() | 39 int64_t display_id = display_manager->IsInUnifiedMode() |
| 39 ? DisplayManager::kUnifiedDisplayId | 40 ? DisplayManager::kUnifiedDisplayId |
| 40 : display_manager->GetDisplayIdForUIScaling(); | 41 : display_manager->GetDisplayIdForUIScaling(); |
| 41 const DisplayInfo& display_info = display_manager->GetDisplayInfo(display_id); | 42 const DisplayInfo& display_info = display_manager->GetDisplayInfo(display_id); |
| 42 DisplayMode mode; | |
| 43 | 43 |
| 44 scoped_refptr<DisplayMode> mode; | |
| 44 if (display_manager->IsInUnifiedMode()) { | 45 if (display_manager->IsInUnifiedMode()) { |
| 45 if (!GetDisplayModeForNextResolution(display_info, up, &mode)) | 46 mode = GetDisplayModeForNextResolution(display_info, up); |
| 47 if (!mode) | |
| 46 return false; | 48 return false; |
|
oshima
2016/08/02 19:44:57
move this outside of if?
rjkroege
2016/08/04 00:12:04
Done.
| |
| 47 } else { | 49 } else { |
| 48 if (!GetDisplayModeForNextUIScale(display_info, up, &mode)) | 50 mode = GetDisplayModeForNextUIScale(display_info, up); |
| 51 if (!mode) | |
| 49 return false; | 52 return false; |
| 50 } | 53 } |
| 51 return display_manager->SetDisplayMode(display_id, mode); | 54 return display_manager->SetDisplayMode(display_id, mode); |
| 52 } | 55 } |
| 53 | 56 |
| 54 void ResetInternalDisplayZoom() { | 57 void ResetInternalDisplayZoom() { |
| 55 base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Reset")); | 58 base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Reset")); |
| 56 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 59 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 57 | 60 |
| 58 if (display_manager->IsInUnifiedMode()) { | 61 if (display_manager->IsInUnifiedMode()) { |
| 59 const DisplayInfo& display_info = | 62 const DisplayInfo& display_info = |
| 60 display_manager->GetDisplayInfo(DisplayManager::kUnifiedDisplayId); | 63 display_manager->GetDisplayInfo(DisplayManager::kUnifiedDisplayId); |
| 61 const std::vector<DisplayMode>& modes = display_info.display_modes(); | 64 const DisplayInfo::DisplayModeList& modes = display_info.display_modes(); |
| 62 auto iter = | 65 auto iter = std::find_if( |
| 63 std::find_if(modes.begin(), modes.end(), | 66 modes.begin(), modes.end(), |
| 64 [](const DisplayMode& mode) { return mode.native; }); | 67 [](const scoped_refptr<DisplayMode>& mode) { return mode->native(); }); |
| 65 display_manager->SetDisplayMode(DisplayManager::kUnifiedDisplayId, *iter); | 68 display_manager->SetDisplayMode(DisplayManager::kUnifiedDisplayId, *iter); |
| 66 } else { | 69 } else { |
| 67 SetDisplayUIScale(display_manager->GetDisplayIdForUIScaling(), 1.0f); | 70 SetDisplayUIScale(display_manager->GetDisplayIdForUIScaling(), 1.0f); |
| 68 } | 71 } |
| 69 } | 72 } |
| 70 | 73 |
| 71 void Unpin() { | 74 void Unpin() { |
| 72 WmWindow* pinned_window = | 75 WmWindow* pinned_window = |
| 73 Shell::GetInstance()->screen_pinning_controller()->pinned_window(); | 76 Shell::GetInstance()->screen_pinning_controller()->pinned_window(); |
| 74 if (pinned_window) | 77 if (pinned_window) |
| 75 pinned_window->GetWindowState()->Restore(); | 78 pinned_window->GetWindowState()->Restore(); |
| 76 } | 79 } |
| 77 | 80 |
| 78 } // namespace accelerators | 81 } // namespace accelerators |
| 79 } // namespace ash | 82 } // namespace ash |
| OLD | NEW |