| 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/shell/renderer/test_runner/mock_screen_orientation_client.h" | 5 #include "content/shell/renderer/test_runner/mock_screen_orientation_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "third_party/WebKit/public/web/WebFrame.h" | 10 #include "third_party/WebKit/public/web/WebFrame.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 base::Unretained(this))); | 124 base::Unretained(this))); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void MockScreenOrientationClient::UpdateLockSync( | 127 void MockScreenOrientationClient::UpdateLockSync( |
| 128 blink::WebScreenOrientationLockType lock, | 128 blink::WebScreenOrientationLockType lock, |
| 129 blink::WebLockOrientationCallback* callback) { | 129 blink::WebLockOrientationCallback* callback) { |
| 130 DCHECK(lock != blink::WebScreenOrientationLockDefault); | 130 DCHECK(lock != blink::WebScreenOrientationLockDefault); |
| 131 current_lock_ = lock; | 131 current_lock_ = lock; |
| 132 if (!IsOrientationAllowedByCurrentLock(current_orientation_)) | 132 if (!IsOrientationAllowedByCurrentLock(current_orientation_)) |
| 133 UpdateScreenOrientation(SuitableOrientationForCurrentLock()); | 133 UpdateScreenOrientation(SuitableOrientationForCurrentLock()); |
| 134 unsigned angle = OrientationTypeToAngle(current_orientation_); | 134 callback->onSuccess(); |
| 135 callback->onSuccess(angle, current_orientation_); | |
| 136 } | 135 } |
| 137 | 136 |
| 138 void MockScreenOrientationClient::ResetLockSync() { | 137 void MockScreenOrientationClient::ResetLockSync() { |
| 139 bool will_screen_orientation_need_updating = | 138 bool will_screen_orientation_need_updating = |
| 140 !IsOrientationAllowedByCurrentLock(device_orientation_); | 139 !IsOrientationAllowedByCurrentLock(device_orientation_); |
| 141 current_lock_ = blink::WebScreenOrientationLockDefault; | 140 current_lock_ = blink::WebScreenOrientationLockDefault; |
| 142 if (will_screen_orientation_need_updating) | 141 if (will_screen_orientation_need_updating) |
| 143 UpdateScreenOrientation(device_orientation_); | 142 UpdateScreenOrientation(device_orientation_); |
| 144 } | 143 } |
| 145 | 144 |
| 146 blink::WebScreenOrientationType | 145 blink::WebScreenOrientationType |
| 147 MockScreenOrientationClient::SuitableOrientationForCurrentLock() { | 146 MockScreenOrientationClient::SuitableOrientationForCurrentLock() { |
| 148 switch (current_lock_) { | 147 switch (current_lock_) { |
| 149 case blink::WebScreenOrientationLockPortraitSecondary: | 148 case blink::WebScreenOrientationLockPortraitSecondary: |
| 150 return blink::WebScreenOrientationPortraitSecondary; | 149 return blink::WebScreenOrientationPortraitSecondary; |
| 151 case blink::WebScreenOrientationLockLandscapePrimary: | 150 case blink::WebScreenOrientationLockLandscapePrimary: |
| 152 case blink::WebScreenOrientationLockLandscape: | 151 case blink::WebScreenOrientationLockLandscape: |
| 153 return blink::WebScreenOrientationLandscapePrimary; | 152 return blink::WebScreenOrientationLandscapePrimary; |
| 154 case blink::WebScreenOrientationLockLandscapeSecondary: | 153 case blink::WebScreenOrientationLockLandscapeSecondary: |
| 155 return blink::WebScreenOrientationLandscapePrimary; | 154 return blink::WebScreenOrientationLandscapePrimary; |
| 156 default: | 155 default: |
| 157 return blink::WebScreenOrientationPortraitPrimary; | 156 return blink::WebScreenOrientationPortraitPrimary; |
| 158 } | 157 } |
| 159 } | 158 } |
| 160 | 159 |
| 161 } // namespace content | 160 } // namespace content |
| OLD | NEW |