OLD | NEW |
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 "ash/magnifier/magnification_controller.h" | 5 #include "ash/magnifier/magnification_controller.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_delegate.h" | 8 #include "ash/shell_delegate.h" |
9 #include "ash/system/tray/system_tray_delegate.h" | 9 #include "ash/system/tray/system_tray_delegate.h" |
10 #include "ui/aura/client/cursor_client.h" | 10 #include "ui/aura/client/cursor_client.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 // Switch Magnified RootWindow to |new_root_window|. This does following: | 99 // Switch Magnified RootWindow to |new_root_window|. This does following: |
100 // - Unzoom the current root_window. | 100 // - Unzoom the current root_window. |
101 // - Zoom the given new root_window |new_root_window|. | 101 // - Zoom the given new root_window |new_root_window|. |
102 // - Switch the target window from current window to |new_root_window|. | 102 // - Switch the target window from current window to |new_root_window|. |
103 void SwitchTargetRootWindow(aura::RootWindow* new_root_window); | 103 void SwitchTargetRootWindow(aura::RootWindow* new_root_window); |
104 | 104 |
105 // Returns if the magnification scale is 1.0 or not (larger then 1.0). | 105 // Returns if the magnification scale is 1.0 or not (larger then 1.0). |
106 bool IsMagnified() const; | 106 bool IsMagnified() const; |
107 | 107 |
| 108 // Returns the default scale which depends on the login status. |
| 109 float GetDefaultZoomScale() const { |
| 110 // TODO(yoshiki,mazda): Do not use SystemTrayDelegate to get the user login |
| 111 // status (http://crbug.com/163170). |
| 112 user::LoginStatus login = Shell::GetInstance()->tray_delegate() ? |
| 113 Shell::GetInstance()->tray_delegate()->GetUserLoginStatus() : |
| 114 user::LOGGED_IN_NONE; |
| 115 |
| 116 // On login screen, don't magnify the screen by default. |
| 117 if (login == user::LOGGED_IN_NONE) |
| 118 return kNonMagnifiedScale; |
| 119 |
| 120 return kInitialMagnifiedScale; |
| 121 } |
| 122 |
108 // Returns the rect of the magnification window. | 123 // Returns the rect of the magnification window. |
109 gfx::RectF GetWindowRectDIP(float scale) const; | 124 gfx::RectF GetWindowRectDIP(float scale) const; |
110 // Returns the size of the root window. | 125 // Returns the size of the root window. |
111 gfx::Size GetHostSizeDIP() const; | 126 gfx::Size GetHostSizeDIP() const; |
112 | 127 |
113 // Correct the givin scale value if nessesary. | 128 // Correct the givin scale value if nessesary. |
114 void ValidateScale(float* scale); | 129 void ValidateScale(float* scale); |
115 | 130 |
116 // ui::EventHandler overrides: | 131 // ui::EventHandler overrides: |
117 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | 132 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 return; | 469 return; |
455 | 470 |
456 EnsurePointIsVisibleWithScale(point, scale_, animate); | 471 EnsurePointIsVisibleWithScale(point, scale_, animate); |
457 } | 472 } |
458 | 473 |
459 void MagnificationControllerImpl::SetEnabled(bool enabled) { | 474 void MagnificationControllerImpl::SetEnabled(bool enabled) { |
460 if (enabled) { | 475 if (enabled) { |
461 float scale = | 476 float scale = |
462 ash::Shell::GetInstance()->delegate()->GetSavedScreenMagnifierScale(); | 477 ash::Shell::GetInstance()->delegate()->GetSavedScreenMagnifierScale(); |
463 if (scale <= 0.0f) | 478 if (scale <= 0.0f) |
464 scale = kInitialMagnifiedScale; | 479 scale = GetDefaultZoomScale(); |
465 ValidateScale(&scale); | 480 ValidateScale(&scale); |
466 | 481 |
467 // Do nothing, if already enabled with same scale. | 482 // Do nothing, if already enabled with same scale. |
468 if (is_enabled_ && scale == scale_) | 483 if (is_enabled_ && scale == scale_) |
469 return; | 484 return; |
470 | 485 |
471 RedrawKeepingMousePosition(scale, true); | 486 RedrawKeepingMousePosition(scale, true); |
472 ash::Shell::GetInstance()->delegate()->SaveScreenMagnifierScale(scale); | |
473 is_enabled_ = enabled; | 487 is_enabled_ = enabled; |
474 } else { | 488 } else { |
475 // Do nothing, if already disabled. | 489 // Do nothing, if already disabled. |
476 if (!is_enabled_) | 490 if (!is_enabled_) |
477 return; | 491 return; |
478 | 492 |
479 RedrawKeepingMousePosition(kNonMagnifiedScale, true); | 493 RedrawKeepingMousePosition(kNonMagnifiedScale, true); |
480 is_enabled_ = enabled; | 494 is_enabled_ = enabled; |
481 } | 495 } |
482 } | 496 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 | 542 |
529 //////////////////////////////////////////////////////////////////////////////// | 543 //////////////////////////////////////////////////////////////////////////////// |
530 // MagnificationController: | 544 // MagnificationController: |
531 | 545 |
532 // static | 546 // static |
533 MagnificationController* MagnificationController::CreateInstance() { | 547 MagnificationController* MagnificationController::CreateInstance() { |
534 return new MagnificationControllerImpl(); | 548 return new MagnificationControllerImpl(); |
535 } | 549 } |
536 | 550 |
537 } // namespace ash | 551 } // namespace ash |
OLD | NEW |