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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/chaos/ChaosPositionCallback.idl ('k') | webkit/chaos/V8ChaosGeolocationCustom.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 #ifndef GeolocationPowerbox_h
2 #define GeolocationPowerbox_h
3
4 #include <functional>
5 #include <map>
6 #include <vector>
7 #include "googleurl/src/gurl.h"
8
9 namespace WebCore {
10 class ChaosGeolocation;
11 class ChooseGeolocationProvider;
12
13 // This class should only be used in the renderer process
14 class GeolocationPowerbox {
15 public:
16 static WebCore::ChooseGeolocationProvider *choose(
17 WebCore::ChaosGeolocation *geolocation);
18
19 // FIXME(benl): probably should be a dynamic list some day.
20 // FIXME(benl): move out of this class, since it is shared across
21 // processes.
22 enum ProviderId {
23 NO_PROVIDER_FOUND, // only used to indicate failure
24 EXACT,
25 CITY,
26 NONE
27 };
28 // FIXME(benl): lazy lazy lazy
29 static const char *decisionAsString(GeolocationPowerbox::ProviderId id) {
30 switch(id) {
31 case EXACT: return "exact location";
32 case CITY: return "rough location";
33 case NONE: return "no location";
34 case NO_PROVIDER_FOUND: return "ARG YOU SHOULD NOT SEE THIS!";
35 }
36 return NULL;
37 }
38 };
39
40 // This class should only be used in the browser process
41 class GeolocationBrowserPowerbox {
42 public:
43 typedef std::pair<GURL, GeolocationPowerbox::ProviderId> DecisionPair;
44
45 void addDecision(const GURL &gurl,
46 GeolocationPowerbox::ProviderId provider_id) {
47 decisions_[gurl] = provider_id;
48 }
49 void deleteDecision(const GURL &gurl) {
50 decisions_.erase(gurl);
51 }
52 GeolocationPowerbox::ProviderId findDecision(const GURL &gurl) const {
53 GURLMap::const_iterator found = decisions_.find(gurl);
54 if (found == decisions_.end())
55 return GeolocationPowerbox::NO_PROVIDER_FOUND;
56 return found->second;
57 }
58 static const DecisionPair identity(const DecisionPair &pair) {
59 return pair;
60 }
61 std::vector<DecisionPair> decisions() const {
62 std::vector<DecisionPair> result;
63
64 std::transform(decisions_.begin(), decisions_.end(),
65 std::back_inserter(result), identity);
66 return result;
67 }
68 static const char *decisionAsString(GeolocationPowerbox::ProviderId id) {
69 return GeolocationPowerbox::decisionAsString(id);
70 }
71 static GeolocationBrowserPowerbox powerbox;
72 private:
73 typedef std::map<GURL, GeolocationPowerbox::ProviderId> GURLMap;
74 GURLMap decisions_;
75 };
76 } // namespace WebCore
77
78
79 #endif // ndef GeolocationPowerbox_h
OLDNEW
« 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