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

Unified Diff: webkit/chaos/GeolocationPowerbox.h

Issue 160084: Chaos geolocation demo, non-WebKit part. Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 4 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 | « webkit/chaos/ChaosPositionCallback.idl ('k') | webkit/chaos/V8ChaosGeolocationCustom.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/chaos/GeolocationPowerbox.h
===================================================================
--- webkit/chaos/GeolocationPowerbox.h (revision 0)
+++ webkit/chaos/GeolocationPowerbox.h (revision 0)
@@ -0,0 +1,79 @@
+#ifndef GeolocationPowerbox_h
+#define GeolocationPowerbox_h
+
+#include <functional>
+#include <map>
+#include <vector>
+#include "googleurl/src/gurl.h"
+
+namespace WebCore {
+class ChaosGeolocation;
+class ChooseGeolocationProvider;
+
+// This class should only be used in the renderer process
+class GeolocationPowerbox {
+ public:
+ static WebCore::ChooseGeolocationProvider *choose(
+ WebCore::ChaosGeolocation *geolocation);
+
+ // FIXME(benl): probably should be a dynamic list some day.
+ // FIXME(benl): move out of this class, since it is shared across
+ // processes.
+ enum ProviderId {
+ NO_PROVIDER_FOUND, // only used to indicate failure
+ EXACT,
+ CITY,
+ NONE
+ };
+ // FIXME(benl): lazy lazy lazy
+ static const char *decisionAsString(GeolocationPowerbox::ProviderId id) {
+ switch(id) {
+ case EXACT: return "exact location";
+ case CITY: return "rough location";
+ case NONE: return "no location";
+ case NO_PROVIDER_FOUND: return "ARG YOU SHOULD NOT SEE THIS!";
+ }
+ return NULL;
+ }
+};
+
+// This class should only be used in the browser process
+class GeolocationBrowserPowerbox {
+ public:
+ typedef std::pair<GURL, GeolocationPowerbox::ProviderId> DecisionPair;
+
+ void addDecision(const GURL &gurl,
+ GeolocationPowerbox::ProviderId provider_id) {
+ decisions_[gurl] = provider_id;
+ }
+ void deleteDecision(const GURL &gurl) {
+ decisions_.erase(gurl);
+ }
+ GeolocationPowerbox::ProviderId findDecision(const GURL &gurl) const {
+ GURLMap::const_iterator found = decisions_.find(gurl);
+ if (found == decisions_.end())
+ return GeolocationPowerbox::NO_PROVIDER_FOUND;
+ return found->second;
+ }
+ static const DecisionPair identity(const DecisionPair &pair) {
+ return pair;
+ }
+ std::vector<DecisionPair> decisions() const {
+ std::vector<DecisionPair> result;
+
+ std::transform(decisions_.begin(), decisions_.end(),
+ std::back_inserter(result), identity);
+ return result;
+ }
+ static const char *decisionAsString(GeolocationPowerbox::ProviderId id) {
+ return GeolocationPowerbox::decisionAsString(id);
+ }
+ static GeolocationBrowserPowerbox powerbox;
+ private:
+ typedef std::map<GURL, GeolocationPowerbox::ProviderId> GURLMap;
+ GURLMap decisions_;
+};
+} // namespace WebCore
+
+
+#endif // ndef GeolocationPowerbox_h
Property changes on: webkit/chaos/GeolocationPowerbox.h
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « webkit/chaos/ChaosPositionCallback.idl ('k') | webkit/chaos/V8ChaosGeolocationCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698