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

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: Take feedback into consideration 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 // 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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698