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 "modules/screen_orientation/ScreenOrientationController.h" | |
| 7 | |
| 8 #include "core/page/Page.h" | |
| 9 | |
| 10 namespace WebCore { | |
| 11 | |
| 12 PassOwnPtr<ScreenOrientationController> ScreenOrientationController::create() | |
| 13 { | |
| 14 return adoptPtr(new ScreenOrientationController()); | |
| 15 } | |
| 16 | |
| 17 ScreenOrientationController::~ScreenOrientationController() | |
| 18 { | |
| 19 } | |
|
abarth-chromium
2014/02/18 01:34:27
Please ASSERT(m_observers.isEmpty()) here.
Inactive
2014/02/18 20:52:47
observers are now in the Dispatcher class, which i
| |
| 20 | |
| 21 void ScreenOrientationController::addObserver(ScreenOrientation* observer) | |
| 22 { | |
| 23 m_observers.add(observer); | |
| 24 } | |
| 25 | |
| 26 void ScreenOrientationController::removeObserver(ScreenOrientation* observer) | |
| 27 { | |
| 28 m_observers.remove(observer); | |
| 29 } | |
| 30 | |
| 31 const char* ScreenOrientationController::supplementName() | |
| 32 { | |
| 33 return "ScreenOrientationController"; | |
| 34 } | |
| 35 | |
| 36 ScreenOrientationController::ScreenOrientationController() | |
| 37 // FIXME: This orientation is not necessary the right one until the first or ientationchange | |
| 38 // event is fired. | |
| 39 : m_orientation(OrientationPortraitPrimary) | |
| 40 { | |
| 41 } | |
| 42 | |
| 43 ScreenOrientationController* ScreenOrientationController::from(Page* page) | |
| 44 { | |
| 45 return static_cast<ScreenOrientationController*>(Supplement<Page>::from(page , supplementName())); | |
| 46 } | |
| 47 | |
| 48 void ScreenOrientationController::orientationChanged(ScreenOrientationValue orie ntation) | |
| 49 { | |
| 50 if (m_orientation == orientation) | |
| 51 return; | |
| 52 | |
| 53 m_orientation = orientation; | |
| 54 for (ObserversSet::iterator it = m_observers.begin(); it != m_observers.end( ); ++it) | |
| 55 (*it)->orientationChanged(); | |
|
abarth-chromium
2014/02/18 01:34:27
This is a weak iteration pattern. What if m_obser
Inactive
2014/02/18 20:52:47
Done, used the same code as DeviceOrientation.
| |
| 56 } | |
| 57 | |
| 58 void provideScreenOrientationTo(Page* page) | |
| 59 { | |
| 60 ScreenOrientationController::provideTo(page, ScreenOrientationController::su pplementName(), ScreenOrientationController::create()); | |
| 61 } | |
| 62 | |
| 63 } // namespace WebCore | |
| OLD | NEW |