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

Unified Diff: Source/modules/geolocation/PositionOptions.cpp

Issue 336343002: Use "Dictionary" for PositionOptions instead of Custom binding (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebasing for removing PerWorldBindings (http://crrev.com/330293002) Created 6 years, 6 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
« no previous file with comments | « Source/modules/geolocation/PositionOptions.h ('k') | Source/modules/modules.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/geolocation/PositionOptions.cpp
diff --git a/Source/modules/geolocation/PositionOptions.cpp b/Source/modules/geolocation/PositionOptions.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e777da2a217344eac5a23b00f60bf4916efb492a
--- /dev/null
+++ b/Source/modules/geolocation/PositionOptions.cpp
@@ -0,0 +1,47 @@
+// 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 "modules/geolocation/PositionOptions.h"
+
+#include "bindings/v8/Dictionary.h"
+#include <limits.h>
+
+namespace WebCore {
+
+PositionOptions* PositionOptions::create(const Dictionary& options)
+{
+ return new PositionOptions(options);
+}
+
+PositionOptions::PositionOptions(const Dictionary& options)
+ : m_highAccuracy(false)
+ , m_maximumAge(0)
+ , m_timeout(std::numeric_limits<unsigned>::max())
+{
+ if (options.hasProperty("enableHighAccuracy"))
+ options.get("enableHighAccuracy", m_highAccuracy);
+ if (options.hasProperty("maximumAge")) {
+ double maximumAge;
+ options.get("maximumAge", maximumAge);
+ if (maximumAge < 0)
+ m_maximumAge = 0;
+ else if (maximumAge > std::numeric_limits<unsigned>::max())
+ m_maximumAge = std::numeric_limits<unsigned>::max();
+ else
+ m_maximumAge = maximumAge;
+ }
+ if (options.hasProperty("timeout")) {
+ double timeout;
+ options.get("timeout", timeout);
+ if (timeout < 0)
+ m_timeout = 0;
+ else if (timeout > std::numeric_limits<unsigned>::max())
+ m_timeout = std::numeric_limits<unsigned>::max();
+ else
+ m_timeout = timeout;
+ }
+}
+
+} // namespace WebCore
« no previous file with comments | « Source/modules/geolocation/PositionOptions.h ('k') | Source/modules/modules.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698