Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 #include "ScreenOrientationController.h" | |
| 7 | |
| 8 #include "modules/screen_orientation/ScreenOrientationClient.h" | |
| 9 | |
| 10 namespace WebCore { | |
| 11 | |
| 12 ScreenOrientationController::ScreenOrientationController(ScreenOrientationClient * client) | |
| 13 : m_client(client) | |
| 14 // FIXME: This orientation is not necessary the right one until the first or ientationchange | |
|
Inactive
2014/02/13 15:47:30
I would propose to address this issue in a follow-
Peter Beverloo
2014/02/13 16:33:42
That sounds fair to me. Ideally we'd be able to u
| |
| 15 // event is fired. | |
| 16 , m_orientation(OrientationPortraitPrimary) | |
| 17 , m_hasClientForTest(false) | |
| 18 { | |
| 19 } | |
| 20 | |
| 21 ScreenOrientationController::~ScreenOrientationController() | |
| 22 { | |
| 23 if (m_hasClientForTest) | |
| 24 delete m_client; | |
| 25 } | |
| 26 | |
| 27 PassOwnPtr<ScreenOrientationController> ScreenOrientationController::create(Scre enOrientationClient* client) | |
| 28 { | |
| 29 return adoptPtr(new ScreenOrientationController(client)); | |
| 30 } | |
| 31 | |
| 32 void ScreenOrientationController::addObserver(ScreenOrientation* observer) | |
| 33 { | |
| 34 m_observers.add(observer); | |
| 35 } | |
| 36 | |
| 37 void ScreenOrientationController::removeObserver(ScreenOrientation* observer) | |
| 38 { | |
| 39 m_observers.remove(observer); | |
| 40 } | |
| 41 | |
| 42 const char* ScreenOrientationController::supplementName() | |
| 43 { | |
| 44 return "ScreenOrientationController"; | |
| 45 } | |
| 46 | |
| 47 ScreenOrientationClient* ScreenOrientationController::clientFrom(Page* page) | |
| 48 { | |
| 49 if (ScreenOrientationController* controller = ScreenOrientationController::f rom(page)) | |
| 50 return controller->client(); | |
| 51 return 0; | |
| 52 } | |
| 53 | |
| 54 void ScreenOrientationController::orientationChanged(ScreenOrientationValue orie ntation) | |
| 55 { | |
| 56 if (m_orientation == orientation) | |
| 57 return; | |
| 58 | |
| 59 m_orientation = orientation; | |
| 60 for (ObserversSet::iterator it = m_observers.begin(); it != m_observers.end( ); ++it) | |
| 61 (*it)->orientationChanged(); | |
| 62 } | |
| 63 | |
| 64 void ScreenOrientationController::setClientForTest(ScreenOrientationClient* clie nt) | |
| 65 { | |
| 66 if (m_hasClientForTest) | |
| 67 delete m_client; | |
| 68 m_client = client; | |
| 69 m_hasClientForTest = true; | |
| 70 } | |
| 71 | |
| 72 void provideScreenOrientation(Page* page, ScreenOrientationClient* client) | |
| 73 { | |
| 74 ScreenOrientationController::provideTo(page, ScreenOrientationController::su pplementName(), ScreenOrientationController::create(client)); | |
| 75 } | |
| 76 | |
| 77 } // namespace WebCore | |
| OLD | NEW |