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 | |
15 // 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.
| |
16 , 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.
| |
17 , m_hasClientForTest(false) | |
18 { | |
19 } | |
20 | |
21 PassOwnPtr<ScreenOrientationController> ScreenOrientationController::create(Scre enOrientationClient* client) | |
22 { | |
23 return adoptPtr(new ScreenOrientationController(client)); | |
24 } | |
25 | |
26 void ScreenOrientationController::addObserver(ScreenOrientation* observer) | |
27 { | |
28 m_observers.add(observer); | |
29 } | |
30 | |
31 void ScreenOrientationController::removeObserver(ScreenOrientation* observer) | |
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 ScreenOrientationController::setClientForTest(ScreenOrientationClient* clie nt) | |
59 { | |
60 m_client = client; | |
61 m_hasClientForTest = true; | |
62 } | |
63 | |
64 void provideScreenOrientation(Page* page, ScreenOrientationClient* client) | |
65 { | |
66 ScreenOrientationController::provideTo(page, ScreenOrientationController::su pplementName(), ScreenOrientationController::create(client)); | |
67 } | |
68 | |
69 } // namespace WebCore | |
OLD | NEW |