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 | |
123 // Returns the rect of the magnification window. | 108 // Returns the rect of the magnification window. |
124 gfx::RectF GetWindowRectDIP(float scale) const; | 109 gfx::RectF GetWindowRectDIP(float scale) const; |
125 // Returns the size of the root window. | 110 // Returns the size of the root window. |
126 gfx::Size GetHostSizeDIP() const; | 111 gfx::Size GetHostSizeDIP() const; |
127 | 112 |
128 // Correct the givin scale value if nessesary. | 113 // Correct the givin scale value if nessesary. |
129 void ValidateScale(float* scale); | 114 void ValidateScale(float* scale); |
130 | 115 |
131 // ui::EventHandler overrides: | 116 // ui::EventHandler overrides: |
132 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | 117 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 return; | 454 return; |
470 | 455 |
471 EnsurePointIsVisibleWithScale(point, scale_, animate); | 456 EnsurePointIsVisibleWithScale(point, scale_, animate); |
472 } | 457 } |
473 | 458 |
474 void MagnificationControllerImpl::SetEnabled(bool enabled) { | 459 void MagnificationControllerImpl::SetEnabled(bool enabled) { |
475 if (enabled) { | 460 if (enabled) { |
476 float scale = | 461 float scale = |
477 ash::Shell::GetInstance()->delegate()->GetSavedScreenMagnifierScale(); | 462 ash::Shell::GetInstance()->delegate()->GetSavedScreenMagnifierScale(); |
478 if (scale <= 0.0f) | 463 if (scale <= 0.0f) |
479 scale = GetDefaultZoomScale(); | 464 scale = kInitialMagnifiedScale; |
480 ValidateScale(&scale); | 465 ValidateScale(&scale); |
481 | 466 |
482 // Do nothing, if already enabled with same scale. | 467 // Do nothing, if already enabled with same scale. |
483 if (is_enabled_ && scale == scale_) | 468 if (is_enabled_ && scale == scale_) |
484 return; | 469 return; |
485 | 470 |
486 RedrawKeepingMousePosition(scale, true); | 471 RedrawKeepingMousePosition(scale, true); |
| 472 ash::Shell::GetInstance()->delegate()->SaveScreenMagnifierScale(scale); |
487 is_enabled_ = enabled; | 473 is_enabled_ = enabled; |
488 } else { | 474 } else { |
489 // Do nothing, if already disabled. | 475 // Do nothing, if already disabled. |
490 if (!is_enabled_) | 476 if (!is_enabled_) |
491 return; | 477 return; |
492 | 478 |
493 RedrawKeepingMousePosition(kNonMagnifiedScale, true); | 479 RedrawKeepingMousePosition(kNonMagnifiedScale, true); |
494 is_enabled_ = enabled; | 480 is_enabled_ = enabled; |
495 } | 481 } |
496 } | 482 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 | 528 |
543 //////////////////////////////////////////////////////////////////////////////// | 529 //////////////////////////////////////////////////////////////////////////////// |
544 // MagnificationController: | 530 // MagnificationController: |
545 | 531 |
546 // static | 532 // static |
547 MagnificationController* MagnificationController::CreateInstance() { | 533 MagnificationController* MagnificationController::CreateInstance() { |
548 return new MagnificationControllerImpl(); | 534 return new MagnificationControllerImpl(); |
549 } | 535 } |
550 | 536 |
551 } // namespace ash | 537 } // namespace ash |
OLD | NEW |