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 , m_orientation(OrientationPortraitPrimary) |
| 15 { |
| 16 } |
| 17 |
| 18 PassOwnPtr<ScreenOrientationController> ScreenOrientationController::create(Scre
enOrientationClient* client) |
| 19 { |
| 20 return adoptPtr(new ScreenOrientationController(client)); |
| 21 } |
| 22 |
| 23 void ScreenOrientationController::addObserver(ScreenOrientation* observer) |
| 24 { |
| 25 m_observers.add(observer); |
| 26 } |
| 27 |
| 28 void ScreenOrientationController::removeObserver(ScreenOrientation* observer) |
| 29 { |
| 30 if (!m_observers.contains(observer)) |
| 31 return; |
| 32 |
| 33 m_observers.remove(observer); |
| 34 } |
| 35 |
| 36 const char* ScreenOrientationController::supplementName() |
| 37 { |
| 38 return "ScreenOrientationController"; |
| 39 } |
| 40 |
| 41 ScreenOrientationClient* ScreenOrientationController::clientFrom(Page* page) |
| 42 { |
| 43 if (ScreenOrientationController* controller = ScreenOrientationController::f
rom(page)) |
| 44 return controller->client(); |
| 45 return 0; |
| 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(); |
| 56 } |
| 57 |
| 58 void provideScreenOrientation(Page* page, ScreenOrientationClient* client) |
| 59 { |
| 60 ScreenOrientationController::provideTo(page, ScreenOrientationController::su
pplementName(), ScreenOrientationController::create(client)); |
| 61 } |
| 62 |
| 63 } // namespace WebCore |
OLD | NEW |