Chromium Code Reviews| Index: Source/modules/screen_orientation/ScreenOrientationController.cpp |
| diff --git a/Source/modules/screen_orientation/ScreenOrientationController.cpp b/Source/modules/screen_orientation/ScreenOrientationController.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..91a955a53f13018a6ed483ce86e08f81ca795685 |
| --- /dev/null |
| +++ b/Source/modules/screen_orientation/ScreenOrientationController.cpp |
| @@ -0,0 +1,67 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "config.h" |
| +#include "ScreenOrientationController.h" |
| + |
| +#include "modules/screen_orientation/ScreenOrientationClient.h" |
| + |
| +namespace WebCore { |
| + |
| +ScreenOrientationController::ScreenOrientationController(ScreenOrientationClient* client) |
| + : m_client(client) |
| + , m_orientation(OrientationPortraitPrimary) |
|
kenneth.r.christiansen
2014/02/12 13:42:37
So this might actually be wrong... how are you mak
Inactive
2014/02/12 16:03:11
Yes, this is not optimal. I haven't given much tho
|
| + , m_hasClientForTest(false) |
| +{ |
| +} |
| + |
| +PassOwnPtr<ScreenOrientationController> ScreenOrientationController::create(ScreenOrientationClient* client) |
| +{ |
| + return adoptPtr(new ScreenOrientationController(client)); |
| +} |
| + |
| +void ScreenOrientationController::addObserver(ScreenOrientation* observer) |
| +{ |
| + m_observers.add(observer); |
| +} |
| + |
| +void ScreenOrientationController::removeObserver(ScreenOrientation* observer) |
| +{ |
| + m_observers.remove(observer); |
| +} |
| + |
| +const char* ScreenOrientationController::supplementName() |
| +{ |
| + return "ScreenOrientationController"; |
| +} |
| + |
| +ScreenOrientationClient* ScreenOrientationController::clientFrom(Page* page) |
| +{ |
| + if (ScreenOrientationController* controller = ScreenOrientationController::from(page)) |
| + return controller->client(); |
| + return 0; |
| +} |
| + |
| +void ScreenOrientationController::orientationChanged(ScreenOrientationValue orientation) |
| +{ |
| + if (m_orientation == orientation) |
| + return; |
| + |
| + m_orientation = orientation; |
| + for (ObserversSet::iterator it = m_observers.begin(); it != m_observers.end(); ++it) |
| + (*it)->orientationChanged(); |
| +} |
| + |
| +void ScreenOrientationController::setClientForTest(ScreenOrientationClient* client) |
| +{ |
| + m_client = client; |
| + m_hasClientForTest = true; |
| +} |
| + |
| +void provideScreenOrientation(Page* page, ScreenOrientationClient* client) |
| +{ |
| + ScreenOrientationController::provideTo(page, ScreenOrientationController::supplementName(), ScreenOrientationController::create(client)); |
| +} |
| + |
| +} // namespace WebCore |