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..1a14a6aac2c346c753d605b626995a8d6c94c72d |
--- /dev/null |
+++ b/Source/modules/screen_orientation/ScreenOrientationController.cpp |
@@ -0,0 +1,69 @@ |
+// 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) |
+ // FIXME: This orientation is not necessary the right one until the first orientationchange |
+ // event is fired. |
mlamouri (slow - plz ping)
2014/02/12 20:11:26
What could we do to fix that? Would that be reason
Inactive
2014/02/12 21:08:04
Yes, we could then initialize m_orientation to Ori
mlamouri (slow - plz ping)
2014/02/13 16:12:08
Let's solve that in a follow-up.
|
+ , m_orientation(OrientationPortraitPrimary) |
mlamouri (slow - plz ping)
2014/02/12 20:11:26
Does that mean that if a page is loaded in another
Inactive
2014/02/12 21:08:04
I don't think it would, as there would be no orien
mlamouri (slow - plz ping)
2014/02/13 16:12:08
And that.
|
+ , 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 |