| 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 "components/test_runner/mock_screen_orientation_client.h" | 5 #include "components/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" | |
| 10 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 11 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 12 | 12 |
| 13 namespace test_runner { | 13 namespace test_runner { |
| 14 | 14 |
| 15 MockScreenOrientationClient::MockScreenOrientationClient() | 15 MockScreenOrientationClient::MockScreenOrientationClient() |
| 16 : main_frame_(NULL), | 16 : main_frame_(NULL), |
| 17 current_lock_(blink::WebScreenOrientationLockDefault), | 17 current_lock_(blink::WebScreenOrientationLockDefault), |
| 18 device_orientation_(blink::WebScreenOrientationPortraitPrimary), | 18 device_orientation_(blink::WebScreenOrientationPortraitPrimary), |
| 19 current_orientation_(blink::WebScreenOrientationPortraitPrimary), | 19 current_orientation_(blink::WebScreenOrientationPortraitPrimary), |
| 20 is_disabled_(false) { | 20 is_disabled_(false) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 blink::WebScreenOrientationLockLandscapeSecondary || | 109 blink::WebScreenOrientationLockLandscapeSecondary || |
| 110 current_lock_ == blink::WebScreenOrientationLockLandscape; | 110 current_lock_ == blink::WebScreenOrientationLockLandscape; |
| 111 default: | 111 default: |
| 112 return false; | 112 return false; |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 | 115 |
| 116 void MockScreenOrientationClient::lockOrientation( | 116 void MockScreenOrientationClient::lockOrientation( |
| 117 blink::WebScreenOrientationLockType orientation, | 117 blink::WebScreenOrientationLockType orientation, |
| 118 blink::WebLockOrientationCallback* callback) { | 118 blink::WebLockOrientationCallback* callback) { |
| 119 base::MessageLoop::current()->task_runner()->PostTask( | 119 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 120 FROM_HERE, base::Bind(&MockScreenOrientationClient::UpdateLockSync, | 120 FROM_HERE, base::Bind(&MockScreenOrientationClient::UpdateLockSync, |
| 121 base::Unretained(this), orientation, callback)); | 121 base::Unretained(this), orientation, callback)); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void MockScreenOrientationClient::unlockOrientation() { | 124 void MockScreenOrientationClient::unlockOrientation() { |
| 125 base::MessageLoop::current()->task_runner()->PostTask( | 125 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 126 FROM_HERE, base::Bind(&MockScreenOrientationClient::ResetLockSync, | 126 FROM_HERE, base::Bind(&MockScreenOrientationClient::ResetLockSync, |
| 127 base::Unretained(this))); | 127 base::Unretained(this))); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void MockScreenOrientationClient::UpdateLockSync( | 130 void MockScreenOrientationClient::UpdateLockSync( |
| 131 blink::WebScreenOrientationLockType lock, | 131 blink::WebScreenOrientationLockType lock, |
| 132 blink::WebLockOrientationCallback* callback) { | 132 blink::WebLockOrientationCallback* callback) { |
| 133 DCHECK(lock != blink::WebScreenOrientationLockDefault); | 133 DCHECK(lock != blink::WebScreenOrientationLockDefault); |
| 134 current_lock_ = lock; | 134 current_lock_ = lock; |
| 135 if (!IsOrientationAllowedByCurrentLock(current_orientation_)) | 135 if (!IsOrientationAllowedByCurrentLock(current_orientation_)) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 155 case blink::WebScreenOrientationLockLandscape: | 155 case blink::WebScreenOrientationLockLandscape: |
| 156 return blink::WebScreenOrientationLandscapePrimary; | 156 return blink::WebScreenOrientationLandscapePrimary; |
| 157 case blink::WebScreenOrientationLockLandscapeSecondary: | 157 case blink::WebScreenOrientationLockLandscapeSecondary: |
| 158 return blink::WebScreenOrientationLandscapePrimary; | 158 return blink::WebScreenOrientationLandscapePrimary; |
| 159 default: | 159 default: |
| 160 return blink::WebScreenOrientationPortraitPrimary; | 160 return blink::WebScreenOrientationPortraitPrimary; |
| 161 } | 161 } |
| 162 } | 162 } |
| 163 | 163 |
| 164 } // namespace test_runner | 164 } // namespace test_runner |
| OLD | NEW |