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

Unified Diff: Source/modules/screen_orientation/ScreenOrientation.cpp

Issue 168763002: Add initial Screen Orientation API support: IDL changes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Take Adam's 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 side-by-side diff with in-line comments
Download patch
Index: Source/modules/screen_orientation/ScreenOrientation.cpp
diff --git a/Source/modules/screen_orientation/ScreenOrientation.cpp b/Source/modules/screen_orientation/ScreenOrientation.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c1e91c16dfab266ee0f2be9a0cc4368de0e34597
--- /dev/null
+++ b/Source/modules/screen_orientation/ScreenOrientation.cpp
@@ -0,0 +1,72 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "ScreenOrientation.h"
abarth-chromium 2014/02/16 09:14:11 Please use paths relative to Source when including
Inactive 2014/02/16 14:09:14 Done.
+
+#include "core/frame/DOMWindow.h"
+#include "core/frame/Frame.h"
+#include "core/frame/Screen.h"
+
+namespace WebCore {
+
+ScreenOrientation::ScreenOrientation(Screen* screen)
+ : DOMWindowProperty(screen->frame())
+{
+}
+
+const char* ScreenOrientation::supplementName()
+{
+ return "ScreenOrientation";
+}
+
+ScreenOrientation* ScreenOrientation::from(Screen* screen)
+{
+ ScreenOrientation* supplement = static_cast<ScreenOrientation*>(Supplement<Screen>::from(screen, supplementName()));
+ if (!supplement) {
+ ASSERT(screen);
+ supplement = new ScreenOrientation(screen);
+ provideTo(screen, supplementName(), adoptPtr(supplement));
+ }
+ return supplement;
+}
+
+ScreenOrientation::~ScreenOrientation()
+{
+}
+
+Screen* ScreenOrientation::screen() const
+{
+ Frame* frame = this->frame();
+ ASSERT(frame);
abarth-chromium 2014/02/16 09:14:11 It's possible for frame to be zero here, but it's
+ DOMWindow* window = frame->domWindow();
+ ASSERT(window);
+ return window->screen();
+}
+
+const AtomicString& ScreenOrientation::orientation(Screen* screen)
+{
+ // FIXME: Implement.
+ DEFINE_STATIC_LOCAL(const AtomicString, portraitPrimary, ("portrait-primary", AtomicString::ConstructFromLiteral));
+ return portraitPrimary;
+}
+
+bool ScreenOrientation::lockOrientation(Screen* screen, const Vector<String>& orientations)
+{
+ // FIXME: Implement.
+ return false;
+}
+
+bool ScreenOrientation::lockOrientation(Screen* screen, const AtomicString& orientation)
+{
+ // FIXME: Implement.
+ return false;
+}
+
+void ScreenOrientation::unlockOrientation(Screen* screen)
+{
+ // FIXME: Implement.
+}
+
+} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698