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

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 Kenneth as OWNER 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)
kenneth.r.christiansen 2014/02/12 13:42:37 So this might actually be wrong... how are you mak
Inactive 2014/02/12 16:03:11 Yes, this is not optimal. I haven't given much tho
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 m_observers.remove(observer);
32 }
33
34 const char* ScreenOrientationController::supplementName()
35 {
36 return "ScreenOrientationController";
37 }
38
39 ScreenOrientationClient* ScreenOrientationController::clientFrom(Page* page)
40 {
41 if (ScreenOrientationController* controller = ScreenOrientationController::f rom(page))
42 return controller->client();
43 return 0;
44 }
45
46 void ScreenOrientationController::orientationChanged(ScreenOrientationValue orie ntation)
47 {
48 if (m_orientation == orientation)
49 return;
50
51 m_orientation = orientation;
52 for (ObserversSet::iterator it = m_observers.begin(); it != m_observers.end( ); ++it)
53 (*it)->orientationChanged();
54 }
55
56 void ScreenOrientationController::setClientForTest(ScreenOrientationClient* clie nt)
57 {
58 m_client = client;
59 m_hasClientForTest = true;
60 }
61
62 void provideScreenOrientation(Page* page, ScreenOrientationClient* client)
63 {
64 ScreenOrientationController::provideTo(page, ScreenOrientationController::su pplementName(), ScreenOrientationController::create(client));
65 }
66
67 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698