Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(591)

Side by Side Diff: Source/modules/screen_orientation/ScreenOrientationController.cpp

Issue 132113006: Add initial Blink-side support for the Screen Orientation API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add locked-no-orientation-change-event.html layout test Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 , m_hasClientForTest(false)
16 {
17 }
18
19 PassOwnPtr<ScreenOrientationController> ScreenOrientationController::create(Scre enOrientationClient* client)
20 {
21 return adoptPtr(new ScreenOrientationController(client));
22 }
23
24 void ScreenOrientationController::addObserver(ScreenOrientation* observer)
25 {
26 m_observers.add(observer);
27 }
28
29 void ScreenOrientationController::removeObserver(ScreenOrientation* observer)
30 {
31 if (!m_observers.contains(observer))
32 return;
33
34 m_observers.remove(observer);
35 }
36
37 const char* ScreenOrientationController::supplementName()
38 {
39 return "ScreenOrientationController";
40 }
41
42 ScreenOrientationClient* ScreenOrientationController::clientFrom(Page* page)
43 {
44 if (ScreenOrientationController* controller = ScreenOrientationController::f rom(page))
45 return controller->client();
46 return 0;
47 }
48
49 void ScreenOrientationController::orientationChanged(ScreenOrientationValue orie ntation)
50 {
51 if (m_orientation == orientation)
52 return;
53
54 m_orientation = orientation;
55 for (ObserversSet::iterator it = m_observers.begin(); it != m_observers.end( ); ++it)
56 (*it)->orientationChanged();
57 }
58
59 void ScreenOrientationController::setClientForTest(ScreenOrientationClient* clie nt)
60 {
61 m_client = client;
62 m_hasClientForTest = true;
63 }
64
65 void provideScreenOrientation(Page* page, ScreenOrientationClient* client)
66 {
67 ScreenOrientationController::provideTo(page, ScreenOrientationController::su pplementName(), ScreenOrientationController::create(client));
68 }
69
70 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698