Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/renderer/screen_orientation/mock_screen_orientation_controller .h" | 5 #include "content/renderer/screen_orientation/mock_screen_orientation_controller .h" |
| 6 | 6 |
| 7 #include "base/bind.h" | |
| 7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | |
| 8 #include "third_party/WebKit/public/platform/WebScreenOrientationListener.h" | 10 #include "third_party/WebKit/public/platform/WebScreenOrientationListener.h" |
| 9 | 11 |
| 10 namespace content { | 12 namespace content { |
| 11 | 13 |
| 12 MockScreenOrientationController::MockScreenOrientationController() | 14 MockScreenOrientationController::MockScreenOrientationController() |
| 13 : current_lock_(blink::WebScreenOrientationLockDefault), | 15 : current_lock_(blink::WebScreenOrientationLockDefault), |
| 14 device_orientation_(blink::WebScreenOrientationPortraitPrimary), | 16 device_orientation_(blink::WebScreenOrientationPortraitPrimary), |
| 15 current_orientation_(blink::WebScreenOrientationPortraitPrimary), | 17 current_orientation_(blink::WebScreenOrientationPortraitPrimary), |
| 16 listener_(NULL) { | 18 listener_(NULL) { |
| 19 // Since MockScreenOrientationController is held by LazyInstance reference, | |
| 20 // add this ref for it. | |
| 21 AddRef(); | |
| 17 } | 22 } |
| 18 | 23 |
| 19 void MockScreenOrientationController::SetListener( | 24 void MockScreenOrientationController::SetListener( |
| 20 blink::WebScreenOrientationListener* listener) { | 25 blink::WebScreenOrientationListener* listener) { |
| 21 listener_ = listener; | 26 listener_ = listener; |
| 22 } | 27 } |
| 23 | 28 |
| 24 void MockScreenOrientationController::ResetData() { | 29 void MockScreenOrientationController::ResetData() { |
| 25 current_lock_ = blink::WebScreenOrientationLockDefault; | 30 current_lock_ = blink::WebScreenOrientationLockDefault; |
| 26 device_orientation_ = blink::WebScreenOrientationPortraitPrimary; | 31 device_orientation_ = blink::WebScreenOrientationPortraitPrimary; |
| 27 current_orientation_ = blink::WebScreenOrientationPortraitPrimary; | 32 current_orientation_ = blink::WebScreenOrientationPortraitPrimary; |
| 28 } | 33 } |
| 29 | 34 |
| 30 void MockScreenOrientationController::UpdateLock( | 35 void MockScreenOrientationController::UpdateLock( |
| 31 blink::WebScreenOrientationLockType lock) { | 36 blink::WebScreenOrientationLockType lock) { |
| 37 LOG(ERROR) << "MockScreenOrientationController::UpdateLock()"; | |
|
Inactive
2014/05/28 11:49:39
I think you meant to remove this logging?
ostap
2014/05/28 14:40:21
Done.
| |
| 38 base::MessageLoop::current()->PostTask( | |
| 39 FROM_HERE, | |
| 40 base::Bind(&MockScreenOrientationController::UpdateLockSync, this, lock)); | |
| 41 } | |
| 42 void MockScreenOrientationController::UpdateLockSync( | |
| 43 blink::WebScreenOrientationLockType lock) { | |
| 44 LOG(ERROR) << "MockScreenOrientationController::UpdateLockSync()"; | |
|
Inactive
2014/05/28 11:49:39
ditto.
ostap
2014/05/28 14:40:21
Done.
| |
| 32 DCHECK(lock != blink::WebScreenOrientationLockDefault); | 45 DCHECK(lock != blink::WebScreenOrientationLockDefault); |
| 33 current_lock_ = lock; | 46 current_lock_ = lock; |
| 34 if (!IsOrientationAllowedByCurrentLock(current_orientation_)) | 47 if (!IsOrientationAllowedByCurrentLock(current_orientation_)) |
| 35 UpdateScreenOrientation(SuitableOrientationForCurrentLock()); | 48 UpdateScreenOrientation(SuitableOrientationForCurrentLock()); |
| 36 } | 49 } |
| 37 | 50 |
| 38 void MockScreenOrientationController::ResetLock() { | 51 void MockScreenOrientationController::ResetLock() { |
| 52 base::MessageLoop::current()->PostTask( | |
| 53 FROM_HERE, | |
| 54 base::Bind(&MockScreenOrientationController::ResetLockSync, this)); | |
| 55 } | |
| 56 | |
| 57 void MockScreenOrientationController::ResetLockSync() { | |
| 39 bool will_screen_orientation_need_updating = | 58 bool will_screen_orientation_need_updating = |
| 40 !IsOrientationAllowedByCurrentLock(device_orientation_); | 59 !IsOrientationAllowedByCurrentLock(device_orientation_); |
| 41 current_lock_ = blink::WebScreenOrientationLockDefault; | 60 current_lock_ = blink::WebScreenOrientationLockDefault; |
| 42 if (will_screen_orientation_need_updating) | 61 if (will_screen_orientation_need_updating) |
| 43 UpdateScreenOrientation(device_orientation_); | 62 UpdateScreenOrientation(device_orientation_); |
| 44 } | 63 } |
| 45 | 64 |
| 46 void MockScreenOrientationController::UpdateDeviceOrientation( | 65 void MockScreenOrientationController::UpdateDeviceOrientation( |
| 47 blink::WebScreenOrientationType orientation) { | 66 blink::WebScreenOrientationType orientation) { |
| 48 if (device_orientation_ == orientation) | 67 if (device_orientation_ == orientation) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 case blink::WebScreenOrientationLockLandscape: | 117 case blink::WebScreenOrientationLockLandscape: |
| 99 return blink::WebScreenOrientationLandscapePrimary; | 118 return blink::WebScreenOrientationLandscapePrimary; |
| 100 case blink::WebScreenOrientationLockLandscapeSecondary: | 119 case blink::WebScreenOrientationLockLandscapeSecondary: |
| 101 return blink::WebScreenOrientationLandscapePrimary; | 120 return blink::WebScreenOrientationLandscapePrimary; |
| 102 default: | 121 default: |
| 103 return blink::WebScreenOrientationPortraitPrimary; | 122 return blink::WebScreenOrientationPortraitPrimary; |
| 104 } | 123 } |
| 105 } | 124 } |
| 106 | 125 |
| 107 } // namespace content | 126 } // namespace content |
| OLD | NEW |